summaryrefslogtreecommitdiff
path: root/lisp/man.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2006-12-09 17:42:28 +0000
committerChong Yidong <cyd@stupidchicken.com>2006-12-09 17:42:28 +0000
commit38363db72c35d9d65bf2b9840e51281215c26ec7 (patch)
tree86f977c5d46fa0309839061a6f342a43c8a95c5a /lisp/man.el
parentb13f75a9216ca785ade0f1b965e1d69d6c8ab7b1 (diff)
downloademacs-38363db72c35d9d65bf2b9840e51281215c26ec7.tar.gz
(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.
Diffstat (limited to 'lisp/man.el')
-rw-r--r--lisp/man.el25
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
'follow-link t
'help-echo "mouse-2, RET: display this man page"
'func nil
- 'action (lambda (button)
- (funcall
- (button-get button 'func)
- (let ((func (button-get button 'Man-target-string)))
- (if func
- (if (functionp func) (funcall func) func)
- (button-label button))))))
+ 'action #'Man-xref-button-action)
+
+(defun Man-xref-button-action (button)
+ (let ((target (button-get button 'Man-target-string)))
+ (funcall
+ (button-get button 'func)
+ (cond ((null target)
+ (button-label button))
+ ((functionp target)
+ (funcall target (button-start button)))
+ (t target)))))
(define-button-type 'Man-xref-man-page
:supertype 'Man-abstract-xref-man-page
@@ -636,11 +640,12 @@ a new value."
;; ======================================================================
;; default man entry: get word under point
-(defsubst Man-default-man-entry ()
- "Make a guess at a default manual entry.
-This guess is based on the text surrounding the cursor."
+(defsubst Man-default-man-entry (&optional pos)
+ "Make a guess at a default manual entry based on the text at POS.
+If POS is nil, the current point is used."
(let (word)
(save-excursion
+ (if pos (goto-char pos))
;; Default man entry title is any word the cursor is on, or if
;; cursor not on a word, then nearest preceding word.
(skip-chars-backward "-a-zA-Z0-9._+:")