Re: Complex virtual folder
Kazuhiro Ito <[email protected]> Fri, 04 Jan 2019 20:32:49 +0900
| Newsgroups | gmane.mail.wanderlust.general |
|---|---|
| Message-ID | <867efkhd3y.wl--xmue__28081.2070159756$1546601603$gmane$org@d1.dion.ne.jp> |
> I'm trying to create a complex virtual folder by using the 'OR' keyword (i.e.,
> OR From <keyword> To <keyword>). However, I'm getting the following error (from
> *Messages*):
>
> elmo-imap4-accept-ok: IMAP error: Command Argument Error. 11
>
> Am I doing something wrong?
I think that is known issue but not resolved yet.
Cf. https://github.com/wanderlust/wanderlust/issues/104
As Erik says, stripping parentheses from
elmo-imap4-search-generate-or's result seems to work, but I can't
assure it works in any cases.
(defun elmo-imap4-search-generate-or (session a b)
"Return a search that returns the union of A and B in SESSION.
SESSION is an imap session.
A is the result of a call to elmo-imap4-search-generate.
B is the result of a call to elmo-imap4-search-generate.
A search is either a list of UIDs or a list of the form (CHARSET
IMAP-SEARCH-COMMAND ...) which is to be evaluated at a future
time."
(if (elmo-imap4-search-mergeable-p a b)
(append (list (elmo-imap4-search-mergeable-charset a b))
'("OR") (cdr a) (cdr b))
(elmo-uniq-list (append (elmo-imap4-search-perform session a)
(elmo-imap4-search-perform session b)))))
As another workaround, override elmo-imap4.el's functions by below
code (it may affect all sending strings to a server, but not tested
sufficiently).
(defun elmo-imap4-send-command (session command)
"Send COMMAND to the SESSION.
Returns a TAG string which is assigned to the COMMAND."
(let* ((command-args (if (listp command)
command
(list command)))
(process (elmo-network-session-process-internal session))
(tag (elmo-imap4-command-tag session))
cmdlist token kind)
(with-current-buffer (process-buffer process)
(push tag cmdlist)
;;; No need.
;;; (erase-buffer)
(goto-char (point-min))
(when (elmo-imap4-response-bye-p elmo-imap4-current-response)
(elmo-imap4-process-bye session))
(setq elmo-imap4-current-response nil)
(elmo-imap4-session-wait-response-maybe session)
(setq elmo-imap4-parsing t)
(while (setq token (car command-args))
(cond ((stringp token) ; formatted
(unless (string= "" token)
(push token cmdlist)))
((listp token) ; unformatted
(setq kind (car token))
(cond ((eq kind 'atom)
(push (nth 1 token) cmdlist))
((eq kind 'quoted)
(push (elmo-imap4-format-quoted (nth 1 token)) cmdlist))
((eq kind 'literal)
(push (format
(if (elmo-imap4-session-capable-p session 'literal+) "{%d+}" "{%d}")
(nth 2 token)) cmdlist)
(elmo-imap4-session-process-send-string session (mapconcat #'identity (nreverse cmdlist) " "))
(setq cmdlist nil)
(unless (elmo-imap4-session-capable-p session 'literal+)
(elmo-imap4-accept-continue-req session))
(cond ((stringp (nth 1 token))
(push (nth 1 token) cmdlist))
((bufferp (nth 1 token))
(with-current-buffer (nth 1 token)
(process-send-region
process
(point-min)
(+ (point-min) (nth 2 token)))))
(t
(error "Wrong argument for literal"))))
(t
(error "Unknown token kind %s" kind))))
(t
(error "Invalid argument")))
(setq command-args (cdr command-args)))
(setq command cmdlist)
(while cmdlist
(when (equal (cadr cmdlist) "(")
(setcar (cdr cmdlist) nil)
(setcar cmdlist (concat "(" (car cmdlist))))
(setq cmdlist (cdr cmdlist)))
(setq cmdlist (nreverse (delq nil command))
command cmdlist)
(while cmdlist
(when (equal (cadr cmdlist) ")")
(setcar (cdr cmdlist) nil)
(setcar cmdlist (concat (car cmdlist) ")")))
(setq cmdlist (cdr cmdlist)))
(elmo-imap4-session-process-send-string
session (mapconcat #'identity (delq nil command) " "))
tag)))
(defun elmo-imap4-search-generate-or (session a b)
"Return a search that returns the union of A and B in SESSION.
SESSION is an imap session.
A is the result of a call to elmo-imap4-search-generate.
B is the result of a call to elmo-imap4-search-generate.
A search is either a list of UIDs or a list of the form (CHARSET
IMAP-SEARCH-COMMAND ...) which is to be evaluated at a future
time."
(if (elmo-imap4-search-mergeable-p a b)
(append (list (elmo-imap4-search-mergeable-charset a b))
'("OR" "(") (cdr a) '(")" "(") (cdr b) '(")"))
(elmo-uniq-list (append (elmo-imap4-search-perform session a)
(elmo-imap4-search-perform session b)))))
--
Kazuhiro Ito