Support extension to SEARCH (RFC-4731) when available (via ESEARCH capability) to make UNSEEN queries more efficient
patch e5c973637923fda8b5c042f0135d08965c6ac2de
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue May 31 17:06:39 CEST 2016
* Support extension to SEARCH (RFC-4731) when available (via ESEARCH capability) to make UNSEEN queries more efficient
hunk ./idlebiff 36
+ variable esearchcap 0
hunk ./idlebiff 304
- imap_command_tagged $con "SEARCH UNSEEN"
+ variable ::shared::esearchcap
+
+ if $esearchcap { imap_command_tagged $con "SEARCH RETURN (COUNT) UNSEEN" } \
+ else { imap_command_tagged $con "SEARCH UNSEEN" }
hunk ./idlebiff 324
+proc check_cap_esearch { linea } \
+{
+ variable ::shared::esearchcap
+
+ if !$esearchcap { set esearchcap [ regexp -nocase {.*capability .* esearch .*} $linea ] }
+}
+
hunk ./idlebiff 382
+ check_cap_esearch $linea
hunk ./idlebiff 401
+ check_cap_esearch $linea
hunk ./idlebiff 426
-
- if [ regexp -lineanchor -nocase {^\*\s+search\s+(.*)$} $linea -> msg_list ] \
+ variable ::shared::esearchcap
+
+ if $esearchcap { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
+ else { set rexpr {^\*\s+search\s+(.*)$} }
+ if [ regexp -lineanchor -nocase $rexpr $linea -> res ] \
hunk ./idlebiff 432
- set new_messages [ llength $msg_list ]
+ if !$esearchcap { set res [ llength $res ] }
+ set new_messages $res