mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-17 03:10:58 -08:00
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.
This commit is contained in:
parent
b76cd8af05
commit
51e51ce2df
1 changed files with 19 additions and 10 deletions
|
|
@ -1393,18 +1393,27 @@ Returns a list of [group article score] vectors."
|
||||||
(when (and f-name
|
(when (and f-name
|
||||||
(file-readable-p f-name)
|
(file-readable-p f-name)
|
||||||
(null (file-directory-p f-name)))
|
(null (file-directory-p f-name)))
|
||||||
(setq group
|
;; `expand-file-name' canoncalizes the file name,
|
||||||
(replace-regexp-in-string
|
;; specifically collapsing multiple consecutive directory
|
||||||
"[/\\]" "."
|
;; separators.
|
||||||
(replace-regexp-in-string
|
(setq f-name (expand-file-name f-name)
|
||||||
"/?\\(cur\\|new\\|tmp\\)?/\\'" ""
|
group
|
||||||
|
(delete
|
||||||
|
"" ; forward slash at root leaves an empty string
|
||||||
|
(file-name-split
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"\\`\\." ""
|
"\\`\\." "" ; why do we do this?
|
||||||
(string-remove-prefix
|
(string-remove-prefix
|
||||||
prefix (file-name-directory f-name))
|
prefix (file-name-directory f-name))
|
||||||
nil t)
|
nil t)))
|
||||||
nil t)
|
;; Turn file name segments into a Gnus group name.
|
||||||
nil t))
|
group (mapconcat
|
||||||
|
#'identity
|
||||||
|
(if (member (car (last group))
|
||||||
|
'("new" "tmp" "cur"))
|
||||||
|
(nbutlast group)
|
||||||
|
group)
|
||||||
|
"."))
|
||||||
(setq article (file-name-nondirectory f-name)
|
(setq article (file-name-nondirectory f-name)
|
||||||
article
|
article
|
||||||
;; TODO: Provide a cleaner way of producing final
|
;; TODO: Provide a cleaner way of producing final
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue