changeset 111986:faa4a1c986c6

Merge changes made in Gnus trunk. nnimap.el (nnimap-wait-for-response): Always look (at least) at the previous line. nnimap.el (nnimap-quirk): New function. (nnimap-retrieve-group-data-early): Use it. (nnimap-quirks): New alist. gnus.texi (Foreign Groups): Added clarification of foreign groups. gnus-sum.el (gnus-summary-push-marks-to-backend): Fix the logic for copying read-ness to the backends. gnus-group.el (gnus-group-kill-group): Notify the backend that the group has been killed. (gnus-group-yank-group): Ditto. gnus-start.el (gnus-subscribe-newsgroup): Notify the backend. nnir.el: Improve customizations. gnus.texi (Archived Messages): Removed outdated comment and text. nnfolder.el (nnfolder-save-all-buffers): Refactor out into its own function. (nnfolder-request-expire-articles): Save all the buffers after doing expiry. nnmail.el (nnmail-expiry-target-group): Revert the "all articles are the last article", since that led to serious performance regressions when expiring nnml groups. gnus-html.el (gnus-html-schedule-image-fetching): Make sure the HTML fetching stops when Gnus exits. gnus-srvr.el: Avoid passing nil regexp argument to delete-matching-lines. auth-source.el (auth-source-gpg-encrypt-to): New variable to set the list of recipient keys, or use symmetric encryption if not a list. (auth-source-create): Use it to make `epa-file-encrypt-to' local for an EPA override, replacing the call to `netrc-store-data'.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 16 Dec 2010 22:22:28 +0000
parents b8b55da43e95
children bf3ad2811a81
files doc/misc/ChangeLog doc/misc/gnus.texi lisp/gnus/ChangeLog lisp/gnus/auth-source.el lisp/gnus/gnus-group.el lisp/gnus/gnus-html.el lisp/gnus/gnus-int.el lisp/gnus/gnus-srvr.el lisp/gnus/gnus-start.el lisp/gnus/gnus-sum.el lisp/gnus/nnfolder.el lisp/gnus/nnimap.el lisp/gnus/nnir.el lisp/gnus/nnmail.el
diffstat 14 files changed, 189 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Thu Dec 16 20:37:13 2010 +0100
+++ b/doc/misc/ChangeLog	Thu Dec 16 22:22:28 2010 +0000
@@ -1,3 +1,11 @@
+2010-12-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (Archived Messages): Remove outdated text.
+
+2010-12-16  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* gnus.texi (Foreign Groups): Added clarification of foreign groups.
+
 2010-12-15  Andrew Cohen  <cohen@andy.bu.edu>
 
 	* gnus.texi (The hyrex Engine): Say that this engine as obsolete.
--- a/doc/misc/gnus.texi	Thu Dec 16 20:37:13 2010 +0100
+++ b/doc/misc/gnus.texi	Thu Dec 16 22:22:28 2010 +0000
@@ -2512,6 +2512,15 @@
 @section Foreign Groups
 @cindex foreign groups
 
+If you recall how to subscribe to servers (@pxref{Finding the News})
+you will remember that @code{gnus-secondary-select-methods} and
+@code{gnus-select-method} let you write a definition in Emacs Lisp of
+what servers you want to see when you start up.  The alternate
+approach is to use foreign servers and groups.  ``Foreign'' here means
+they are not coming from the select methods.  All foreign server
+configuration and subscriptions are stored only in the
+@file{~/.newsrc.eld} file.
+
 Below are some group mode commands for making and editing general foreign
 groups, as well as commands to ease the creation of a few
 special-purpose groups.  All these commands insert the newly created
@@ -12611,9 +12620,6 @@
           (concat "mail." (format-time-string "%Y-%m")))))
 @end lisp
 
-@c (XEmacs 19.13 doesn't have @code{format-time-string}, so you'll have to
-@c use a different value for @code{gnus-message-archive-group} there.)
-
 Now, when you send a message off, it will be stored in the appropriate
 group.  (If you want to disable storing for just one particular message,
 you can just remove the @code{Gcc} header that has been inserted.)  The
@@ -12625,11 +12631,6 @@
 nice---@samp{misc-mail-september-1995}, or whatever.  New messages will
 continue to be stored in the old (now empty) group.
 
