diff options
| author | Martin Rudalics | 2007-12-19 09:24:01 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2007-12-19 09:24:01 +0000 |
| commit | ccf721a6259d770f239a56ce40b1abf4edd97ed0 (patch) | |
| tree | c56c9b8defc23fd6294d4c1ef00b371f05d2855b | |
| parent | 5b57e6c6286b916db1bf946640296f873afd9b50 (diff) | |
| download | emacs-ccf721a6259d770f239a56ce40b1abf4edd97ed0.tar.gz emacs-ccf721a6259d770f239a56ce40b1abf4edd97ed0.zip | |
(Man-default-man-entry): When looking for default man
entry title search text preceding point. Use when instead of if.
| -rw-r--r-- | lisp/man.el | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/lisp/man.el b/lisp/man.el index c3621be1c97..ebf1ebc69bc 100644 --- a/lisp/man.el +++ b/lisp/man.el | |||
| @@ -647,26 +647,39 @@ a new value." | |||
| 647 | (defsubst Man-default-man-entry (&optional pos) | 647 | (defsubst Man-default-man-entry (&optional pos) |
| 648 | "Make a guess at a default manual entry based on the text at POS. | 648 | "Make a guess at a default manual entry based on the text at POS. |
| 649 | If POS is nil, the current point is used." | 649 | If POS is nil, the current point is used." |
| 650 | (let (word) | 650 | (let (word start original-pos distance) |
| 651 | (save-excursion | 651 | (save-excursion |
| 652 | (if pos (goto-char pos)) | 652 | (if pos (goto-char pos)) |
| 653 | ;; Default man entry title is any word the cursor is on, or if | 653 | ;; Default man entry title is any word the cursor is on, or if |
| 654 | ;; cursor not on a word, then nearest preceding word. | 654 | ;; cursor not on a word, nearest preceding or next word-like |
| 655 | (skip-chars-backward "-a-zA-Z0-9._+:") | 655 | ;; object on this line. |
| 656 | (let ((start (point))) | 656 | (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:"))) |
| 657 | (skip-chars-forward "-a-zA-Z0-9._+:") | 657 | (setq start (point)) |
| 658 | ;; If there is a continuation at the end of line, check the | 658 | (setq original-pos (point)) |
| 659 | ;; following line too, eg: | 659 | (setq distance (abs (skip-chars-backward ",; \t"))) |
| 660 | ;; see this- | 660 | (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:"))) |
| 661 | ;; command-here(1) | 661 | (progn |
| 662 | (setq word (buffer-substring-no-properties start (point))) | 662 | (setq start (point)) |
| 663 | (if (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])") | 663 | (goto-char original-pos) |
| 664 | (setq word (concat word (match-string 1))))) | 664 | (if (and (< (skip-chars-forward ",; \t") distance) |
| 665 | (if (string-match "[._]+$" word) | 665 | (looking-at "[-a-zA-Z0-9._+:]")) |
| 666 | (setq word (substring word 0 (match-beginning 0)))) | 666 | (setq start (point)) |
| 667 | (goto-char start))) | ||
| 668 | (skip-chars-forward ",; \t") | ||
| 669 | (setq start (point)))) | ||
| 670 | (skip-chars-forward "-a-zA-Z0-9._+:") | ||
| 671 | (setq word (buffer-substring-no-properties start (point))) | ||
| 672 | ;; If there is a continuation at the end of line, check the | ||
| 673 | ;; following line too, eg: | ||
| 674 | ;; see this- | ||
| 675 | ;; command-here(1) | ||
| 676 | (when (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])") | ||
| 677 | (setq word (concat word (match-string-no-properties 1)))) | ||
| 678 | (when (string-match "[._]+$" word) | ||
| 679 | (setq word (substring word 0 (match-beginning 0)))) | ||
| 667 | ;; If looking at something like *strcat(... , remove the '*' | 680 | ;; If looking at something like *strcat(... , remove the '*' |
| 668 | (if (string-match "^*" word) | 681 | (when (string-match "^*" word) |
| 669 | (setq word (substring word 1))) | 682 | (setq word (substring word 1))) |
| 670 | ;; If looking at something like ioctl(2) or brc(1M), include the | 683 | ;; If looking at something like ioctl(2) or brc(1M), include the |
| 671 | ;; section number in the returned value. Remove text properties. | 684 | ;; section number in the returned value. Remove text properties. |
| 672 | (concat word | 685 | (concat word |