aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-03-02 00:15:34 +0000
committerKarl Heuer1997-03-02 00:15:34 +0000
commitf655106be2fffe6c35bdf5a20d4e0b998571bf28 (patch)
tree5e0bac459335c333fd9d45ce2bf482e532a3b419
parent47582ab34d8fa116cd46844927b877a2408e1ec3 (diff)
downloademacs-f655106be2fffe6c35bdf5a20d4e0b998571bf28.tar.gz
emacs-f655106be2fffe6c35bdf5a20d4e0b998571bf28.zip
(man-mode-syntax-table): New variable.
(Man-mode): Use it. (man-follow): New command and keystroke. (Man-default-man-entry): Ignore trailing dots and underscores.
-rw-r--r--lisp/man.el42
1 files changed, 21 insertions, 21 deletions
diff --git a/lisp/man.el b/lisp/man.el
index eb1e3a34b50..8b4d9072cb7 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -290,6 +290,13 @@ This regular expression should start with a `^' character.")
290/\e\\[[0-9][0-9]*m/ s///g" 290/\e\\[[0-9][0-9]*m/ s///g"
291 "Script for berkeley-like sed to nuke backspaces and ANSI codes from manpages.") 291 "Script for berkeley-like sed to nuke backspaces and ANSI codes from manpages.")
292 292
293(defvar man-mode-syntax-table
294 (let ((table (copy-syntax-table (standard-syntax-table))))
295 (modify-syntax-entry ?. "w" table)
296 (modify-syntax-entry ?_ "w" table)
297 table)
298 "Syntax table used in Man mode buffers.")
299
293(if Man-mode-map 300(if Man-mode-map
294 nil 301 nil
295 (setq Man-mode-map (make-keymap)) 302 (setq Man-mode-map (make-keymap))
@@ -463,31 +470,23 @@ and the Man-section-translations-alist variables)."
463 "Make a guess at a default manual entry. 470 "Make a guess at a default manual entry.
464This guess is based on the text surrounding the cursor, and the 471This guess is based on the text surrounding the cursor, and the
465default section number is selected from `Man-auto-section-alist'." 472default section number is selected from `Man-auto-section-alist'."
466 (let (default-title) 473 (let (word)
467 (save-excursion 474 (save-excursion
468
469 ;; Default man entry title is any word the cursor is on, or if 475 ;; Default man entry title is any word the cursor is on, or if
470 ;; cursor not on a word, then nearest preceding word. Cannot 476 ;; cursor not on a word, then nearest preceding word.
471 ;; use the current-word function because it skips the dots. 477 (setq word (current-word))
472 (if (not (looking-at "[-a-zA-Z_.]")) 478 (if (string-match "[._]+$" word)
473 (skip-chars-backward "^a-zA-Z")) 479 (setq word (substring word 0 (match-beginning 0))))
474 (skip-chars-backward "-(a-zA-Z_0-9_.")
475 (if (looking-at "(") (forward-char 1))
476 (setq default-title
477 (buffer-substring
478 (point)
479 (progn (skip-chars-forward "-a-zA-Z0-9_.") (point))))
480
481 ;; If looking at something like ioctl(2) or brc(1M), include the 480 ;; If looking at something like ioctl(2) or brc(1M), include the
482 ;; section number in the returned value. Remove text properties. 481 ;; section number in the returned value. Remove text properties.
483 (let ((result (concat 482 (forward-word 1)
484 default-title 483 ;; Use `format' here to clear any text props from `word'.
485 (if (looking-at 484 (format "%s%s"
486 (concat "[ \t]*([ \t]*\\(" 485 word
487 Man-section-regexp "\\)[ \t]*)")) 486 (if (looking-at
488 (format "(%s)" (Man-match-substring 1)))))) 487 (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
489 (set-text-properties 0 (length result) nil result) 488 (format "(%s)" (Man-match-substring 1))
490 result)))) 489 "")))))
491 490
492 491
493;; ====================================================================== 492;; ======================================================================
@@ -788,6 +787,7 @@ The following key bindings are currently in effect in the buffer:
788 (buffer-disable-undo (current-buffer)) 787 (buffer-disable-undo (current-buffer))
789 (auto-fill-mode -1) 788 (auto-fill-mode -1)
790 (use-local-map Man-mode-map) 789 (use-local-map Man-mode-map)
790 (set-syntax-table man-mode-syntax-table)
791 (Man-build-page-list) 791 (Man-build-page-list)
792 (Man-strip-page-headers) 792 (Man-strip-page-headers)
793 (Man-unindent) 793 (Man-unindent)