From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68173 Path: news.gmane.org!not-for-mail From: Dave Love Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: IMAP and Exchange 2007 - imap-fetch-safe Date: Sat, 17 Jan 2009 20:58:01 +0000 Message-ID: <871vv1d50m.fsf@liv.ac.uk> References: <87iqphil5p.fsf@liv.ac.uk> <87ocz3n8d4.fsf@marauder.physik.uni-ulm.de> <87iqpa99wy.fsf@liv.ac.uk> <87wsde7t5j.fsf_-_@marauder.physik.uni-ulm.de> <86mye95p27.fsf@lifelogs.com> <878wpt48qj.fsf@marauder.physik.uni-ulm.de> <86d4eyvryx.fsf@lifelogs.com> <878wplcxws.fsf@marauder.physik.uni-ulm.de> <87k58za3q8.fsf@liv.ac.uk> <87k58zm99o.fsf_-_@marauder.physik.uni-ulm.de> <87fxjn9l7g.fsf@mocca.josefsson.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FBI-afsatcom-Aldergrove-ANDVT-Legion-of-Doom" X-Trace: ger.gmane.org 1232225834 2392 80.91.229.12 (17 Jan 2009 20:57:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Jan 2009 20:57:14 +0000 (UTC) Cc: Bjorn Solberg , "emacs-devel@gnu.org" To: "ding\@gnus.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 17 21:58:25 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LOIFM-00051A-O6 for ged-emacs-devel@m.gmane.org; Sat, 17 Jan 2009 21:58:25 +0100 Original-Received: from localhost ([127.0.0.1]:45901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOIE5-00052q-IO for ged-emacs-devel@m.gmane.org; Sat, 17 Jan 2009 15:57:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOIE1-00052C-UU for emacs-devel@gnu.org; Sat, 17 Jan 2009 15:57:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOIE0-000520-Cd for emacs-devel@gnu.org; Sat, 17 Jan 2009 15:57:00 -0500 Original-Received: from [199.232.76.173] (port=54695 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOIE0-00051x-60 for emacs-devel@gnu.org; Sat, 17 Jan 2009 15:57:00 -0500 Original-Received: from mxa.liv.ac.uk ([138.253.100.59]:54813) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LOIDz-0003Se-Kv for emacs-devel@gnu.org; Sat, 17 Jan 2009 15:56:59 -0500 Original-Received: from mailhubb.liv.ac.uk ([138.253.100.37]) by mxa.liv.ac.uk with esmtp (Exim 4.67) (envelope-from ) id 1LOIDy-0003vj-0N for emacs-devel@gnu.org; Sat, 17 Jan 2009 20:56:58 +0000 Original-Received: from localhost ([127.0.0.1] helo=mailhubb.liv.ac.uk) by mailhubb.liv.ac.uk with esmtp (Exim 4.67) (envelope-from ) id 1LOIDx-00023x-Up; Sat, 17 Jan 2009 20:56:57 +0000 Original-Received: from pc102091.liv.ac.uk ([138.253.102.91] helo=albion) by mailhubb.liv.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1LOIDx-00023u-OV; Sat, 17 Jan 2009 20:56:57 +0000 Original-Received: from dlove by albion with local (Exim 4.69) (envelope-from ) id 1LOIEz-0007KX-Qe; Sat, 17 Jan 2009 20:58:01 +0000 X-Draft-From: ("nnimap+imap.liv.ac.uk:Misc" 3439) In-Reply-To: <87fxjn9l7g.fsf@mocca.josefsson.org> (Simon Josefsson's message of "Tue, 13 Jan 2009 17:20:35 +0000") User-Agent: Gnus/5.110011 (No Gnus v0.11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:107941 gmane.emacs.gnus.general:68173 Archived-At: --FBI-afsatcom-Aldergrove-ANDVT-Legion-of-Doom Simon Josefsson writes: > Maybe the problem is a condition-case within another condition-case > work? I recall problems related to this when run as an async process > filter. Yes -- signals from process filters are normally caught; I wasn't thinking or looking closely enough at what the code does originally. I must have had debug-on-error set when testing, but I was sure I'd actually tried it in fresh Emacs. > Maybe it is possible to re-write the approach without using > condition-case, that would likely be easier to debug anyway. I'm not sure it would be easier, but see the comment in the patch below. I made it before reading this, and at least the fix over my previous code is just an extra binding. It works for me in a fresh Emacs, and isn't broken in Emacs 22. > I'd prefer to avoid sending the Exchange bug-workaround approach > ("1,*:*") to any server that does not need it. I've seen servers that > (internally) open up all e-mails in the folder and searches them, but > for the 1,* approach was able to return data quickly. Obviously that's a good reason. Previous comments about efficiency that I was referred to seemed to be about something different. > This may be old > information now, but generally I don't see why imap.el should send poor > protocol output to all servers just because Exchange is broken. [It does have workarounds for various other servers, not that I want to defend Exchange in any way. Exchange 2007 is doing horrible things like messing with MIME parts, which I don't think the previous version did, and I wish I could avoid it.] Anyhow, per the comment in the patch, is there a good reason -- other than simplicity? -- to use FETCH rather than UID like other clients? I'm speaking mostly in ignorance of IMAP... --FBI-afsatcom-Aldergrove-ANDVT-Legion-of-Doom Content-Type: text/x-patch Content-Disposition: inline 2009-01-17 Dave Love * imap.el (imap-fetch-safe): Bind debug-on-error. (imap-debug): Add imap-fetch-safe. Index: imap.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/imap.el,v retrieving revision 7.52 diff -u -r7.52 imap.el --- imap.el 8 Jan 2009 20:51:29 -0000 7.52 +++ imap.el 17 Jan 2009 19:33:31 -0000 @@ -1798,25 +1800,38 @@ of the UIDS specification, and the cdr is the one which works with Exchange 2007 or, potentially, other buggy servers. See `imap-enable-exchange-bug-workaround'." - ;; We don't unconditionally use the alternative (valid) form, since - ;; this is said to be significantly inefficient. The first time we - ;; get here for a given, we'll try the canonical form. If we get - ;; the known error from the buggy server, set the flag - ;; buffer-locally (to account for connections to multiple servers), - ;; then re-try with the alternative UIDS spec. + ;; The first time we get here for a given, we'll try the canonical + ;; form. If we get the known error from the buggy server, set the + ;; flag buffer-locally (to account for connections to multiple + ;; servers), then re-try with the alternative UIDS spec. We don't + ;; unconditionally use the alternative form, since the + ;; currently-used alternatives are seriously inefficient with some + ;; servers (although they are valid). + ;; + ;; FIXME: Maybe it would be cleaner to have a flag to not signal + ;; the error (which otherwise gives a message), and test + ;; `imap-failed-tags'. Also, Other IMAP clients use other forms of + ;; request which work with Exchange, e.g. Claws does "UID FETCH 1:* + ;; (UID)" rather than "FETCH UID 1,*". Is there a good reason not + ;; to do the same? (condition-case data - (imap-fetch (if imap-enable-exchange-bug-workaround - (cdr uids) - (car uids)) - props receive nouidfetch buffer) + ;; Binding `debug-on-error' allows us to get the error from + ;; `imap-parse-response' -- it's normally caught by Emacs around + ;; execution of a process filter. + (let ((debug-on-error t)) + (imap-fetch (if imap-enable-exchange-bug-workaround + (cdr uids) + (car uids)) + props receive nouidfetch buffer)) (error (if (and (not imap-enable-exchange-bug-workaround) - (string-match - "The specified message set is invalid" - (cadr data))) + ;; This is the Exchange 2007 response. It may be more + ;; robust just to check for a BAD response to the + ;; attempted fetch. + (string-match "The specified message set is invalid" + (cadr data))) (with-current-buffer (or buffer (current-buffer)) - (set (make-local-variable - 'imap-enable-exchange-bug-workaround) + (set (make-local-variable 'imap-enable-exchange-bug-workaround) t) (imap-fetch (cdr uids) props receive nouidfetch)) (signal (car data) (cdr data)))))) @@ -3023,6 +3038,7 @@ imap-list-to-message-set imap-fetch-asynch imap-fetch + imap-fetch-safe imap-message-put imap-message-get imap-message-map --FBI-afsatcom-Aldergrove-ANDVT-Legion-of-Doom--