Handle multiline SEARCH responses (according to http://imapwiki.org/ClientImplementation/Search)
patch 6dd64c777afb2deec0c3dcfacbba3552e409ead6
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Nov 22 23:26:40 CET 2016
* Handle multiline SEARCH responses (according to http://imapwiki.org/ClientImplementation/Search)
hunk ./idlebiff 34
+ variable pmsgs 0
+ variable search_resp 0
hunk ./idlebiff 48
+ variable search
+ variable rexpsearch
hunk ./idlebiff 186
+proc set_search_params { } \
+{
+ variable ::shared::cap
+ variable ::shared::search
+ variable ::shared::rexpsearch
+ variable ::shared::criteria
+
+ if $cap(esearch) \
+ {
+ set search "SEARCH RETURN (COUNT) $criteria"
+ set rexpsearch {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$}
+ } \
+ else \
+ {
+ set search "SEARCH $criteria"
+ set rexpsearch {^\*\s+search\s+(.*)$}
+ }
+}
+
hunk ./idlebiff 348
- variable ::shared::cap
- variable ::shared::criteria
-
- if $cap(esearch) { imap_command_tagged $con "SEARCH RETURN (COUNT) $criteria" } \
- else { imap_command_tagged $con "SEARCH $criteria" }
+ variable ::shared::search
+
+ imap_command_tagged $con $search
hunk ./idlebiff 385
+ set_search_params
hunk ./idlebiff 459
-
- if $cap(esearch) { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
- else { set rexpr {^\*\s+search\s+(.*)$} }
- if [ regexp -lineanchor -nocase $rexpr $linea -> res ] \
+ variable ::shared::rexpsearch
+ variable ::static::pmsgs
+ variable ::static::search_resp
+
+ if [ regexp -lineanchor -nocase $rexpsearch $linea -> res ] \
hunk ./idlebiff 465
+ if $cap(esearch) { set pmsgs $res } else { incr pmsgs [ llength $res ] }
+ set search_resp 1
+ }
+ if { $search_resp && [ ok_tagged $linea ] } \
+ {
hunk ./idlebiff 471
- if !$cap(esearch) { set res [ llength $res ] }
- set new_messages $res
+ set new_messages $pmsgs
+ set pmsgs 0
+ set search_resp 0
hunk ./idlebiff 478
- } [_$_]
+ }
+ if [ no_tagged $linea ] { error search }