From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.bugs Subject: bug#45770: 28.0.50; `gnus-search-run-search' for imap does not take parentheses into account Date: Sun, 10 Jan 2021 12:49:04 -0500 Message-ID: <87ft388yy7.fsf@md5i.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25318"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 45770@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 10 18:50:55 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyere-0006SH-Ez for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jan 2021 18:50:54 +0100 Original-Received: from localhost ([::1]:59870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyerd-0000oP-8j for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jan 2021 12:50:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyeqo-0000mx-GY for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 12:50:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyeqo-00087G-8Y for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 12:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kyeqo-0007qn-4G; Sun, 10 Jan 2021 12:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Welsh Duggan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Sun, 10 Jan 2021 17:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45770 X-GNU-PR-Package: emacs,gnus X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161030095130089 (code B ref -1); Sun, 10 Jan 2021 17:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Jan 2021 17:49:11 +0000 Original-Received: from localhost ([127.0.0.1]:54853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyepz-0007pF-5g for submit@debbugs.gnu.org; Sun, 10 Jan 2021 12:49:11 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:52800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyepx-0007p7-AE for submit@debbugs.gnu.org; Sun, 10 Jan 2021 12:49:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyepx-00008W-2f for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 12:49:09 -0500 Original-Received: from md5i.com ([75.151.244.229]:35200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyepu-0007uw-CM for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 12:49:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com; s=dkim; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YrIYXPSlaQG+saPdA88xaRSLXaK7VbZxdcbC9GrIYKk=; b=pq4pqeQD1JnIal9cnEJu/dAE5U +JKxPvyEpxrtZp3qinWmjQUcDJtWSj6ob3B4pvL+gLMd3bru95/bN2Dfak0759jBw3xE4oRtgXRjX V6QnmA3Ac+fV+F2/CpTZFPM23; Original-Received: from md5i by md5i.com with local (Exim 4.94) (envelope-from ) id 1kyeps-002v6H-Q6 for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 12:49:04 -0500 Received-SPF: pass client-ip=75.151.244.229; envelope-from=mwd@md5i.com; helo=md5i.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197654 Archived-At: --=-=-= Content-Type: text/plain When using the `gnus-search-imap' backend for `gnus-search', there is a bug in the `gnus-search-run-search' method. When the search query begins with parentheses (such as "(OR FROM A FROM B)"), the naive check for a known IMAP keyword at the beginning fails due to the parenthesis, and gnus-search adds "TEXT " to the beginning of the query. Moreover, these are several search keys that are not in `gnus-search-imap-search-keys'. These are "new", "not", "old", and "or". I include a minimal patch for these problems. There's another misfeature which I have not attempted to fix that made debugging the problem much more difficult. If the result of a query is not OK, this fact just gets ignored by `gnus-search-run-search' and the search group is considered empty. Even after fixing the above problems, this is a problem when doing a raw search, as one doesn't know whether the query is bad or if it just does not result in any messages. Example: C-u G G "((OR" RET This results in something like: 577841 BAD Error in IMAP command UID SEARCH: Missing ')' (0.001 + 0.000 secs). in the process buffer. Here's a small patch for the first two issues: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 44f43b073c..f20f9586d2 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -1036,7 +1036,7 @@ gnus-search-imap-search-keys '(body cc bcc from header keyword larger smaller subject text to uid x-gm-raw answered before deleted draft flagged on since recent seen sentbefore senton sentsince unanswered undeleted undraft unflagged unkeyword - unseen all) + unseen all new not old or) "Known IMAP search keys.") ;; imap interface @@ -1072,9 +1072,9 @@ gnus-search-imap-search-keys ;; A bit of backward-compatibility slash convenience: if the ;; query string doesn't start with any known IMAP search ;; keyword, assume it is a "TEXT" search. - (unless (and (string-match "\\`[^[:blank:]]+" q-string) + (unless (and (string-match "\\`(*\\([^[:blank:]]+\\)" q-string) (memql (intern-soft (downcase - (match-string 0 q-string))) + (match-string 1 q-string))) gnus-search-imap-search-keys)) (setq q-string (concat "TEXT " q-string))) --=-=-= Content-Type: text/plain In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0) of 2020-12-20 built on maru2 Repository revision: 27347db0069f9d9fd0152274bfc7c649c387f185 Repository branch: md5i Windowing system distributor 'The X.Org Foundation', version 11.0.12009000 System Description: Debian GNU/Linux bullseye/sid Configured using: 'configure --with-modules --without-toolkit-scroll-bars --with-x-toolkit=lucid --with-wide-int --with-gameuser=:staff 'CFLAGS=-Og -ggdb3'' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB LUCID X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Group Minor modes in effect: gnus-topic-mode: t cursor-sensor-mode: t gnus-undo-mode: t display-time-mode: t magit-wip-initial-backup-mode: t magit-wip-before-change-mode: t magit-wip-after-apply-mode: t magit-wip-after-save-mode: t magit-wip-mode: t magit-auto-revert-mode: t global-git-commit-mode: t async-bytecomp-package-mode: t shell-dirtrack-mode: t desktop-save-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t Load-path shadows: /home/md5i/.emacs.d/elpa/cmake-mode-20201217.1410/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode Features: (nroff-mode prolog align ps-bdf ps-mule markdown-mode gnus-eform sh-script smie executable cmake-font-lock cmake-mode autoload tar-mode arc-mode archive-mode lisp-mnt url-http url-gw url-auth finder-inf xref project profiler timer-list goto-addr vc-mtn vc-src vc-sccs vc-svn vc-cvs vc-rcs vc vc-dispatcher bug-reference tex-mode latexenc rst pcmpl-unix man generic thai-util thai-word org-element avl-tree generator ol-eww eww xdg ol-rmail ol-mhe ol-irc ol-info ol-gnus ol-docview doc-view ol-bibtex bibtex ol-bbdb ol-w3m org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs image-mode exif zenscript-mode zenscript-indentation zenscript-completion zenscript-language zenscript-parser zenscript-highlighting zenscript-common calc-undo js vc-hg vc-bzr tramp-cmds rfc2104 noutline outline tramp-cache novice magit-extras face-remap conf-mode dired-aux shr-color color flow-fill calc-misc calc-alg calc-ext calc-menu calc calc-loaddefs calc-macs mm-archive gnus-bcklg qp copyright time-stamp whitespace tabify grep compile shadow sort mail-extr emacsbug vc-git dabbrev edebug deuglify gnus-async gnus-cite gnus-cus gnus-diary nndiary gnus-draft gnus-dup gnus-fun gnus-html url-queue url-cache mm-url gnus-kill gnus-logic gnus-mh mh-comp mh-scan mh-gnus mh-e mh-compat mh-buffers mh-loaddefs gnus-registry registry eieio-base gnus-salt gnus-uu yenc gnus-vm sendmail mule-util cl-print debug backtrace misearch multi-isearch jka-compr thingatpt shortdoc help-fns radix-tree gnus-ml disp-table nnselect gnus-search eieio-opt speedbar ezimage dframe find-func gnus-topic cursor-sensor utf-7 nndraft nnmh epa-file network-stream nsm nnml gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-cache gnus-sum shr kinsoku svg gnus-demon nntp gnus-group gnus-undo gnutls gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range gnus-win gnus nnheader flyspell ispell view uptimes descr-text tramp-sh cus-edit pp cus-start cus-load tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat parse-time iso8601 ls-lisp time sieve-manage sasl sasl-anonymous sasl-login sasl-plain rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util sgml-mode dom psvn wid-edit cl ps-print ps-print-loaddefs ps-def lpr picture magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff diff-mode magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process magit-mode git-commit transient format-spec magit-git magit-section magit-utils crm log-edit easy-mmode message rmc puny rfc822 mml mml-sec epa gnus-util rmail rmail-loaddefs text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log with-editor cl-extra help-mode async-bytecomp advice async shell pcomplete server dash lua-mode rx comint ansi-color ring generated generic-x epg epg-config ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util pcase dbus xml desktop frameset dired-x dired dired-loaddefs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs edmacro kmacro derived debian-el info package easymenu browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 3100306 317740) (symbols 48 59489 65) (strings 32 300970 101472) (string-bytes 1 21728841) (vectors 16 156616) (vector-slots 8 3056454 276397) (floats 8 943 1294) (intervals 56 327249 13446) (buffers 984 241)) -- Michael Welsh Duggan (md5i@md5i.com) --=-=-=--