diff options
| author | Stefan Monnier | 2009-11-25 03:51:00 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-11-25 03:51:00 +0000 |
| commit | e2ec6dd51362e1fe7c9b66cf8eac2c3366ba3e92 (patch) | |
| tree | 25eb4b9e47cb2b5524fc18b54299689a748fd37c | |
| parent | eb708e66249e7b9760b5fb9ce8e047f49191d972 (diff) | |
| download | emacs-e2ec6dd51362e1fe7c9b66cf8eac2c3366ba3e92.tar.gz emacs-e2ec6dd51362e1fe7c9b66cf8eac2c3366ba3e92.zip | |
(Man-completion-cache): New var.
(Man-completion-table): Use it.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/man.el | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b11127c7a7b..e0125c85b73 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2009-11-25 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-11-25 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * man.el (Man-completion-cache): New var. | ||
| 4 | (Man-completion-table): Use it. | ||
| 5 | |||
| 3 | * vc.el (vc-print-log-internal): Make `limit' optional for better | 6 | * vc.el (vc-print-log-internal): Make `limit' optional for better |
| 4 | compatibility (e.g. with vc-annotate.el). | 7 | compatibility (e.g. with vc-annotate.el). |
| 5 | 8 | ||
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'." | |||
| 749 | ;;;###autoload | 749 | ;;;###autoload |
| 750 | (defalias 'manual-entry 'man) | 750 | (defalias 'manual-entry 'man) |
| 751 | 751 | ||
| 752 | (defvar Man-completion-cache nil | ||
| 753 | ;; On my machine, "man -k" is so fast that a cache makes no sense, | ||
| 754 | ;; but apparently that's not the case in all cases, so let's add a cache. | ||
| 755 | "Cache of completion table of the form (PREFIX . TABLE).") | ||
| 756 | |||
| 752 | (defun Man-completion-table (string pred action) | 757 | (defun Man-completion-table (string pred action) |
| 753 | (cond | 758 | (cond |
| 754 | ((memq action '(t nil)) | 759 | ((memq action '(t nil)) |
| 755 | (let ((table '())) | 760 | (let ((table (cdr Man-completion-cache))) |
| 761 | (unless (and Man-completion-cache | ||
| 762 | (string-prefix-p (car Man-completion-cache) string)) | ||
| 756 | (with-temp-buffer | 763 | (with-temp-buffer |
| 757 | ;; Actually for my `man' the arg is a regexp. Don't know how | 764 | ;; Actually for my `man' the arg is a regexp. Don't know how |
| 758 | ;; standard that is. Also, it's not clear what kind of | 765 | ;; standard that is. Also, it's not clear what kind of |
| @@ -760,10 +767,13 @@ POS defaults to `point'." | |||
| 760 | ;; whereas under MacOSX it seems to be BRE-style and | 767 | ;; whereas under MacOSX it seems to be BRE-style and |
| 761 | ;; doesn't accept backslashes at all. Let's not bother to | 768 | ;; doesn't accept backslashes at all. Let's not bother to |
| 762 | ;; quote anything. | 769 | ;; quote anything. |
| 763 | (call-process "man" nil '(t nil) nil "-k" (concat "^" string)) | 770 | (call-process manual-program nil '(t nil) nil |
| 771 | "-k" (concat "^" string)) | ||
| 764 | (goto-char (point-min)) | 772 | (goto-char (point-min)) |
| 765 | (while (re-search-forward "^[^ \t\n]+" nil t) | 773 | (while (re-search-forward "^[^ \t\n]+" nil t) |
| 766 | (push (match-string 0) table))) | 774 | (push (match-string 0) table))) |
| 775 | ;; Cache the table for later reuse. | ||
| 776 | (setq Man-completion-cache (cons string table))) | ||
| 767 | ;; The table may contain false positives since the match is made | 777 | ;; The table may contain false positives since the match is made |
| 768 | ;; by "man -k" not just on the manpage's name. | 778 | ;; by "man -k" not just on the manpage's name. |
| 769 | (complete-with-action action table string pred))) | 779 | (complete-with-action action table string pred))) |