diff options
| author | Chong Yidong | 2006-12-09 17:42:28 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-12-09 17:42:28 +0000 |
| commit | 38363db72c35d9d65bf2b9840e51281215c26ec7 (patch) | |
| tree | 86f977c5d46fa0309839061a6f342a43c8a95c5a | |
| parent | b13f75a9216ca785ade0f1b965e1d69d6c8ab7b1 (diff) | |
| download | emacs-38363db72c35d9d65bf2b9840e51281215c26ec7.tar.gz emacs-38363db72c35d9d65bf2b9840e51281215c26ec7.zip | |
(Man-xref-button-action): New function. If the `Man-target-string'
button property is a function, assume it accepts a position argument.
(Man-abstract-xref-man-page): Use it.
(Man-default-man-entry): New optional arg POS.
| -rw-r--r-- | lisp/man.el | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/man.el b/lisp/man.el index 2351853eeca..40a4e810204 100644 --- a/lisp/man.el +++ b/lisp/man.el | |||
| @@ -428,13 +428,17 @@ Otherwise, the value is whatever the function | |||
| 428 | 'follow-link t | 428 | 'follow-link t |
| 429 | 'help-echo "mouse-2, RET: display this man page" | 429 | 'help-echo "mouse-2, RET: display this man page" |
| 430 | 'func nil | 430 | 'func nil |
| 431 | 'action (lambda (button) | 431 | 'action #'Man-xref-button-action) |
| 432 | (funcall | 432 | |
| 433 | (button-get button 'func) | 433 | (defun Man-xref-button-action (button) |
| 434 | (let ((func (button-get button 'Man-target-string))) | 434 | (let ((target (button-get button 'Man-target-string))) |
| 435 | (if func | 435 | (funcall |
| 436 | (if (functionp func) (funcall func) func) | 436 | (button-get button 'func) |
| 437 | (button-label button)))))) | 437 | (cond ((null target) |
| 438 | (button-label button)) | ||
| 439 | ((functionp target) | ||
| 440 | (funcall target (button-start button))) | ||
| 441 | (t target))))) | ||
| 438 | 442 | ||
| 439 | (define-button-type 'Man-xref-man-page | 443 | (define-button-type 'Man-xref-man-page |
| 440 | :supertype 'Man-abstract-xref-man-page | 444 | :supertype 'Man-abstract-xref-man-page |
| @@ -636,11 +640,12 @@ a new value." | |||
| 636 | ;; ====================================================================== | 640 | ;; ====================================================================== |
| 637 | ;; default man entry: get word under point | 641 | ;; default man entry: get word under point |
| 638 | 642 | ||
| 639 | (defsubst Man-default-man-entry () | 643 | (defsubst Man-default-man-entry (&optional pos) |
| 640 | "Make a guess at a default manual entry. | 644 | "Make a guess at a default manual entry based on the text at POS. |
| 641 | This guess is based on the text surrounding the cursor." | 645 | If POS is nil, the current point is used." |
| 642 | (let (word) | 646 | (let (word) |
| 643 | (save-excursion | 647 | (save-excursion |
| 648 | (if pos (goto-char pos)) | ||
| 644 | ;; Default man entry title is any word the cursor is on, or if | 649 | ;; Default man entry title is any word the cursor is on, or if |
| 645 | ;; cursor not on a word, then nearest preceding word. | 650 | ;; cursor not on a word, then nearest preceding word. |
| 646 | (skip-chars-backward "-a-zA-Z0-9._+:") | 651 | (skip-chars-backward "-a-zA-Z0-9._+:") |