From d30dd079c92097ac9eee48d574ce609da778b50f Mon Sep 17 00:00:00 2001 From: Gnus developers Date: Tue, 5 Jul 2011 22:27:16 +0000 Subject: [PATCH] Merge changes made in Gnus trunk. gnus.texi (Expiring Mail): Document gnus-auto-expirable-marks. nnir.el (nnir-notmuch-program, nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix, nnir-engines, nnir-run-notmuch): New nnir `notmuch' backend. mm-decode.el (mm-text-html-renderer): Doc fix. gnus-msg.el (gnus-bug): Fix the MML tag. pop3.el (pop3-open-server): -ERR is a valid response to CAPA. gnus-start.el (gnus-get-unread-articles): Don't connect to the secondary methods if started with `gnus-no-server'. gnus-group.el (gnus-read-ephemeral-bug-group): Allow fetching several bug reports at once. --- doc/misc/ChangeLog | 4 ++ doc/misc/gnus.texi | 6 ++- lisp/gnus/ChangeLog | 19 +++++++++ lisp/gnus/gnus-group.el | 23 ++++++----- lisp/gnus/gnus-msg.el | 8 ++-- lisp/gnus/gnus-start.el | 17 ++++---- lisp/gnus/mm-decode.el | 14 +++---- lisp/gnus/nnir.el | 101 ++++++++++++++++++++++++++++++++++++++++++++++++ lisp/gnus/pop3.el | 2 +- 9 files changed, 163 insertions(+), 31 deletions(-) diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index e388b54b7c2..f6a6c396ef4 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,7 @@ +2011-07-05 Lars Magne Ingebrigtsen + + * gnus.texi (Expiring Mail): Document gnus-auto-expirable-marks. + 2011-07-04 Michael Albinus * tramp.texi (Cleanup remote connections): Add diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 3bce492d831..c9206363a9b 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -15648,14 +15648,16 @@ will remain on your system until hell freezes over. This bears repeating one more time, with some spurious capitalizations: IF you do NOT mark articles as EXPIRABLE, Gnus will NEVER delete those ARTICLES. +@vindex gnus-auto-expirable-marks You do not have to mark articles as expirable by hand. Gnus provides two features, called ``auto-expire'' and ``total-expire'', that can help you with this. In a nutshell, ``auto-expire'' means that Gnus hits @kbd{E} for you when you select an article. And ``total-expire'' means that Gnus considers all articles as expirable that are read. So, in addition to the articles marked @samp{E}, also the articles marked @samp{r}, -@samp{R}, @samp{O}, @samp{K}, @samp{Y} and so on are considered -expirable. +@samp{R}, @samp{O}, @samp{K}, @samp{Y} (and so on) are considered +expirable. @code{gnus-auto-expirable-marks} has the full list of +these marks. When should either auto-expire or total-expire be used? Most people who are subscribed to mailing lists split each list into its own group diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index f8d1a74ead0..439d51fdce5 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -3,6 +3,25 @@ * gnus.el (gnus-refer-article-method): Remove mention of nnspool, which no longer is much used. +2011-04-03 Kan-Ru Chen + + * nnir.el (nnir-notmuch-program, nnir-notmuch-additional-switches) + (nnir-notmuch-remove-prefix, nnir-engines, nnir-run-notmuch): New nnir + `notmuch' backend. + +2011-07-05 Lars Magne Ingebrigtsen + + * mm-decode.el (mm-text-html-renderer): Doc fix. + + * gnus-msg.el (gnus-bug): Fix the MML tag. + + * pop3.el (pop3-open-server): -ERR is a valid response to CAPA. + +2011-07-05 Daiki Ueno + + * gnus-start.el (gnus-get-unread-articles): Don't connect to the + secondary methods if started with `gnus-no-server'. + 2011-07-05 Juanma Barranquero * message.el (message-return-action): Fix typo in docstring. diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 83383186ca9..da6550c1680 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -2428,25 +2428,28 @@ the bug number, and browsing the URL must return mbox output." :version "24.1" :type '(repeat (cons (symbol) (string :tag "URL format string")))) -(defun gnus-read-ephemeral-bug-group (number mbox-url &optional window-conf) +(defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf) "Browse bug NUMBER as ephemeral group." (interactive (list (read-string "Enter bug number: " (thing-at-point 'word) nil) ;; FIXME: Add completing-read from ;; `gnus-emacs-bug-group-download-format' ... (cdr (assoc 'emacs gnus-bug-group-download-format-alist)))) - (when (stringp number) - (setq number (string-to-number number))) + (when (stringp ids) + (setq ids (string-to-number ids))) + (unless (listp ids) + (setq ids (list ids))) (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")) (coding-system-for-write 'binary) (coding-system-for-read 'binary)) (with-temp-file tmpfile - (url-insert-file-contents (format mbox-url number)) + (dolist (id ids) + (url-insert-file-contents (format mbox-url id))) (goto-char (point-min)) ;; Add the debbugs address so that we can respond to reports easily. (while (re-search-forward "^To: " nil t) (end-of-line) - (insert (format ", %s@%s" number + (insert (format ", %s@%s" (car ids) (gnus-replace-in-string (gnus-replace-in-string mbox-url "^http://" "") "/.*$" "")))) @@ -2466,19 +2469,21 @@ the bug number, and browsing the URL must return mbox output." number (cdr (assoc 'debian gnus-bug-group-download-format-alist)))) -(defun gnus-read-ephemeral-emacs-bug-group (number &optional window-conf) - "Browse Emacs bug NUMBER as ephemeral group." +(defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf) + "Browse Emacs bugs IDS as an ephemeral group." (interactive (list (string-to-number (read-string "Enter bug number: " (thing-at-point 'word) nil)))) + (unless (listp ids) + (setq ids (list ids))) (gnus-read-ephemeral-bug-group - number + ids (cdr (assoc 'emacs gnus-bug-group-download-format-alist)) window-conf) (when (boundp 'debbugs-summary-mode) (with-current-buffer (window-buffer (selected-window)) (debbugs-summary-mode 1) - (set (make-local-variable 'debbugs-bug-number) number)))) + (set (make-local-variable 'debbugs-bug-number) (car ids))))) (defun gnus-group-jump-to-group (group &optional prompt) "Jump to newsgroup GROUP. diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el index b265a681eb8..bad474b4057 100644 --- a/lisp/gnus/gnus-msg.el +++ b/lisp/gnus/gnus-msg.el @@ -1480,10 +1480,10 @@ If YANK is non-nil, include the original article." (erase-buffer) (gnus-debug) (setq text (buffer-string))) - (insert (concat "<#part type=application/emacs-lisp" - "disposition=inline description=\"User settings\">\n" - text - "\n<#/part>"))) + (insert "<#part type=application/emacs-lisp " + "disposition=inline description=\"User settings\">\n" + text + "\n<#/part>")) (goto-char (point-min)) (search-forward "Subject: " nil t) (message ""))) diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index aa9af012a1c..7c63d5e2653 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -1043,7 +1043,7 @@ If LEVEL is non-nil, the news will be set up at level LEVEL." ;; Find the number of unread articles in each non-dead group. (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) - (gnus-get-unread-articles level)))) + (gnus-get-unread-articles level dont-connect)))) (defun gnus-call-subscribe-functions (method group) "Call METHOD to subscribe GROUP. @@ -1606,7 +1606,7 @@ If SCAN, request a scan of that group as well." ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' ;; and compute how many unread articles there are in each group. -(defun gnus-get-unread-articles (&optional level) +(defun gnus-get-unread-articles (&optional level dont-connect) (setq gnus-server-method-cache nil) (require 'gnus-agent) (let* ((newsrc (cdr gnus-newsrc-alist)) @@ -1702,12 +1702,13 @@ If SCAN, request a scan of that group as well." ;; If we have primary/secondary select methods, but no groups from ;; them, we still want to issue a retrieval request from them. - (dolist (method (cons gnus-select-method - gnus-secondary-select-methods)) - (when (and (not (assoc method type-cache)) - (gnus-check-backend-function 'request-list (car method))) - (with-current-buffer nntp-server-buffer - (gnus-read-active-file-1 method nil)))) + (unless dont-connect + (dolist (method (cons gnus-select-method + gnus-secondary-select-methods)) + (when (and (not (assoc method type-cache)) + (gnus-check-backend-function 'request-list (car method))) + (with-current-buffer nntp-server-buffer + (gnus-read-active-file-1 method nil))))) ;; Start early async retrieval of data. (let ((done-methods nil) diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index f543920446b..a51c6630ac5 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -114,14 +114,14 @@ "Render of HTML contents. It is one of defined renderer types, or a rendering function. The defined renderer types are: -`shr': use Gnus simple HTML renderer; -`gnus-w3m' : use Gnus renderer based on w3m; -`w3m' : use emacs-w3m; -`w3m-standalone': use w3m; +`shr': use the built-in Gnus HTML renderer; +`gnus-w3m': use Gnus renderer based on w3m; +`w3m': use emacs-w3m; +`w3m-standalone': use plain w3m; `links': use links; -`lynx' : use lynx; -`w3' : use Emacs/W3; -`html2text' : use html2text; +`lynx': use lynx; +`w3': use Emacs/W3; +`html2text': use html2text; nil : use external viewer (default web browser)." :version "24.1" :type '(choice (const shr) diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el index 71b85183e0f..8099cc2a7cc 100644 --- a/lisp/gnus/nnir.el +++ b/lisp/gnus/nnir.el @@ -499,6 +499,31 @@ arrive at the correct group name, \"mail.misc\"." :type '(directory) :group 'nnir) +(defcustom nnir-notmuch-program "notmuch" + "*Name of notmuch search executable." + :type '(string) + :group 'nnir) + +(defcustom nnir-notmuch-additional-switches '() + "*A list of strings, to be given as additional arguments to notmuch. + +Note that this should be a list. Ie, do NOT use the following: + (setq nnir-notmuch-additional-switches \"-i -w\") ; wrong +Instead, use this: + (setq nnir-notmuch-additional-switches '(\"-i\" \"-w\"))" + :type '(repeat (string)) + :group 'nnir) + +(defcustom nnir-notmuch-remove-prefix (concat (getenv "HOME") "/Mail/") + "*The prefix to remove from each file name returned by notmuch +in order to get a group name (albeit with / instead of .). This is a +regular expression. + +This variable is very similar to `nnir-namazu-remove-prefix', except +that it is for notmuch, not Namazu." + :type '(regexp) + :group 'nnir) + ;;; Developer Extension Variable: (defvar nnir-engines @@ -519,6 +544,8 @@ arrive at the correct group name, \"mail.misc\"." ((group . "Swish-e Group spec: "))) (namazu nnir-run-namazu ()) + (notmuch nnir-run-notmuch + ()) (hyrex nnir-run-hyrex ((group . "Hyrex Group spec: "))) (find-grep nnir-run-find-grep @@ -1338,6 +1365,80 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." (> (nnir-artitem-rsv x) (nnir-artitem-rsv y))))))))) +(defun nnir-run-notmuch (query server &optional group) + "Run QUERY against notmuch. +Returns a vector of (group name, file name) pairs (also vectors, +actually)." + + ;; (when group + ;; (error "The notmuch backend cannot search specific groups")) + + (save-excursion + (let ( (qstring (cdr (assq 'query query))) + (groupspec (cdr (assq 'group query))) + (prefix (nnir-read-server-parm 'nnir-notmuch-remove-prefix server)) + artlist + (article-pattern (if (string= (gnus-group-server server) "nnmaildir") + ":[0-9]+" + "^[0-9]+$")) + artno dirnam filenam) + + (when (equal "" qstring) + (error "notmuch: You didn't enter anything")) + + (set-buffer (get-buffer-create nnir-tmp-buffer)) + (erase-buffer) + + (if groupspec + (message "Doing notmuch query %s on %s..." qstring groupspec) + (message "Doing notmuch query %s..." qstring)) + + (let* ((cp-list `( ,nnir-notmuch-program + nil ; input from /dev/null + t ; output + nil ; don't redisplay + "search" + "--format=text" + "--output=files" + ,@(nnir-read-server-parm 'nnir-notmuch-additional-switches server) + ,qstring ; the query, in notmuch format + )) + (exitstatus + (progn + (message "%s args: %s" nnir-notmuch-program + (mapconcat 'identity (cddddr cp-list) " ")) ;; ??? + (apply 'call-process cp-list)))) + (unless (or (null exitstatus) + (zerop exitstatus)) + (nnheader-report 'nnir "Couldn't run notmuch: %s" exitstatus) + ;; notmuch failure reason is in this buffer, show it if + ;; the user wants it. + (when (> gnus-verbose 6) + (display-buffer nnir-tmp-buffer)))) + + ;; The results are output in the format of: + ;; absolute-path-name + (goto-char (point-min)) + (while (not (eobp)) + (setq filenam (buffer-substring-no-properties (line-beginning-position) + (line-end-position)) + artno (file-name-nondirectory filenam) + dirnam (file-name-directory filenam)) + (forward-line 1) + + ;; don't match directories + (when (string-match article-pattern artno) + (when (not (null dirnam)) + + ;; maybe limit results to matching groups. + (when (or (not groupspec) + (string-match groupspec dirnam)) + (nnir-add-result dirnam artno "" prefix server artlist))))) + + (message "Massaging notmuch output...done") + + artlist))) + (defun nnir-run-find-grep (query server &optional grouplist) "Run find and grep to obtain matching articles." (let* ((method (gnus-server-to-method server)) diff --git a/lisp/gnus/pop3.el b/lisp/gnus/pop3.el index b485ac39f60..e29ddb0d44e 100644 --- a/lisp/gnus/pop3.el +++ b/lisp/gnus/pop3.el @@ -307,7 +307,7 @@ Returns the process associated with the connection." (or pop3-stream-type 'network))) :capability-command "CAPA\r\n" :end-of-command "^\\(-ERR\\|+OK \\).*\n" - :end-of-capability "^\\.\r?\n" + :end-of-capability "^\\.\r?\n\\|^-ERR" :success "^\\+OK.*\n" :return-list t :starttls-function -- 2.11.4.GIT