Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <reinersteib+gmane@imap.cc>
To: Mat Marcus <mat-lists@emarcus.org>
Cc: Vitaly Mayatskikh <v.mayatskih@gmail.com>, ding@gnus.org
Subject: Re: gnus IMAP vs. Exchange Server 2007
Date: Wed, 24 Sep 2008 20:27:49 +0200	[thread overview]
Message-ID: <874p45qtzu.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <9206c7e10809241007t13f92263lb4946826a852560f@mail.gmail.com> (Mat Marcus's message of "Wed, 24 Sep 2008 10:07:09 -0700")

On Wed, Sep 24 2008, Mat Marcus wrote:

> Vitaly Mayatskikh <v.mayatskih@gmail.com> wrote:
>> Mat Marcus <mat-lists@emarcus.org> writes:
[...]
>>> 3) in either case is there a patch workaround for gnus? I am
>>> currently running gnus "5.11" that comes with emacs 22.1.1.
[...]
>> (setq imap-enable-exchange-bug-workaround t)
>>
>> "Documentation:
>> Send FETCH UID commands as *:* instead of *.
>> Enabling this appears to be required for some servers (e.g.,
>> Microsoft Exchange) which otherwise would trigger a response 'BAD
>> The specified message set is invalid.'."
>
> Thanks for the reply. This variable is just what I need. C-h v
> indicates that it is not present in the version of gnus that I have
> (see 3, above). Do I just grab an arbitrary nightly snapshot  and
> replace my lisp/gnus folder? 

No.

There are some options:

- install the current development version (No Gnus) completely as
  described in the top-level README.

- Insert this code (e.g. in ~/.gnus.el)
  *before* setting `imap-enable-exchange-bug-workaround':

--8<---------------cut here---------------start------------->8---
;; Workaround.  Don't use with Gnus 5.12 or later.

(require 'imap)
(unless (boundp 'imap-enable-exchange-bug-workaround)

  (defvar imap-enable-exchange-bug-workaround nil
    "Send FETCH UID commands as *:* instead of *.
Enabling this appears to be required for some servers (e.g.,
Microsoft Exchange) which otherwise would trigger a response 'BAD
The specified message set is invalid.'.

BACKPORT from No Gnus!")

  (defun imap-message-copyuid-1 (mailbox)
    (if (imap-capability 'UIDPLUS)
	(list (nth 0 (imap-mailbox-get-1 'copyuid mailbox))
	      (string-to-number (nth 2 (imap-mailbox-get-1 'copyuid mailbox))))
      (let ((old-mailbox imap-current-mailbox)
	    (state imap-state)
	    (imap-message-data (make-vector 2 0)))
	(when (imap-mailbox-examine-1 mailbox)
	  (prog1
	      (and (imap-fetch
		    (if imap-enable-exchange-bug-workaround "*:*" "*") "UID")
		   (list (imap-mailbox-get-1 'uidvalidity mailbox)
			 (apply 'max (imap-message-map
				      (lambda (uid prop) uid) 'UID))))
	    (if old-mailbox
		(imap-mailbox-select old-mailbox (eq state 'examine))
	      (imap-mailbox-unselect)))))))

  (defun imap-message-appenduid-1 (mailbox)
    (if (imap-capability 'UIDPLUS)
	(imap-mailbox-get-1 'appenduid mailbox)
      (let ((old-mailbox imap-current-mailbox)
	    (state imap-state)
	    (imap-message-data (make-vector 2 0)))
	(when (imap-mailbox-examine-1 mailbox)
	  (prog1
	      (and (imap-fetch
		    (if imap-enable-exchange-bug-workaround "*:*" "*") "UID")
		   (list (imap-mailbox-get-1 'uidvalidity mailbox)
			 (apply 'max (imap-message-map
				      (lambda (uid prop) uid) 'UID))))
	    (if old-mailbox
		(imap-mailbox-select old-mailbox (eq state 'examine))
	      (imap-mailbox-unselect)))))))

  (message "Workaround `imap-enable-exchange-bug-workaround' added."))

(setq imap-enable-exchange-bug-workaround t)

--8<---------------cut here---------------end--------------->8---

- install the following patch (and recompile imap.el):

--8<---------------cut here---------------start------------->8---
--- imap.el	2 Mar 2008 16:55:00 -0000	7.44
+++ imap.el	2 Apr 2008 14:46:57 -0000	7.45
@@ -440,6 +440,12 @@
 The function should take two arguments, the first the IMAP tag and the
 second the status (OK, NO, BAD etc) of the command.")
 
+(defvar imap-enable-exchange-bug-workaround nil
+  "Send FETCH UID commands as *:* instead of *.
+Enabling this appears to be required for some servers (e.g.,
+Microsoft Exchange) which otherwise would trigger a response 'BAD
+The specified message set is invalid.'.")
+
 \f
 ;; Utility functions:
 
@@ -1774,7 +1780,8 @@
 	  (imap-message-data (make-vector 2 0)))
       (when (imap-mailbox-examine-1 mailbox)
 	(prog1
-	    (and (imap-fetch "*" "UID")
+	    (and (imap-fetch
+		  (if imap-enable-exchange-bug-workaround "*:*" "*") "UID")
 		 (list (imap-mailbox-get-1 'uidvalidity mailbox)
 		       (apply 'max (imap-message-map
 				    (lambda (uid prop) uid) 'UID))))
@@ -1818,7 +1825,8 @@
 	  (imap-message-data (make-vector 2 0)))
       (when (imap-mailbox-examine-1 mailbox)
 	(prog1
-	    (and (imap-fetch "*" "UID")
+	    (and (imap-fetch
+		  (if imap-enable-exchange-bug-workaround "*:*" "*") "UID")
 		 (list (imap-mailbox-get-1 'uidvalidity mailbox)
 		       (apply 'max (imap-message-map
 				    (lambda (uid prop) uid) 'UID))))
--8<---------------cut here---------------end--------------->8---

> Or will this introduce more "instabilities" than it is worth? Or am
> I better off downloading and compiling a newer emacs? If so, which
> version will suffice? 

It's only in the development version of Emacs (to become Emacs 23).

Unfortunately we didn't apply this patch to v5-10 so that it is not
included in the recently released Emacs 22.3.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



  parent reply	other threads:[~2008-09-24 18:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-23 20:52 Mat Marcus
2008-09-24  6:21 ` Vitaly Mayatskikh
2008-09-24  7:28   ` David Engster
2008-09-24 17:07   ` Mat Marcus
2008-09-24 18:13     ` Vitaly Mayatskikh
2008-09-24 18:27     ` Reiner Steib [this message]
2008-09-24 20:25     ` Steinar Bang
2008-09-25 17:31     ` Mat Marcus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874p45qtzu.fsf@marauder.physik.uni-ulm.de \
    --to=reinersteib+gmane@imap.cc \
    --cc=Reiner.Steib@gmx.de \
    --cc=ding@gnus.org \
    --cc=mat-lists@emarcus.org \
    --cc=v.mayatskih@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).