changeset 17132:07c01fa1e7fc

(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.
author Karl Heuer <kwzh@gnu.org>
date Sun, 02 Mar 1997 00:15:34 +0000
parents 6ff1e0aec51e
children fbdff0d0de3d
files lisp/man.el
diffstat 1 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/man.el	Sat Mar 01 17:55:39 1997 +0000
+++ b/lisp/man.el	Sun Mar 02 00:15:34 1997 +0000
@@ -290,6 +290,13 @@
 /\e\\[[0-9][0-9]*m/ s///g"
   "Script for berkeley-like sed to nuke backspaces and ANSI codes from manpages.")
 
+(defvar man-mode-syntax-table
+  (let ((table (copy-syntax-table (standard-syntax-table))))
+    (modify-syntax-entry ?. "w" table)
+    (modify-syntax-entry ?_ "w" table)
+    table)
+  "Syntax table used in Man mode buffers.")
+
 (if Man-mode-map
     nil
   (setq Man-mode-map (make-keymap))
@@ -463,31 +470,23 @@
   "Make a guess at a default manual entry.
 This guess is based on the text surrounding the cursor, and the
 default section number is selected from `Man-auto-section-alist'."
-  (let (default-title)
+  (let (word)
     (save-excursion
-      
       ;; Default man entry title is any word the cursor is on, or if
-      ;; cursor not on a word, then nearest preceding word.  Cannot
-      ;; use the current-word function because it skips the dots.
-      (if (not (looking-at "[-a-zA-Z_.]"))
-	  (skip-chars-backward "^a-zA-Z"))
-      (skip-chars-backward "-(a-zA-Z_0-9_.")
-      (if (looking-at "(") (forward-char 1))
-      (setq default-title
-	    (buffer-substring
-	     (point)
-	     (progn (skip-chars-forward "-a-zA-Z0-9_.") (point))))
-      
+      ;; cursor not on a word, then nearest preceding word.
+      (setq word (current-word))
+      (if (string-match "[._]+$" word)
+	  (setq word (substring word 0 (match-beginning 0))))
       ;; If looking at something like ioctl(2) or brc(1M), include the
       ;; section number in the returned value.  Remove text properties.
-      (let ((result (concat
-		     default-title
-		     (if (looking-at
-			  (concat "[ \t]*([ \t]*\\("
-				  Man-section-regexp "\\)[ \t]*)"))
-			 (format "(%s)" (Man-match-substring 1))))))
-	(set-text-properties 0 (length result) nil result)
-	result))))
+      (forward-word 1)
+      ;; Use `format' here to clear any text props from `word'.
+      (format "%s%s"
+	      word
+	      (if (looking-at
+		   (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
+		  (format "(%s)" (Man-match-substring 1))
+		"")))))
 
 
 ;; ======================================================================
@@ -788,6 +787,7 @@
   (buffer-disable-undo (current-buffer))
   (auto-fill-mode -1)
   (use-local-map Man-mode-map)
+  (set-syntax-table man-mode-syntax-table)
   (Man-build-page-list)
   (Man-strip-page-headers)
   (Man-unindent)