changeset 112193:700b890dcfb5

proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil. gnus-sum.el (gnus-summary-next-article): Remove hack to reselect group window, because it does the wrong thing when a separate frame displays the group buffer. gnus-int.el (gnus-request-accept-article): Don't try to update marks and stuff if the backend didn't return the article number. This fixes an Exchange-related nnimap bug. mm-decode.el (mm-preferred-alternative-precedence): Discourage showing empty parts. nnimap.el (nnimap-convert-partial-article): Protect against zero-length body parts.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 11 Jan 2011 23:32:50 +0000
parents 3dff252e42ea
children 978fe18f0882
files lisp/gnus/ChangeLog lisp/gnus/gnus-int.el lisp/gnus/gnus-sum.el lisp/gnus/mm-decode.el lisp/gnus/nnimap.el lisp/gnus/proto-stream.el
diffstat 6 files changed, 49 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/ChangeLog	Tue Jan 11 23:32:50 2011 +0000
@@ -1,3 +1,22 @@
+2011-01-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-convert-partial-article): Protect against
+	zero-length body parts.
+
+	* mm-decode.el (mm-preferred-alternative-precedence): Discourage
+	showing empty parts.
+
+	* gnus-int.el (gnus-request-accept-article): Don't try to update marks
+	and stuff if the backend didn't return the article number.  This fixes
+	an Exchange-related nnimap bug.
+
+	* gnus-sum.el (gnus-summary-next-article): Remove hack to reselect
+	group window, because it does the wrong thing when a separate frame
+	displays the group buffer.
+
+	* proto-stream.el (open-protocol-stream): Protect against the low-level
+	transport functions returning nil.
+
 2011-01-07  Daiki Ueno  <ueno@unixuser.org>
 
 	* mml2015.el (epg-sub-key-fingerprint): Autoload.
--- a/lisp/gnus/gnus-int.el	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/gnus-int.el	Tue Jan 11 23:32:50 2011 +0000
@@ -1,7 +1,7 @@
 ;;; gnus-int.el --- backend interface functions for Gnus
 
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -711,7 +711,9 @@
 	  (if (stringp group) (gnus-group-real-name group) group)
 	  (cadr gnus-command-method)
 	  last)))
-    (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
+    (when (and gnus-agent
+	       (gnus-agent-method-p gnus-command-method)
+	       (cdr result))
       (gnus-agent-regenerate-group group (list (cdr result))))
     result))
 
--- a/lisp/gnus/gnus-sum.el	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/gnus-sum.el	Tue Jan 11 23:32:50 2011 +0000
@@ -7687,9 +7687,6 @@
 	   (if (eq gnus-keep-same-level 'best)
 	       (gnus-summary-best-group gnus-newsgroup-name)
 	     (gnus-summary-search-group backward gnus-keep-same-level))))
-      ;; For some reason, the group window gets selected.  We change
-      ;; it back.
-      (select-window (get-buffer-window (current-buffer)))
       ;; Select next unread newsgroup automagically.
       (cond
        ((or (not gnus-auto-select-next)
--- a/lisp/gnus/mm-decode.el	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/mm-decode.el	Tue Jan 11 23:32:50 2011 +0000
@@ -1,7 +1,7 @@
 ;;; mm-decode.el --- Functions for decoding MIME things
 
 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;;   2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;	MORIOKA Tomohiko <morioka@jaist.ac.jp>
@@ -1367,13 +1367,18 @@
 
 (defun mm-preferred-alternative-precedence (handles)
   "Return the precedence based on HANDLES and `mm-discouraged-alternatives'."
-  (let ((seq (nreverse (mapcar #'mm-handle-media-type
-			       handles))))
-    (dolist (disc (reverse mm-discouraged-alternatives))
-      (dolist (elem (copy-sequence seq))
-	(when (string-match disc elem)
-	  (setq seq (nconc (delete elem seq) (list elem))))))
-    seq))
+  (setq handles (reverse handles))
+  (dolist (disc (reverse mm-discouraged-alternatives))
+    (dolist (handle (copy-sequence handles))
+      (when (string-match disc (mm-handle-media-type handle))
+	(setq handles (nconc (delete handle handles) (list handle))))))
+  ;; Remove empty parts.
+  (dolist (handle (copy-sequence handles))
+    (unless (with-current-buffer (mm-handle-buffer handle)
+	      (goto-char (point-min))
+	      (re-search-forward "[^ \t\n]" nil t))
+      (setq handles (nconc (delete handle handles) (list handle)))))
+  (mapcar #'mm-handle-media-type handles))
 
 (defun mm-get-content-id (id)
   "Return the handle(s) referred to by ID."
--- a/lisp/gnus/nnimap.el	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/nnimap.el	Tue Jan 11 23:32:50 2011 +0000
@@ -582,7 +582,7 @@
     ;; Collect all the body parts.
     (while (looking-at ".*BODY\\[\\([.0-9]+\\)\\]")
       (setq id (match-string 1)
-	    bytes (nnimap-get-length))
+	    bytes (or (nnimap-get-length) 0))
       (beginning-of-line)
       (delete-region (point) (progn (forward-line 1) (point)))
       (push (list id (buffer-substring (point) (+ (point) bytes)))
--- a/lisp/gnus/proto-stream.el	Tue Jan 11 21:14:13 2011 +0100
+++ b/lisp/gnus/proto-stream.el	Tue Jan 11 23:32:50 2011 +0000
@@ -1,6 +1,6 @@
 ;;; proto-stream.el --- negotiating TLS, STARTTLS and other connections
 
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: network
@@ -101,14 +101,17 @@
       (setq type 'network))
      ((eq type 'ssl)
       (setq type 'tls)))
-    (destructuring-bind (stream greeting capabilities)
-	(funcall (intern (format "proto-stream-open-%s" type) obarray)
-		 name buffer host service parameters)
-      (list (and stream
-		 (memq (process-status stream)
-		       '(open run))
-		 stream)
-	    greeting capabilities))))
+    (let ((open-result
+	   (funcall (intern (format "proto-stream-open-%s" type) obarray)
+		    name buffer host service parameters)))
+      (if (null open-result)
+	  (list nil nil nil)
+	(destructuring-bind (stream greeting capabilities) open-result
+	  (list (and stream
+		     (memq (process-status stream)
+			   '(open run))
+		     stream)
+		greeting capabilities))))))
 
 (defun proto-stream-open-network-only (name buffer host service parameters)
   (let ((start (with-current-buffer buffer (point)))