aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-06-06 12:47:51 +0000
committerRichard M. Stallman2005-06-06 12:47:51 +0000
commita89da416f554e2df08968557abdefb339f493b95 (patch)
treedcb250e62f7fd663be22b30e3c958cfbfe666161
parent9c7f6bb3914b2a2e25c1ac568ff0c4e986b866aa (diff)
downloademacs-a89da416f554e2df08968557abdefb339f493b95.tar.gz
emacs-a89da416f554e2df08968557abdefb339f493b95.zip
(Info-read-node-name-2): New function.
(Info-read-node-name-1): Use that. Add a completion-base-size-function property.
-rw-r--r--lisp/info.el50
1 files changed, 46 insertions, 4 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 774715aca5c..4c6a0ea027d 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1379,6 +1379,43 @@ If FORK is a string, it is the name to use for the new buffer."
1379 1379
1380(defvar Info-read-node-completion-table) 1380(defvar Info-read-node-completion-table)
1381 1381
1382(defun Info-read-node-name-2 (string path-and-suffixes action)
1383 "Virtual completion table for file names input in Info node names.
1384PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
1385 (let* ((names nil)
1386 (suffixes (remove "" (cdr path-and-suffixes)))
1387 (suffix (concat (regexp-opt suffixes t) "\\'"))
1388 (string-dir (file-name-directory string))
1389 (dirs
1390 (if (file-name-absolute-p string)
1391 (list (file-name-directory string))
1392 (car path-and-suffixes))))
1393 (dolist (dir dirs)
1394 (unless dir
1395 (setq dir default-directory))
1396 (if string-dir (setq dir (expand-file-name string-dir dir)))
1397 (when (file-directory-p dir)
1398 (dolist (file (file-name-all-completions
1399 (file-name-nondirectory string) dir))
1400 ;; If the file name has no suffix or a standard suffix,
1401 ;; include it.
1402 (and (or (null (file-name-extension file))
1403 (string-match suffix file))
1404 ;; But exclude subfiles of split info files.
1405 (not (string-match "-[0-9]+\\'" file))
1406 ;; And exclude backup files.
1407 (not (string-match "~\\'" file))
1408 (push (if string-dir (concat string-dir file) file) names))
1409 ;; If the file name ends in a standard suffix,
1410 ;; add the unsuffixed name as a completion option.
1411 (when (string-match suffix file)
1412 (setq file (substring file 0 (match-beginning 0)))
1413 (push (if string-dir (concat string-dir file) file) names)))))
1414 (cond
1415 ((eq action t) (all-completions string names))
1416 ((null action) (try-completion string names))
1417 (t (test-completion string names)))))
1418
1382;; This function is used as the "completion table" while reading a node name. 1419;; This function is used as the "completion table" while reading a node name.
1383;; It does completion using the alist in Info-read-node-completion-table 1420;; It does completion using the alist in Info-read-node-completion-table
1384;; unless STRING starts with an open-paren. 1421;; unless STRING starts with an open-paren.
@@ -1389,15 +1426,16 @@ If FORK is a string, it is the name to use for the new buffer."
1389 (let ((file (substring string 1))) 1426 (let ((file (substring string 1)))
1390 (cond 1427 (cond
1391 ((eq code nil) 1428 ((eq code nil)
1392 (let ((comp (try-completion file 'locate-file-completion 1429 (let ((comp (try-completion file 'Info-read-node-name-2
1393 (cons Info-directory-list 1430 (cons Info-directory-list
1394 (mapcar 'car Info-suffix-list))))) 1431 (mapcar 'car Info-suffix-list)))))
1395 (cond 1432 (cond
1396 ((eq comp t) (concat string ")")) 1433 ((eq comp t) (concat string ")"))
1397 (comp (concat "(" comp))))) 1434 (comp (concat "(" comp)))))
1398 ((eq code t) (all-completions file 'locate-file-completion 1435 ((eq code t)
1399 (cons Info-directory-list 1436 (all-completions file 'Info-read-node-name-2
1400 (mapcar 'car Info-suffix-list)))) 1437 (cons Info-directory-list
1438 (mapcar 'car Info-suffix-list))))
1401 (t nil)))) 1439 (t nil))))
1402 ;; If a file name was given, then any node is fair game. 1440 ;; If a file name was given, then any node is fair game.
1403 ((string-match "\\`(" string) 1441 ((string-match "\\`(" string)
@@ -1413,6 +1451,10 @@ If FORK is a string, it is the name to use for the new buffer."
1413 (t 1451 (t
1414 (test-completion string Info-read-node-completion-table predicate)))) 1452 (test-completion string Info-read-node-completion-table predicate))))
1415 1453
1454;; Arrange to highlight the proper letters in the completion list buffer.
1455(put 'Info-read-node-name-1 'completion-base-size-function
1456 (lambda () 1))
1457
1416(defun Info-read-node-name (prompt &optional default) 1458(defun Info-read-node-name (prompt &optional default)
1417 (let* ((completion-ignore-case t) 1459 (let* ((completion-ignore-case t)
1418 (Info-read-node-completion-table (Info-build-node-completions)) 1460 (Info-read-node-completion-table (Info-build-node-completions))