diff options
Diffstat (limited to 'lisp/gnus')
-rw-r--r-- | lisp/gnus/ChangeLog | 20 | ||||
-rw-r--r-- | lisp/gnus/gnus-bcklg.el | 4 | ||||
-rw-r--r-- | lisp/gnus/nnimap.el | 20 | ||||
-rw-r--r-- | lisp/gnus/nnir.el | 123 | ||||
-rw-r--r-- | lisp/gnus/nnmairix.el | 2 |
5 files changed, 116 insertions, 53 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 7ef526b4253..7bf4a6e01d6 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,23 @@ +2015-01-27 Lars Ingebrigtsen <larsi@gnus.org> + + * nnir.el (nnir-imap-expr-to-imap): Check for literal+ capability in + IMAP. + +2015-01-27 Eric Abrahamsen <eric@ericabrahamsen.net> + + * nnir.el (nnir-run-imap): Enable non-ASCII IMAP searches. + + * nnmairix.el ("nnmairix"): Declare nnmairix as virtual. + + * gnus-bcklg.el (gnus-backlog-enter-article): No virtual groups should + be added to the backlog. + +2015-01-26 Trevor Murphy <trevor.m.murphy@gmail.com> + + * nnimap.el (nnimap-header-parameters): Refactor and request + X-GM-LABELS if it's been announced. + (nnimap-transform-headers): Gather and output GM-LABELS. + 2015-01-26 Peder O. Klingenberg <peder@klingenberg.no> * mm-decode.el (mm-display-part): Make non-string methods work. diff --git a/lisp/gnus/gnus-bcklg.el b/lisp/gnus/gnus-bcklg.el index b26f367a79b..e0c457a8829 100644 --- a/lisp/gnus/gnus-bcklg.el +++ b/lisp/gnus/gnus-bcklg.el @@ -61,7 +61,7 @@ (defun gnus-backlog-enter-article (group number buffer) (when (and (numberp number) - (not (string-match "^nnvirtual" group))) + (not (gnus-virtual-group-p group))) (gnus-backlog-setup) (let ((ident (intern (concat group ":" (int-to-string number)) gnus-backlog-hashtb)) @@ -126,7 +126,7 @@ (defun gnus-backlog-request-article (group number &optional buffer) (when (and (numberp number) - (not (string-match "^nnvirtual" group))) + (not (gnus-virtual-group-p group))) (gnus-backlog-setup) (let ((ident (intern (concat group ":" (int-to-string number)) gnus-backlog-hashtb)) diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index ced55619881..8e81abcf9c0 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -166,14 +166,21 @@ textual parts.") (nnimap-find-process-buffer nntp-server-buffer)) (defun nnimap-header-parameters () - (format "(UID RFC822.SIZE BODYSTRUCTURE %s)" - (format + (let (params) + (push "UID" params) + (push "RFC822.SIZE" params) + (when (nnimap-capability "X-GM-EXT-1") + (push "X-GM-LABELS" params)) + (push "BODYSTRUCTURE" params) + (push (format (if (nnimap-ver4-p) "BODY.PEEK[HEADER.FIELDS %s]" "RFC822.HEADER.LINES %s") (append '(Subject From Date Message-Id References In-Reply-To Xref) - nnmail-extra-headers)))) + nnmail-extra-headers)) + params) + (format "%s" (nreverse params)))) (deffoo nnimap-retrieve-headers (articles &optional group server fetch-old) (when group @@ -197,7 +204,7 @@ textual parts.") (defun nnimap-transform-headers () (goto-char (point-min)) - (let (article lines size string) + (let (article lines size string labels) (block nil (while (not (eobp)) (while (not (looking-at "\\* [0-9]+ FETCH")) @@ -232,6 +239,9 @@ textual parts.") t) (match-string 1))) (beginning-of-line) + (when (search-forward "X-GM-LABELS" (line-end-position) t) + (setq labels (ignore-errors (read (current-buffer))))) + (beginning-of-line) (when (search-forward "BODYSTRUCTURE" (line-end-position) t) (let ((structure (ignore-errors (read (current-buffer))))) @@ -251,6 +261,8 @@ textual parts.") (insert (format "Chars: %s\n" size))) (when lines (insert (format "Lines: %s\n" lines))) + (when labels + (insert (format "X-GM-LABELS: %s\n" labels))) ;; Most servers have a blank line after the headers, but ;; Davmail doesn't. (unless (re-search-forward "^\r$\\|^)\r?$" nil t) diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el index 08ca7c7e06b..6d111e89e80 100644 --- a/lisp/gnus/nnir.el +++ b/lisp/gnus/nnir.el @@ -284,6 +284,8 @@ is `(valuefunc member)'." (eval-when-compile (autoload 'nnimap-buffer "nnimap") (autoload 'nnimap-command "nnimap") + (autoload 'nnimap-capability "nnimap") + (autoload 'nnimap-wait-for-line "nnimap") (autoload 'nnimap-change-group "nnimap") (autoload 'nnimap-make-thread-query "nnimap") (autoload 'gnus-registry-action "gnus-registry") @@ -968,33 +970,52 @@ details on the language and supported extensions." (catch 'found (mapcar #'(lambda (group) - (let (artlist) - (condition-case () - (when (nnimap-change-group - (gnus-group-short-name group) server) - (with-current-buffer (nnimap-buffer) - (message "Searching %s..." group) - (let ((arts 0) - (result (nnimap-command "UID SEARCH %s" - (if (string= criteria "") - qstring - (nnir-imap-make-query - criteria qstring))))) - (mapc - (lambda (artnum) - (let ((artn (string-to-number artnum))) - (when (> artn 0) - (push (vector group artn 100) - artlist) - (when (assq 'shortcut query) - (throw 'found (list artlist))) - (setq arts (1+ arts))))) - (and (car result) - (cdr (assoc "SEARCH" (cdr result))))) - (message "Searching %s... %d matches" group arts))) - (message "Searching %s...done" group)) - (quit nil)) - (nreverse artlist))) + (let (artlist) + (condition-case () + (when (nnimap-change-group + (gnus-group-short-name group) server) + (with-current-buffer (nnimap-buffer) + (message "Searching %s..." group) + (let* ((arts 0) + (literal+ (nnimap-capability "LITERAL+")) + (search (split-string + (if (string= criteria "") + qstring + (nnir-imap-make-query + criteria qstring)) + "\n")) + (coding (upcase + (replace-regexp-in-string + "-\\(unix\\|dos\\|mac\\)" "" + (symbol-name + (cdr default-process-coding-system))))) + call result) + (setq call (nnimap-send-command + "UID SEARCH CHARSET %s %s" coding (pop search))) + (while search ; Non-ascii search terms + (unless literal+ + (nnimap-wait-for-line "^\\+\\(.*\\)\n")) + (process-send-string (get-buffer-process (current-buffer)) (pop search)) + (process-send-string (get-buffer-process (current-buffer)) + (if (nnimap-newlinep nnimap-object) + "\n" + "\r\n"))) + (setq result (nnimap-get-response call)) + (mapc + (lambda (artnum) + (let ((artn (string-to-number artnum))) + (when (> artn 0) + (push (vector group artn 100) + artlist) + (when (assq 'shortcut query) + (throw 'found (list artlist))) + (setq arts (1+ arts))))) + (and (car result) + (cdr (assoc "SEARCH" (cdr result))))) + (message "Searching %s... %d matches" group arts))) + (message "Searching %s...done" group)) + (quit nil)) + (nreverse artlist))) groups)))))) (defun nnir-imap-make-query (criteria qstring) @@ -1048,25 +1069,30 @@ In future the following will be added to the language: (defun nnir-imap-expr-to-imap (criteria expr) "Convert EXPR into an IMAP search expression on CRITERIA" ;; What sort of expression is this, eh? - (cond - ;; Simple string term - ((stringp expr) - (format "%s %S" criteria expr)) - ;; Trivial term: and - ((eq expr 'and) nil) - ;; Composite term: or expression - ((eq (car-safe expr) 'or) - (format "OR %s %s" - (nnir-imap-expr-to-imap criteria (second expr)) - (nnir-imap-expr-to-imap criteria (third expr)))) - ;; Composite term: just the fax, mam - ((eq (car-safe expr) 'not) - (format "NOT (%s)" (nnir-imap-query-to-imap criteria (rest expr)))) - ;; Composite term: just expand it all. - ((and (not (null expr)) (listp expr)) - (format "(%s)" (nnir-imap-query-to-imap criteria expr))) - ;; Complex value, give up for now. - (t (error "Unhandled input: %S" expr)))) + (let ((literal+ (nnimap-capability "LITERAL+"))) + (cond + ;; Simple string term + ((stringp expr) + (format "%s %S" criteria expr)) + ;; Trivial term: and + ((eq expr 'and) nil) + ;; Composite term: or expression + ((eq (car-safe expr) 'or) + (format "OR %s %s" + (nnir-imap-expr-to-imap criteria (second expr)) + (nnir-imap-expr-to-imap criteria (third expr)))) + ;; Composite term: just the fax, mam + ((eq (car-safe expr) 'not) + (format "NOT (%s)" (nnir-imap-query-to-imap criteria (rest expr)))) + ;; Composite term: non-ascii search term + ((numberp (car-safe expr)) + (format "%s {%d%s}\n%s" criteria (car expr) + (if literal+ "+" "") (second expr))) + ;; Composite term: just expand it all. + ((and (not (null expr)) (listp expr)) + (format "(%s)" (nnir-imap-query-to-imap criteria expr))) + ;; Complex value, give up for now. + (t (error "Unhandled input: %S" expr))))) (defun nnir-imap-parse-query (string) @@ -1108,6 +1134,11 @@ that the search language can then understand and use." ((eq term 'and) 'and) ;; negated term ((eq term 'not) (list 'not (nnir-imap-next-expr))) + ;; non-ascii search string + ((and (stringp term) + (not (= (string-bytes term) + (length term)))) + (list (string-bytes term) term)) ;; generic term (t term)))) diff --git a/lisp/gnus/nnmairix.el b/lisp/gnus/nnmairix.el index 5a01ce8c25c..96b40e5b845 100644 --- a/lisp/gnus/nnmairix.el +++ b/lisp/gnus/nnmairix.el @@ -417,7 +417,7 @@ Other back ends might or might not work.") (nnoo-define-basics nnmairix) -(gnus-declare-backend "nnmairix" 'mail 'address) +(gnus-declare-backend "nnmairix" 'mail 'address 'virtual) (deffoo nnmairix-open-server (server &optional definitions) ;; just set server variables |