-That's the default method of archiving sent messages.  Gnus offers a
-different way for the people who don't like the default method.  In that
-case you should set @code{gnus-message-archive-group} to @code{nil};
-this will disable archiving.
-
 @table @code
 @item gnus-gcc-mark-as-read
 @vindex gnus-gcc-mark-as-read
--- a/lisp/gnus/ChangeLog	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/ChangeLog	Thu Dec 16 22:22:28 2010 +0000
@@ -1,8 +1,65 @@
+2010-12-16  Daiki Ueno  <ueno@unixuser.org>
+
+	* auth-source.el (auth-source-gpg-encrypt-to): New variable to set the
+	list of recipient keys, or use symmetric encryption if not a list.
+	(auth-source-create): Use it to make `epa-file-encrypt-to' local for an
+	EPA override, replacing the call to `netrc-store-data'.
+
+2010-12-16  Dan Davison  <dandavison7@gmail.com>  (tiny change)
+
+	* gnus-srvr.el: Avoid passing nil regexp argument to
+	delete-matching-lines.
+
+2010-12-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-html.el (gnus-html-schedule-image-fetching): Make sure the HTML
+	fetching stops when Gnus exits.
+
+	* nnfolder.el (nnfolder-save-all-buffers): Refactor out into its own
+	function.
+	(nnfolder-request-expire-articles): Save all the buffers after doing
+	expiry.
+
+	* nnmail.el (nnmail-expiry-target-group): Revert the "all articles are
+	the last article", since that led to serious performance regressions
+	when expiring nnml groups.
+
+2010-12-16  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el: Improve customizations.
+
+2010-12-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-start.el (gnus-subscribe-newsgroup): Notify the backend.
+
+	* gnus-group.el (gnus-group-kill-group): Notify the backend that the
+	group has been killed.
+	(gnus-group-yank-group): Ditto.
+
+	* gnus-srvr.el (gnus-browse-unsubscribe-group): Ditto.
+
+	* nnimap.el (nnimap-request-update-group-status): New function.
+
+	* gnus-int.el (gnus-request-update-group-status): New interface
+	function.
+
+	* gnus-sum.el (gnus-summary-push-marks-to-backend): Fix the logic for
+	copying read-ness to the backends.
+
+	* nnimap.el (nnimap-quirk): New function.
+	(nnimap-retrieve-group-data-early): Use it.
+	(nnimap-quirks): New alist.
+
 2010-12-16  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* shr.el (shr-insert): Set shr-start after deleting trailing space;
 	don't delete it within indentation.
 
+2010-12-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-wait-for-response): Always look (at least) at the
+	previous line.
+
 2010-12-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* nnimap.el (nnimap-retrieve-group-data-early): Fix the syntax of the
--- a/lisp/gnus/auth-source.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/auth-source.el	Thu Dec 16 22:22:28 2010 +0000
@@ -159,6 +159,15 @@
                                                      (const :tag "Any" t)
                                                      (string :tag "Specific user name"))))))))
 
