Mercurial > emacs
comparison lisp/man.el @ 74532:2acf2de66673
(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.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 09 Dec 2006 17:42:28 +0000 |
parents | 5dd4533a9a7e |
children | e3694f1cb928 6588c6259dfb |
comparison
equal
deleted
inserted
replaced
74531:76a88b32996a | 74532:2acf2de66673 |
---|---|
426 ;; buttons | 426 ;; buttons |
427 (define-button-type 'Man-abstract-xref-man-page | 427 (define-button-type 'Man-abstract-xref-man-page |
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 |
441 'func 'man-follow) | 445 'func 'man-follow) |
442 | 446 |
634 | 638 |
635 | 639 |
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._+:") |
647 (let ((start (point))) | 652 (let ((start (point))) |
648 (skip-chars-forward "-a-zA-Z0-9._+:") | 653 (skip-chars-forward "-a-zA-Z0-9._+:") |