From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#33122: Acknowledgement (27.0.50; Allow use of Gnus search groups as notmuch :path search terms) Date: Mon, 19 Nov 2018 10:17:24 -0800 Message-ID: <87bm6l9bkb.fsf@ericabrahamsen.net> References: <871s8hfk0g.fsf@ericabrahamsen.net> <875zxscgt6.fsf@ericabrahamsen.net> <83h8gyft55.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1542651374 17927 195.159.176.226 (19 Nov 2018 18:16:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Nov 2018 18:16:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33122@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 19 19:16:10 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gOo5f-0004Up-Dx for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Nov 2018 19:16:07 +0100 Original-Received: from localhost ([::1]:58488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gOo7l-00017f-Gu for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Nov 2018 13:18:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gOo7a-000166-Lr for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2018 13:18:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gOo7X-00051z-Fb for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2018 13:18:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gOo7W-00051d-IM for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2018 13:18:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gOo7W-00026k-Bs for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2018 13:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Nov 2018 18:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33122 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33122-submit@debbugs.gnu.org id=B33122.15426514478056 (code B ref 33122); Mon, 19 Nov 2018 18:18:02 +0000 Original-Received: (at 33122) by debbugs.gnu.org; 19 Nov 2018 18:17:27 +0000 Original-Received: from localhost ([127.0.0.1]:32984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gOo6w-00025s-Ta for submit@debbugs.gnu.org; Mon, 19 Nov 2018 13:17:27 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:34619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gOo6w-00025l-1M for 33122@debbugs.gnu.org; Mon, 19 Nov 2018 13:17:26 -0500 Original-Received: from localhost (71-212-20-199.tukw.qwest.net [71.212.20.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 2A18A3F0C9; Mon, 19 Nov 2018 18:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1542651445; bh=K9CeyZFbXJ/vCpMuw2IRVHvJ2gEKwBgz+6L7zOQGXjk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=fPY6fYYjdrjPDFPx8TjJlFPINfifVOECMQHSyuzDk2DVa8vVOhKP6L59+St7+edvv HFuoG7WGlAZjRdYKL4Wo/tg3FyzKg5hIAQgWn+Msty9hSUlXJ85YAIISTDMLKTN7Cd OXhzQQsTcs8X8BmZ/41tYFl+h3nUefP1ZA5xUeGM= In-Reply-To: <83h8gyft55.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 03 Nov 2018 10:43:34 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152539 Archived-At: --=-=-= Content-Type: text/plain On 11/03/18 10:43 AM, Eli Zaretskii wrote: >> From: Eric Abrahamsen >> Date: Wed, 24 Oct 2018 08:46:29 +0800 >> >> Here's an updated version of the patch, thanks to Andreas Goesele for >> reporting and testing. > > Thanks, pushed to the master branch. In hindsight, this behavior should be off by default: it's going to require user intervention too often to be practical as on-by-default. This patch changes that, fixes a small bug, and also documents the option. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-Allow-use-of-Gnus-search-groups-as-notmuch-path-.patch >From 7c26e8db58f64446f60c6f255a1a614deba198a6 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Mon, 19 Nov 2018 10:03:16 -0800 Subject: [PATCH] Fix "Allow use of Gnus search groups as notmuch path: search term" * lisp/gnus/nnir.el (nnir-notmuch-filter-group-names-function): Default to nil -- getting correct behavior requires user intervention too often to have this enabled by default. * lisp/gnus/nnir.el (nnir-run-notmuch): If the user has turned this on, then also hardcode `gnus-group-short-name' as a filter -- things will never work without it. Also move leading space to before the opening parenthesis. * doc/misc/gnus.texi: Document option. (Bug#33122) --- doc/misc/gnus.texi | 12 ++++++++++++ lisp/gnus/nnir.el | 27 +++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index fb9113f460..d1c746c2e5 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -21468,6 +21468,18 @@ The notmuch Engine to get a group name (albeit with @samp{/} instead of @samp{.}). This is a regular expression. +@item nnir-notmuch-filter-group-names-function +A function used to transform the names of groups being searched in, +for use as a ``path:'' search keyword for notmuch. If nil, the +default, ``path:'' keywords are not used. Otherwise, this should be a +callable which accepts a single group name and returns a transformed +name as notmuch expects to see it. In many mail backends, for +instance, dots in group names must be converted to forward slashes: to +achieve this, set this option to +@example +(lambda (g) (replace-regexp-in-string "\\." "/" g)) +@end example + @end table diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el index ea7257d0c9..084b154e8a 100644 --- a/lisp/gnus/nnir.el +++ b/lisp/gnus/nnir.el @@ -518,18 +518,16 @@ nnir-notmuch-remove-prefix :type '(regexp) :group 'nnir) -(defcustom nnir-notmuch-filter-group-names-function - #'gnus-group-short-name +(defcustom nnir-notmuch-filter-group-names-function nil "Whether and how to use Gnus group names as \"path:\" search terms. When nil, the groups being searched in are not used as notmuch :path search terms. It's still possible to use \"path:\" terms manually within the search query, however. -When a function, map this function over all the group names. By -default this runs them through `gnus-group-short-name', and it is -recommended to use this transform, at least. Further -transforms (for instance, converting \".\" to \"/\") can be -added like so: +When a function, map this function over all the group names. To +use the group names unchanged, set to (lambda (g) g). Multiple +transforms (for instance, converting \".\" to \"/\") can be added +like so: \(add-function :filter-return nnir-notmuch-filter-group-names-function @@ -1541,14 +1539,15 @@ nnir-run-notmuch ":[0-9]+" "^[0-9]+$")) (groups (when nnir-notmuch-filter-group-names-function - (mapcar nnir-notmuch-filter-group-names-function - groups))) + (delq nil + (mapcar nnir-notmuch-filter-group-names-function + (mapcar #'gnus-group-short-name groups))))) (pathquery (when groups - (concat "(" - (mapconcat (lambda (g) - (format " path:%s" g)) - groups " or") - ")"))) + (concat " (" + (mapconcat (lambda (g) + (format "path:%s" g)) + groups " or") + ")"))) artno dirnam filenam) (when (equal "" qstring) -- 2.19.1 --=-=-=--