+(defcustom auth-source-gpg-encrypt-to t
+  "List of recipient keys that `authinfo.gpg' encrypted to.
+If the value is not a list, symmetric encryption will be used."
+  :group 'auth-source
+  :version "23.2" ;; No Gnus
+  :type '(choice (const :tag "Symmetric encryption" t)
+		 (repeat :tag "Recipient public keys"
+			 (string :tag "Recipient public key"))))
+
 ;; temp for debugging
 ;; (unintern 'auth-source-protocols)
 ;; (unintern 'auth-sources)
@@ -352,9 +361,28 @@
       ;; netrc interface.
       (when (y-or-n-p (format "Do you want to save this password in %s? "
                               source))
-        (netrc-store-data source host prot
-                          (or user (cdr (assoc "login" result)))
-                          (cdr (assoc "password" result))))))
+	;; the code below is almost same as `netrc-store-data' except
+	;; the `epa-file-encrypt-to' hack (see bug#7487).
+	(with-temp-buffer
+	  (when (file-exists-p source)
+	    (insert-file-contents source))
+	  (when auth-source-gpg-encrypt-to
+	    ;; making `epa-file-encrypt-to' local to this buffer lets
+	    ;; epa-file skip the key selection query (see the
+	    ;; `local-variable-p' check in `epa-file-write-region').
+	    (unless (local-variable-p 'epa-file-encrypt-to)
+	      (make-local-variable 'epa-file-encrypt-to))
+	    (if (listp auth-source-gpg-encrypt-to)
+		(setq epa-file-encrypt-to auth-source-gpg-encrypt-to)))
+	  (goto-char (point-max))
+	  (unless (bolp)
+	    (insert "\n"))
+	  (insert (format "machine %s login %s password %s port %s\n"
+			  host
+			  (or user (cdr (assoc "login" result)))
+			  (cdr (assoc "password" result))
+			  prot))
+	  (write-region (point-min) (point-max) source nil 'silent)))))
     (if (consp mode)
         (mapcar #'cdr result)
       (cdar result))))
--- a/lisp/gnus/gnus-group.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-group.el	Thu Dec 16 22:22:28 2010 +0000
@@ -3781,6 +3781,7 @@
 		  gnus-list-of-killed-groups))
 	  (gnus-group-change-level
 	   (if entry entry group) gnus-level-killed (if entry nil level))
+	  (gnus-request-update-group-status group 'unsubscribe)
 	  (message "Killed group %s" (gnus-group-decoded-name group)))
       ;; If there are lots and lots of groups to be killed, we use
       ;; this thing instead.
@@ -3803,7 +3804,8 @@
 	  (setq gnus-zombie-list (delete group gnus-zombie-list))))
 	;; There may be more than one instance displayed.
 	(while (gnus-group-goto-group group)
-	  (gnus-delete-line)))
+	  (gnus-delete-line))
+	(gnus-request-update-group-status group 'unsubscribe))
       (gnus-make-hashtable-from-newsrc-alist))
 
     (gnus-group-position-point)
@@ -3831,6 +3833,7 @@
        (and prev (gnus-group-entry prev))
        t)
       (gnus-group-insert-group-line-info group)
