summaryrefslogtreecommitdiff
path: root/lisp/info.el
diff options
context:
space:
mode:
authorOleh Krehel <ohwoeowho@gmail.com>2022-04-17 12:50:05 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-04-17 12:50:05 +0200
commit60a3c94a14da8c9f4fa591bea25ea5189d92fe7a (patch)
tree15d38efeba34b614f343fd2dda361b8b36fb0a22 /lisp/info.el
parent6019ca9dd20825fe6645419d775f9113c44f9309 (diff)
downloademacs-60a3c94a14da8c9f4fa591bea25ea5189d92fe7a.tar.gz
emacs-60a3c94a14da8c9f4fa591bea25ea5189d92fe7a.tar.bz2
emacs-60a3c94a14da8c9f4fa591bea25ea5189d92fe7a.zip
Remove duplicates from Info-read-node-name-2
* lisp/info.el (Info-read-node-name-2): Remove duplicates from completions (bug#20365).
Diffstat (limited to 'lisp/info.el')
-rw-r--r--lisp/info.el45
1 files changed, 13 insertions, 32 deletions
diff --git a/lisp/info.el b/lisp/info.el
index ac4169b5504..380a8e2780d 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1822,41 +1822,22 @@ directories to search if FILENAME is not absolute; SUFFIXES is a
list of valid filename suffixes for Info files. See
`try-completion' for a description of the remaining arguments."
(setq suffixes (remove "" suffixes))
- (when (file-name-absolute-p string)
- (setq dirs (list (file-name-directory string))))
(let ((names nil)
- (names-sans-suffix nil)
- (suffix (concat (regexp-opt suffixes t) "\\'"))
- (string-dir (file-name-directory string)))
+ (suffix (concat (regexp-opt suffixes t) "\\'")))
(dolist (dir dirs)
- (unless dir
- (setq dir default-directory))
- (if string-dir (setq dir (expand-file-name string-dir dir)))
(when (file-directory-p dir)
- (dolist (file (file-name-all-completions
- (file-name-nondirectory string) dir))
- ;; If the file name has no suffix or a standard suffix,
- ;; include it.
- (and (or (null (file-name-extension file))
- (string-match suffix file))
- ;; But exclude subfiles of split Info files.
- (not (string-match "-[0-9]+\\'" file))
- ;; And exclude backup files.
- (not (string-match "~\\'" file))
- (push (if string-dir (concat string-dir file) file) names))
- ;; If the file name ends in a standard suffix,
- ;; add the unsuffixed name as a completion option.
- (when (string-match suffix file)
- (setq file (substring file 0 (match-beginning 0)))
- (push (if string-dir (concat string-dir file) file)
- names-sans-suffix)))))
- ;; If there is just one file, don't duplicate it with suffixes,
- ;; so `Info-read-node-name-1' will be able to complete a single
- ;; candidate and to add the terminating ")".
- (if (and (= (length names) 1) (= (length names-sans-suffix) 1))
- (setq names names-sans-suffix)
- (setq names (append names-sans-suffix names)))
- (complete-with-action action names string pred)))
+ (dolist (file (directory-files dir))
+ ;; If the file name has a standard suffix,
+ ;; include it (without the suffix).
+ (when (and (string-match suffix file)
+ ;; But exclude subfiles of split Info files.
+ (not (string-match "\.info-[0-9]+" file))
+ ;; And exclude backup files.
+ (not (string-match "~\\'" file)))
+ (push (substring file 0 (match-beginning 0))
+ names)))))
+ (complete-with-action action (delete-dups (nreverse names))
+ string pred)))
(defun Info-read-node-name-1 (string predicate code)
"Internal function used by `Info-read-node-name'.