emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: info completion shows too many results


From: Richard Stallman
Subject: Re: info completion shows too many results
Date: Sun, 05 Jun 2005 16:26:20 -0400

Does this fix the problem?

*** info.el     28 May 2005 07:54:19 -0400      1.428
--- info.el     05 Jun 2005 13:31:18 -0400      
***************
*** 1379,1384 ****
--- 1379,1421 ----
  
  (defvar Info-read-node-completion-table)
  
+ (defun Info-read-node-name-2 (string path-and-suffixes action)
+   "Virtual completion table for file names input in Info node names.
+ PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
+   (let* ((names nil)
+        (suffixes (remove "" (cdr path-and-suffixes)))
+        (suffix (concat (regexp-opt suffixes t) "\\'"))
+        (string-dir (file-name-directory string))
+        (dirs
+         (if (file-name-absolute-p string)
+             (list (file-name-directory string))
+           (car path-and-suffixes))))
+     (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)))))
+     (cond
+      ((eq action t) (all-completions string names))
+      ((null action) (try-completion string names))
+      (t (test-completion string names)))))
+ 
  ;; This function is used as the "completion table" while reading a node name.
  ;; It does completion using the alist in Info-read-node-completion-table
  ;; unless STRING starts with an open-paren.
***************
*** 1389,1401 ****
      (let ((file (substring string 1)))
        (cond
         ((eq code nil)
!       (let ((comp (try-completion file 'locate-file-completion
                                    (cons Info-directory-list
                                          (mapcar 'car Info-suffix-list)))))
          (cond
           ((eq comp t) (concat string ")"))
           (comp (concat "(" comp)))))
!        ((eq code t) (all-completions file 'locate-file-completion
                                     (cons Info-directory-list
                                           (mapcar 'car Info-suffix-list))))
         (t nil))))
--- 1426,1438 ----
      (let ((file (substring string 1)))
        (cond
         ((eq code nil)
!       (let ((comp (try-completion file 'Info-read-node-name-2
                                    (cons Info-directory-list
                                          (mapcar 'car Info-suffix-list)))))
          (cond
           ((eq comp t) (concat string ")"))
           (comp (concat "(" comp)))))
!        ((eq code t) (all-completions file 'Info-read-node-name-2
                                     (cons Info-directory-list
                                           (mapcar 'car Info-suffix-list))))
         (t nil))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]