comparison lisp/man.el @ 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 79f712c639b7
children 2a9fdbfcb993
comparison
equal deleted inserted replaced
17131:6ff1e0aec51e 17132:07c01fa1e7fc
287 s/\\(.\\)\b\\1/\\1/g\\ 287 s/\\(.\\)\b\\1/\\1/g\\
288 t ovstrk\\ 288 t ovstrk\\
289 }\\ 289 }\\
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
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.")
292 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))
296 (suppress-keymap Man-mode-map) 303 (suppress-keymap Man-mode-map)
461 468
462 (defsubst Man-default-man-entry () 469 (defsubst Man-default-man-entry ()
463 "Make a guess at a default manual entry. 470 "Make a guess at a default manual entry.
464 This guess is based on the text surrounding the cursor, and the 471 This guess is based on the text surrounding the cursor, and the
465 default section number is selected from `Man-auto-section-alist'." 472 default 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 ;; ======================================================================
494 ;; Top level command and background process sentinel 493 ;; Top level command and background process sentinel
495 494
786 truncate-lines t 785 truncate-lines t
787 buffer-read-only t) 786 buffer-read-only t)
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)
794 (Man-goto-page 1) 794 (Man-goto-page 1)
795 (run-hooks 'Man-mode-hook)) 795 (run-hooks 'Man-mode-hook))