summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-search.el
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2022-02-18 08:37:33 -0800
committerEric Abrahamsen <eric@ericabrahamsen.net>2022-02-18 08:37:33 -0800
commit51e51ce2df46fc0c6e17a97e74b00366bb9c09d8 (patch)
treeabb4649081d1fdc17138cecd63cde12ef44b665a /lisp/gnus/gnus-search.el
parentb76cd8af054a0e24ed8cd1bea515f1ca4619b115 (diff)
downloademacs-51e51ce2df46fc0c6e17a97e74b00366bb9c09d8.tar.gz
Handle multiple directory separators in gnus-search results
Try to treat the file names more like file names, less like strings to massage. * lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output): Use `expand-file-name' to collapse separators and generally canonicalize the name. Use `file-name-split' and joining instead of regexp munging.
Diffstat (limited to 'lisp/gnus/gnus-search.el')
-rw-r--r--lisp/gnus/gnus-search.el29
1 files changed, 19 insertions, 10 deletions
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 27b07e36556..4ca873eeec9 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -1393,18 +1393,27 @@ Returns a list of [group article score] vectors."
(when (and f-name
(file-readable-p f-name)
(null (file-directory-p f-name)))
- (setq group
- (replace-regexp-in-string
- "[/\\]" "."
- (replace-regexp-in-string
- "/?\\(cur\\|new\\|tmp\\)?/\\'" ""
+ ;; `expand-file-name' canoncalizes the file name,
+ ;; specifically collapsing multiple consecutive directory
+ ;; separators.
+ (setq f-name (expand-file-name f-name)
+ group
+ (delete
+ "" ; forward slash at root leaves an empty string
+ (file-name-split
(replace-regexp-in-string
- "\\`\\." ""
- (string-remove-prefix
+ "\\`\\." "" ; why do we do this?
+ (string-remove-prefix
prefix (file-name-directory f-name))
- nil t)
- nil t)
- nil t))
+ nil t)))
+ ;; Turn file name segments into a Gnus group name.
+ group (mapconcat
+ #'identity
+ (if (member (car (last group))
+ '("new" "tmp" "cur"))
+ (nbutlast group)
+ group)
+ "."))
(setq article (file-name-nondirectory f-name)
article
;; TODO: Provide a cleaner way of producing final