summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/misc/gnus.texi12
-rw-r--r--lisp/gnus/nnir.el27
2 files changed, 25 insertions, 14 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index fb9113f4608..d1c746c2e56 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -21468,6 +21468,18 @@ The prefix to remove from each file name returned by notmuch in order
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 ea7257d0c9b..084b154e8a1 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -518,18 +518,16 @@ that it is for notmuch, not Namazu."
: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 @@ construct path: search terms (see the variable
":[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)