summaryrefslogtreecommitdiff
path: root/lisp/man.el
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2007-12-19 09:24:01 +0000
committerMartin Rudalics <rudalics@gmx.at>2007-12-19 09:24:01 +0000
commitccf721a6259d770f239a56ce40b1abf4edd97ed0 (patch)
treec56c9b8defc23fd6294d4c1ef00b371f05d2855b /lisp/man.el
parent5b57e6c6286b916db1bf946640296f873afd9b50 (diff)
downloademacs-ccf721a6259d770f239a56ce40b1abf4edd97ed0.tar.gz
(Man-default-man-entry): When looking for default man
entry title search text preceding point. Use when instead of if.
Diffstat (limited to 'lisp/man.el')
-rw-r--r--lisp/man.el45
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."
(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)
+ (let (word start original-pos distance)
(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._+:")
- (let ((start (point)))
- (skip-chars-forward "-a-zA-Z0-9._+:")
- ;; If there is a continuation at the end of line, check the
- ;; following line too, eg:
- ;; see this-
- ;; command-here(1)
- (setq word (buffer-substring-no-properties start (point)))
- (if (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
- (setq word (concat word (match-string 1)))))
- (if (string-match "[._]+$" word)
- (setq word (substring word 0 (match-beginning 0))))
+ ;; cursor not on a word, nearest preceding or next word-like
+ ;; object on this line.
+ (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:")))
+ (setq start (point))
+ (setq original-pos (point))
+ (setq distance (abs (skip-chars-backward ",; \t")))
+ (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:")))
+ (progn
+ (setq start (point))
+ (goto-char original-pos)
+ (if (and (< (skip-chars-forward ",; \t") distance)
+ (looking-at "[-a-zA-Z0-9._+:]"))
+ (setq start (point))
+ (goto-char start)))
+ (skip-chars-forward ",; \t")
+ (setq start (point))))
+ (skip-chars-forward "-a-zA-Z0-9._+:")
+ (setq word (buffer-substring-no-properties start (point)))
+ ;; If there is a continuation at the end of line, check the
+ ;; following line too, eg:
+ ;; see this-
+ ;; command-here(1)
+ (when (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
+ (setq word (concat word (match-string-no-properties 1))))
+ (when (string-match "[._]+$" word)
+ (setq word (substring word 0 (match-beginning 0))))
;; If looking at something like *strcat(... , remove the '*'
- (if (string-match "^*" word)
- (setq word (substring word 1)))
+ (when (string-match "^*" word)
+ (setq word (substring word 1)))
;; If looking at something like ioctl(2) or brc(1M), include the
;; section number in the returned value. Remove text properties.
(concat word