diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2009-11-25 03:51:00 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2009-11-25 03:51:00 +0000 |
commit | e2ec6dd51362e1fe7c9b66cf8eac2c3366ba3e92 (patch) | |
tree | 25eb4b9e47cb2b5524fc18b54299689a748fd37c /lisp/man.el | |
parent | eb708e66249e7b9760b5fb9ce8e047f49191d972 (diff) | |
download | emacs-e2ec6dd51362e1fe7c9b66cf8eac2c3366ba3e92.tar.gz |
(Man-completion-cache): New var.
(Man-completion-table): Use it.
Diffstat (limited to 'lisp/man.el')
-rw-r--r-- | lisp/man.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/man.el b/lisp/man.el index 5923b3909ee..364a5d248fc 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -749,10 +749,17 @@ POS defaults to `point'." ;;;###autoload (defalias 'manual-entry 'man) +(defvar Man-completion-cache nil + ;; On my machine, "man -k" is so fast that a cache makes no sense, + ;; but apparently that's not the case in all cases, so let's add a cache. + "Cache of completion table of the form (PREFIX . TABLE).") + (defun Man-completion-table (string pred action) (cond ((memq action '(t nil)) - (let ((table '())) + (let ((table (cdr Man-completion-cache))) + (unless (and Man-completion-cache + (string-prefix-p (car Man-completion-cache) string)) (with-temp-buffer ;; Actually for my `man' the arg is a regexp. Don't know how ;; standard that is. Also, it's not clear what kind of @@ -760,10 +767,13 @@ POS defaults to `point'." ;; whereas under MacOSX it seems to be BRE-style and ;; doesn't accept backslashes at all. Let's not bother to ;; quote anything. - (call-process "man" nil '(t nil) nil "-k" (concat "^" string)) + (call-process manual-program nil '(t nil) nil + "-k" (concat "^" string)) (goto-char (point-min)) (while (re-search-forward "^[^ \t\n]+" nil t) (push (match-string 0) table))) + ;; Cache the table for later reuse. + (setq Man-completion-cache (cons string table))) ;; The table may contain false positives since the match is made ;; by "man -k" not just on the manpage's name. (complete-with-action action table string pred))) |