+      (gnus-request-update-group-status group 'subscribe)
       (gnus-undo-register
 	`(when (gnus-group-goto-group ,group)
 	   (gnus-group-kill-group 1))))
--- a/lisp/gnus/gnus-html.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-html.el	Thu Dec 16 22:22:28 2010 +0000
@@ -395,7 +395,7 @@
 	     4)
       (setq args (nconc args (list t))))
     (ignore-errors
-      (apply #'url-retrieve args))))
+      (push (apply #'url-retrieve args) gnus-buffers))))
 
 (defun gnus-html-image-fetched (status buffer image)
   "Callback function called when image has been fetched."
--- a/lisp/gnus/gnus-int.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-int.el	Thu Dec 16 22:22:28 2010 +0000
@@ -473,6 +473,18 @@
       (funcall (gnus-get-function gnus-command-method 'request-type)
 	       (gnus-group-real-name group) article))))
 
+(defun gnus-request-update-group-status (group status)
+  "Change the status of a group.
+Valid statuses include `subscribe' and `unsubscribe'."
+  (let ((gnus-command-method (gnus-find-method-for-group group)))
+    (if (not (gnus-check-backend-function
+	      'request-update-group-status (car gnus-command-method)))
+	nil
+      (funcall
+       (gnus-get-function gnus-command-method 'request-update-group-status)
+       (gnus-group-real-name group) status
+       (nth 1 gnus-command-method)))))
+
 (defun gnus-request-set-mark (group action)
   "Set marks on articles in the back end."
   (let ((gnus-command-method (gnus-find-method-for-group group)))
--- a/lisp/gnus/gnus-srvr.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-srvr.el	Thu Dec 16 22:22:28 2010 +0000
@@ -766,7 +766,8 @@
       (with-current-buffer nntp-server-buffer
 	(let ((cur (current-buffer)))
 	  (goto-char (point-min))
-	  (unless (string= gnus-ignored-newsgroups "")
+         (unless (or (null gnus-ignored-newsgroups)
+                     (string= gnus-ignored-newsgroups ""))
 	    (delete-matching-lines gnus-ignored-newsgroups))
 	  ;; We treat NNTP as a special case to avoid problems with
 	  ;; garbage group names like `"foo' that appear in some badly
@@ -992,7 +993,8 @@
 		;; mechanism for new group subscription.
 		(gnus-call-subscribe-functions
 		 gnus-browse-subscribe-newsgroup-method
-		 group)))
+		 group)
+		(gnus-request-update-group-status group 'subscribe)))
 	    (delete-char 1)
 	    (insert (let ((lvl (gnus-group-level group)))
 		      (cond
--- a/lisp/gnus/gnus-start.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-start.el	Thu Dec 16 22:22:28 2010 +0000
@@ -645,6 +645,7 @@
     (gnus-group-change-level
      newsgroup gnus-level-default-subscribed
      gnus-level-killed (gnus-group-entry (or next "dummy.group")))
+    (gnus-request-update-group-status newsgroup 'subscribe)
     (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
     (run-hook-with-args 'gnus-subscribe-newsgroup-hooks newsgroup)
     t))
--- a/lisp/gnus/gnus-sum.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/gnus-sum.el	Thu Dec 16 22:22:28 2010 +0000
@@ -9958,7 +9958,7 @@
 (defun gnus-summary-push-marks-to-backend (article)
   (let ((set nil)
 	(marks gnus-article-mark-lists))
-    (when (memq article gnus-newsgroup-unreads)
+    (unless (memq article gnus-newsgroup-unreads)
       (push 'read set))
     (while marks
       (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
--- a/lisp/gnus/nnfolder.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/nnfolder.el	Thu Dec 16 22:22:28 2010 +0000
@@ -322,20 +322,20 @@
   (when nnfolder-get-new-mail
     (nnfolder-possibly-change-group group server)
     (nnmail-get-new-mail
-     'nnfolder
-     (lambda ()
-       (let ((bufs nnfolder-buffer-alist))
-	 (save-excursion
-	   (while bufs
-	     (if (not (gnus-buffer-live-p (nth 1 (car bufs))))
-		 (setq nnfolder-buffer-alist
-		       (delq (car bufs) nnfolder-buffer-alist))
-	       (set-buffer (nth 1 (car bufs)))
-	       (nnfolder-save-buffer)
-	       (kill-buffer (current-buffer)))
-	     (setq bufs (cdr bufs))))))
-     nnfolder-directory
-     group)))
+     'nnfolder 'nnfolder-save-all-buffers
+     nnfolder-directory group)))
+
+(defun nnfolder-save-all-buffers ()
+  (let ((bufs nnfolder-buffer-alist))
+    (save-excursion
+      (while bufs
+	(if (not (gnus-buffer-live-p (nth 1 (car bufs))))
+	    (setq nnfolder-buffer-alist
+		  (delq (car bufs) nnfolder-buffer-alist))
+	  (set-buffer (nth 1 (car bufs)))
+	  (nnfolder-save-buffer)
+	  (kill-buffer (current-buffer)))
+	(setq bufs (cdr bufs))))))
 
 ;; Don't close the buffer if we're not shutting down the server.  This way,
 ;; we can keep the buffer in the group buffer cache, and not have to grovel
@@ -488,7 +488,8 @@
       (nnfolder-save-buffer)
       (nnfolder-adjust-min-active newsgroup)
       (nnfolder-save-active nnfolder-group-alist nnfolder-active-file)
-      (gnus-sorted-difference articles (nreverse deleted-articles)))))
+      (gnus-sorted-difference articles (nreverse deleted-articles)))
+    (nnfolder-save-all-buffers)))
 
 (deffoo nnfolder-request-move-article (article group server accept-form
 					       &optional last move-is-internal)
--- a/lisp/gnus/nnimap.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/nnimap.el	Thu Dec 16 22:22:28 2010 +0000
@@ -139,6 +139,9 @@
     (download "gnus-download")
     (forward "gnus-forward")))
 
+(defvar nnimap-quirks
+  '(("QRESYNC" "Zimbra" "QRESYNC ")))
+
 (defun nnimap-buffer ()
   (nnimap-find-process-buffer nntp-server-buffer))
 
@@ -897,6 +900,16 @@
 	(push flag flags)))
     flags))
 
+(deffoo nnimap-request-update-group-status (group status &optional server)
+  (when (nnimap-possibly-change-group nil server)
+    (let ((command (assoc
+		    status
+		    '((subscribe "SUBSCRIBE")
+		      (unsubscribe "UNSUBSCRIBE")))))
+      (when command
+	(with-current-buffer (nnimap-buffer)
+	  (nnimap-command "%s %S" (cadr command) (utf7-encode group t)))))))
+
 (deffoo nnimap-request-set-mark (group actions &optional server)
   (when (nnimap-possibly-change-group group server)
     (let (sequence)
@@ -1080,8 +1093,9 @@
 		   uidvalidity
 		   modseq)
 	      (push
-	       (list (nnimap-send-command "EXAMINE %S (QRESYNC (%s %s))"
+	       (list (nnimap-send-command "EXAMINE %S (%s (%s %s))"
 					  (utf7-encode group t)
+					  (nnimap-quirk "QRESYNC")
 					  uidvalidity modseq)
 		     'qresync
 		     nil group 'qresync)
@@ -1107,6 +1121,15 @@
 		    sequences))))
 	sequences))))
 
+(defun nnimap-quirk (command)
+  (let ((quirk (assoc command nnimap-quirks)))
+    ;; If this server is of a type that matches a quirk, then return
+    ;; the "quirked" command instead of the proper one.
+    (if (or (null quirk)
+	    (not (string-match (nth 1 quirk) (nnimap-greeting nnimap-object))))
+	command
+      (nth 2 quirk))))
+
 (deffoo nnimap-finish-retrieve-group-infos (server infos sequences)
   (when (and sequences
 	     (nnimap-possibly-change-group nil server))
@@ -1541,7 +1564,11 @@
 		      (not (re-search-backward
 			    (format "^%d .*\n" sequence)
 			    (if nnimap-streaming
-				(max (point-min) (- (point) 500))
+				(max (point-min)
+				     (- (point) 500)
+				     (save-excursion
+				       (forward-line -1)
+				       (point)))
 			      (point-min))
 			    t)))
 	    (when messagep
--- a/lisp/gnus/nnir.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/nnir.el	Thu Dec 16 22:22:28 2010 +0000
@@ -305,13 +305,6 @@
   "Search groups in Gnus with assorted seach engines."
   :group 'gnus)
 
-(defcustom nnir-method-default-engines
-  '((nnimap . imap)
-    (nntp . gmane))
-  "*Alist of default search engines keyed by server method."
-  :type '(alist)
-  :group 'nnir)
-
 (defcustom nnir-ignored-newsgroups ""
   "*A regexp to match newsgroups in the active file that should
   be skipped when searching."
@@ -329,7 +322,7 @@
 %g    Article original short group name (string)
 
 If nil this will use `gnus-summary-line-format'."
-  :type '(regexp)
+  :type '(string)
   :group 'nnir)
 
 (defcustom nnir-retrieve-headers-override-function nil
@@ -347,7 +340,8 @@
   "*The default IMAP search key for an nnir search. Must be one of
   the keys in `nnir-imap-search-arguments'. To use raw imap queries
   by default set this to \"Imap\"."
-  :type '(string)
+  :type `(choice ,@(mapcar (lambda (elem) (list 'const (car elem)))
+			   nnir-imap-search-arguments))
   :group 'nnir)
 
 (defcustom nnir-swish++-configuration-file
@@ -546,6 +540,18 @@
 
 Add an entry here when adding a new search engine.")
 
+(defcustom nnir-method-default-engines
+  '((nnimap . imap)
+    (nntp . gmane))
+  "*Alist of default search engines keyed by server method."
+  :type `(repeat (cons (choice (const nnimap) (const nttp) (const nnspool)
+			       (const nneething) (const nndir) (const nnmbox)
+			       (const nnml) (const nnmh) (const nndraft)
+			       (const nnfolder) (const nnmaildir))
+		       (choice
+			,@(mapcar (lambda (elem) (list 'const (car elem)))
+				  nnir-engines))))
+  :group 'nnir)
 
 ;; Gnus glue.
 
--- a/lisp/gnus/nnmail.el	Thu Dec 16 20:37:13 2010 +0100
+++ b/lisp/gnus/nnmail.el	Thu Dec 16 22:22:28 2010 +0000
@@ -1915,7 +1915,7 @@
     (unless (eq target 'delete)
       (when (or (gnus-request-group target)
 		(gnus-request-create-group target))
-	(let ((group-art (gnus-request-accept-article target nil t t)))
+	(let ((group-art (gnus-request-accept-article target nil nil t)))
 	  (when (and (consp group-art)
 		     (cdr group-art))
 	    (gnus-group-mark-article-read target (cdr group-art))))))))