annotate lisp/man.el @ 3462:2624c18df764

(rmail-select-summary): Add a save-excursion.
author Richard M. Stallman <rms@gnu.org>
date Thu, 03 Jun 1993 21:02:22 +0000
parents 1fc2bc44def7
children 507f64624555
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; man.el --- browse UNIX manual pages
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1993 Free Software Foundation, Inc.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Barry A. Warsaw <bwarsaw@cen.com>
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Last-Modified: 31-Jul-1991
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Version: 1.1
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: help
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Adapted-By: ESR
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; any later version.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; This code provides a function, manual-entry, with which you can
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; browse UNIX manual pages. Formatting is done in background so that
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; you can continue to use your Emacs while processing is going on.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; The mode also supports hypertext-like following of manual page SEE
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; ALSO references, and other features. See below or do `?' in a
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; manual page buffer for details.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; ========== Credits and History ==========
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; In mid 1991, several people posted some interesting improvements to
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; man.el from the standard emacs 18.57 distribution. I liked many of
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; these, but wanted everthing in one single package, so I decided
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; to encorporate them into a single manual browsing mode. While
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; much of the code here has been rewritten, and some features added,
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; these folks deserve lots of credit for providing the initial
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; excellent packages on which this one is based.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; Nick Duffek <duffek@chaos.cs.brandeis.edu>, posted a very nice
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; improvement which retrieved and cleaned the manpages in a
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; background process, and which correctly deciphered such options as
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; man -k.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Eric Rose <erose@jessica.stanford.edu>, submitted manual.el which
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; provided a very nice manual browsing mode.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; This package was available as `superman.el' from the LCD paackage
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; for some time before it was accepted into Emacs 19. The entry
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; point and some other names have been changed to make it a drop-in
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; replacement for the old man.el package.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; ========== Features ==========
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; + Runs "man" in the background and pipes the results through a
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; series of sed and awk scripts so that all retrieving and cleaning
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; is done in the background. The cleaning commands are configurable.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; + Syntax is the same as Un*x man
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; + Functionality is the same as Un*x man, including "man -k" and
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; "man <section>, etc.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; + Provides a manual browsing mode with keybindings for traversing
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; the sections of a manpage, following references in the SEE ALSO
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; section, and more.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; + Multiple manpages created with the same man command are put into
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; a narrowed buffer circular list.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;;; Code:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (require 'assoc)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (provide 'man)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; user variables
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (defvar Man-notify 'friendly
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 "*Selects the behavior when manpage is ready.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 This variable may have one of the following values:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 bully -- make the manpage the current buffer and only window
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 aggressive -- make the manpage the current buffer in the other window
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 friendly -- display manpage in other window but don't make current
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 polite -- don't display manpage, but prints message when ready (beeps)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 quiet -- like `polite', but don't beep
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 meek -- make no indication that manpage is ready
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 Any other value of `Man-notify' is equivalent to `meek'.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (defvar Man-reuse-okay-p t
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 "*Reuse a manpage buffer if possible.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 When t, and a manpage buffer already exists with the same invocation,
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 man just indicates the manpage is ready according to the value of
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 Man-notify. When nil, it always fires off a background process, putting
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 the results in a uniquely named buffer.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (defvar Man-downcase-section-letters-p t
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "*Letters in sections are converted to lower case.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 Some Un*x man commands can't handle uppercase letters in sections, for
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 example \"man 2V chmod\", but they are often displayed in the manpage
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 with the upper case letter. When this variable is t, the section
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 letter (e.g., \"2V\") is converted to lowercase (e.g., \"2v\") before
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 being sent to the man background process.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (defvar Man-circular-pages-p t
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 "*If t, the manpage list is treated as circular for traversal.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (defvar Man-auto-section-alist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 '((c-mode . ("2" "3"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (c++-mode . ("2" "3"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (shell-mode . ("1" "8"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (cmushell-mode . ("1" "8"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (text-mode . "1")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 )
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 "*Association list of major modes and their default section numbers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 List is of the form: (MAJOR-MODE . [SECTION | (SECTION*)]). If current
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 major mode is not in list, then the default is to check for manpages
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 in all sections.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (defvar Man-section-translations-alist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 '(("3C++" . "3")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ("1-UCB" . ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 "*Association list of bogus sections to real section numbers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 Some manpages (e.g. the Sun C++ 2.1 manpages) have section numbers in
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 their references which Un*x man(1) does not recognize. This
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 assocation list is used to translate those sections, when found, to
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 the associated section number.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defvar Man-filter-list
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 '(("sed "
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ("-e 's/.\010//g'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 "-e '/[Nn]o such file or directory/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "-e '/Reformatting page. Wait... done/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "-e '/^\\([A-Z][A-Z.]*([0-9A-Za-z][-0-9A-Za-z+]*)\\).*\\1$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "-e '/^[ \\t]*Hewlett-Packard Company[ \\t]*- [0-9]* -.*$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "-e '/^[ \\t]*Hewlett-Packard[ \\t]*- [0-9]* -.*$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 "-e '/^ *Page [0-9]*.*(printed [0-9\\/]*)$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "-e '/^Printed [0-9].*[0-9]$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 "-e '/^Sun Microsystems.*Last change:/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "-e '/^Sun Release [0-9].*[0-9]$/d'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "-e '/^\\n$/D'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ("awk '"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ("BEGIN { blankline=0; anonblank=0; }"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "/^$/ { if (anonblank==0) next; }"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 "{ anonblank=1; }"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "/^$/ { blankline++; next; }"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "'"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 )
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "*Manpage cleaning filter command phrases.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 This variable contains an association list of the following form:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 '((command-string (phrase-string*))*)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 Each phrase-string is concatenated onto the command-string to form a
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 command filter. The (standard) output (and standard error) of the Un*x
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 man command is piped through each command filter in the order the
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 commands appear in the association list. The final output is placed in
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 the manpage buffer.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (defvar Man-mode-line-format
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 '("" mode-line-modified
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 mode-line-buffer-identification " "
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 global-mode-string
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 Man-page-mode-string
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 " %[(" mode-name minor-mode-alist mode-line-process ")%]----"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (-3 . "%p") "-%-")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 "*Mode line format for manual mode buffer.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (defvar Man-mode-map nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 "*Keymap for Man-mode.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (defvar Man-mode-hooks nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 "*Hooks for Man-mode.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defvar Man-section-regexp "[0-9][a-zA-Z+]*"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 "*Regular expression describing a manpage section within parentheses.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (defvar Man-heading-regexp "^[A-Z]"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "*Regular expression describing a manpage heading entry.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (defvar Man-see-also-regexp "SEE ALSO"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 "*Regular expression for SEE ALSO heading (or your equivalent).
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 This regexp should not start with a `^' character.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (defvar Man-first-heading-regexp "^NAME$\\|^No manual entry for .*$"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 "*Regular expression describing first heading on a manpage.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 This regular expression should start with a `^' character.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (defvar Man-reference-regexp "[-a-zA-Z0-9_.]+\\(([0-9][a-zA-Z+]*)\\)?"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 "*Regular expression describing a reference in the SEE ALSO section.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; end user variables
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (defconst Man-version-number "1.1"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "man's version number.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ;; other variables and keymap initializations
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (make-variable-buffer-local 'Man-sections-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (make-variable-buffer-local 'Man-refpages-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (make-variable-buffer-local 'Man-page-list)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (make-variable-buffer-local 'Man-current-page)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (make-variable-buffer-local 'Man-page-mode-string)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (setq-default Man-sections-alist nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (setq-default Man-refpages-alist nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (setq-default Man-page-list nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (setq-default Man-current-page 0)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (setq-default Man-page-mode-string "1 (of 1)")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (if Man-mode-map
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (setq Man-mode-map (make-keymap))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (suppress-keymap Man-mode-map)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (define-key Man-mode-map " " 'scroll-up)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (define-key Man-mode-map "\177" 'scroll-down)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (define-key Man-mode-map "n" 'Man-next-section)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (define-key Man-mode-map "p" 'Man-previous-section)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (define-key Man-mode-map "\en" 'Man-next-manpage)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (define-key Man-mode-map "\ep" 'Man-previous-manpage)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (define-key Man-mode-map "," 'beginning-of-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (define-key Man-mode-map "." 'end-of-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (define-key Man-mode-map "r" 'Man-follow-manual-reference)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (define-key Man-mode-map "t" 'toggle-truncate-lines)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (define-key Man-mode-map "g" 'Man-goto-section)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (define-key Man-mode-map "s" 'Man-goto-see-also-section)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (define-key Man-mode-map "q" 'Man-quit)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (define-key Man-mode-map "m" 'manual-entry)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (define-key Man-mode-map "v" 'Man-version)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (define-key Man-mode-map "?" 'describe-mode)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 )
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; ======================================================================
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ;; utilities
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (defun Man-page-mode-string ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 "Formats part of the mode line for manual mode."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (format "%d (of %d)" Man-current-page (length Man-page-list)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (defun Man-delete-trailing-newline (str)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (if (string= (substring str (1- (length str))) "\n")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (substring str 0 (1- (length str)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 str))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (defun Man-build-man-command ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 "Builds the entire background manpage and cleaning command."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (let ((command "man %s 2>&1 | ")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (flist Man-filter-list))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (while flist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (let ((pcom (car (car flist)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (pargs (car (cdr (car flist)))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (setq flist (cdr flist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (if (or (not (stringp pcom))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (not (listp pargs)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (error "malformed Man-filter-list."))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (setq command (concat command pcom
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (mapconcat '(lambda (phrase) phrase)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 pargs " "))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (if flist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (setq command (concat command " | " ))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 command))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (defun Man-downcase (man-args)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 "Downcases section letters in MAN-ARGS."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (let ((newargs "")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (s 0)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 mstart mend
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (len (length man-args)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (while (and (< s len)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (setq mstart (string-match Man-section-regexp man-args s)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (setq mend (match-end 0)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 newargs (concat newargs (substring man-args s mstart)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (setq newargs (concat newargs (downcase
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (substring man-args mstart mend)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 s mend))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (concat newargs (substring man-args s len))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (defun Man-translate-references (ref)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 "Translates REF from \"chmod(2V)\" to \"2v chmod\" style."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (if (string-match (concat "(" Man-section-regexp ")$") ref)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (let* ((word (progn (string-match "(" ref)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (substring ref 0 (1- (match-end 0)))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (section-re (concat "(\\(" Man-section-regexp "\\))"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (section (if (string-match section-re ref)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (substring ref (match-beginning 1) (match-end 1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (slist Man-section-translations-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 )
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (if Man-downcase-section-letters-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (setq section (Man-downcase section)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (while slist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (let ((s1 (car (car slist)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (s2 (cdr (car slist))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (setq slist (cdr slist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (if Man-downcase-section-letters-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (setq s1 (Man-downcase s1)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (if (not (string= s1 section)) nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (setq section (if Man-downcase-section-letters-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (Man-downcase s2)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 s2)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 slist nil))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (concat section " " word))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ref))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (defun Man-linepos (&optional position col-p)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 "Return the character position at various line/buffer positions.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 Preserves the state of point, mark, etc. Optional POSITION can be one
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 of the following symbols:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 bol == beginning of line
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 boi == beginning of indentation
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 eol == end of line [default]
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 bob == beginning of buffer
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 eob == end of buffer
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 Optional COL-P non-nil returns current-column instead of character position."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (let ((tpnt (point))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 rval)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (cond
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ((eq position 'bol) (beginning-of-line))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 ((eq position 'boi) (back-to-indentation))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ((eq position 'bob) (goto-char (point-min)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ((eq position 'eob) (goto-char (point-max)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (t (end-of-line)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (setq rval (if col-p (current-column) (point)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (goto-char tpnt)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 rval))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 ;; ======================================================================
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 ;; default man entry and get word under point
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (defun Man-default-man-args (manword)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 "Build the default man args from MANWORD and major-mode."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (let ((mode major-mode)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (slist Man-auto-section-alist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (while (and slist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (not (eq (car (car slist)) mode)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (setq slist (cdr slist)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (if (not slist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 manword
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (let ((sections (cdr (car slist))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (if (not (listp sections))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (concat sections " " manword)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (let ((manarg ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (while sections
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (setq manarg (concat manarg " " (car sections) " " manword))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (setq sections (cdr sections)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 manarg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 )))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (defun Man-default-man-entry ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 "Make a guess at a default manual entry.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 This guess is based on the text surrounding the cursor, and the
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 default section number is selected from Man-auto-section-alist."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (let ((default-section nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 default-title)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (save-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 ;; Default man entry title is any word the cursor is on,
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ;; or if cursor not on a word, then nearest preceding
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 ;; word.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (and (not (looking-at "[a-zA-Z_]"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (skip-chars-backward "^a-zA-Z_"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (skip-chars-backward "(a-zA-Z_0-9")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (and (looking-at "(") (forward-char 1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (setq default-title
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (buffer-substring
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (point)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (progn (skip-chars-forward "a-zA-Z0-9_") (point))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;; If looking at something like ioctl(2) or brc(1M), include
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ;; section number in default-entry
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (if (looking-at "[ \t]*([ \t]*[0-9][a-zA-Z]?[ \t]*)")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (progn (skip-chars-forward "^0-9")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (setq default-section
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (buffer-substring
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (point)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (progn
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (skip-chars-forward "0-9a-zA-Z")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (point)))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 ;; Otherwise, assume section number to be 2 if we're
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;; in C code
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (and (eq major-mode 'c-mode)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (setq default-section "2")))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (if default-section
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (format "%s %s" default-section default-title)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 default-title))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 ;; ======================================================================
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ;; top level command and background process sentinel
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ;;;###autoload
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (defun manual-entry (arg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 "Get a Un*x manual page and put it in a buffer.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 This command is the top-level command in the man package. It runs a Un*x
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 command to retrieve and clean a manpage in the background and places the
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 results in a Man-mode (manpage browsing) buffer. See variable
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 Man-notify for what happens when the buffer is ready.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 Universal argument ARG, is passed to Man-getpage-in-background."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (interactive "P")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (let* ((default-entry (Man-default-man-entry))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (man-args
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (read-string (format "Manual-entry: %s"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (if (string= default-entry "") ""
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (format "(default: %s) "
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 default-entry))))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (and (string= man-args "")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (if (string= default-entry "")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (error "No man args given.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (setq man-args default-entry)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (if Man-downcase-section-letters-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (setq man-args (Man-downcase man-args)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (Man-getpage-in-background man-args (consp arg))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (defun Man-getpage-in-background (man-args &optional override-reuse-p)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 "Uses MAN-ARGS to build and fire off the manpage and cleaning command.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 Optional OVERRIDE-REUSE-P, when supplied non-nil forces man to
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 start a background process even if a buffer already exists and
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 Man-reuse-okay-p is non-nil."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (let* ((bufname (concat "*man " man-args "*"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (buffer (get-buffer bufname)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (if (and Man-reuse-okay-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (not override-reuse-p)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (Man-notify-when-ready buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (message "Invoking man %s in background..." man-args)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (setq buffer (generate-new-buffer bufname))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (set-process-sentinel
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (start-process "man" buffer "sh" "-c"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (format (Man-build-man-command) man-args))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 'Man-bgproc-sentinel))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (defun Man-notify-when-ready (man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 "Notify the user when MAN-BUFFER is ready.
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
448 See the variable `Man-notify' for the different notification behaviors."
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (cond
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
450 ((eq Man-notify 'bully)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (pop-to-buffer man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (delete-other-windows))
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
453 ((eq Man-notify 'aggressive)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (pop-to-buffer man-buffer))
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
455 ((eq Man-notify 'friendly)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (display-buffer man-buffer 'not-this-window))
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
457 ((eq Man-notify 'polite)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (beep)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (message "Manual buffer %s is ready." (buffer-name man-buffer)))
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
460 ((eq Man-notify 'quiet)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (message "Manual buffer %s is ready." (buffer-name man-buffer)))
3307
1fc2bc44def7 (Man-notify-when-ready): Correct previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3235
diff changeset
462 ((or (eq Man-notify 'meek)
3235
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (message ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (defun Man-bgproc-sentinel (process msg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 "Manpage background process sentinel."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (let ((Man-buffer (process-buffer process))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (delete-buff nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (err-mess nil))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (if (null (buffer-name Man-buffer)) ;; deleted buffer
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (set-process-buffer process nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (save-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (set-buffer Man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (cond ((or (looking-at "No \\(manual \\)*entry for")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (looking-at "[^\n]*: nothing appropriate$"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (setq err-mess (buffer-substring (point) (Man-linepos 'eol))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 delete-buff t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 )
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 ((not (and (eq (process-status process) 'exit)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (= (process-exit-status process) 0)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (setq err-mess
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (concat (buffer-name Man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ": process "
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (let ((eos (1- (length msg))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (if (= (aref msg eos) ?\n)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (substring msg 0 eos) msg))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (goto-char (point-max))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (insert (format "\nprocess %s" msg))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 )))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (if delete-buff
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (kill-buffer Man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (save-window-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (save-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (set-buffer Man-buffer)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (Man-mode)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (set-buffer-modified-p nil)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (Man-notify-when-ready Man-buffer))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (if err-mess
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (error err-mess))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 )))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 ;; ======================================================================
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 ;; set up manual mode in buffer and build alists
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (defun Man-mode ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 "SUPERMAN 1.1: A mode for browsing Un*x manual pages.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 The following man commands are available in the buffer. Try
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 \"\\[describe-key] <key> RET\" for more information:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 \\[manual-entry] Prompt to retrieve a new manpage.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 \\[Man-follow-manual-reference] Retrieve reference in SEE ALSO section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 \\[Man-next-manpage] Jump to next manpage in circular list.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 \\[Man-previous-manpage] Jump to previous manpage in circular list.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 \\[Man-next-section] Jump to next manpage section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 \\[Man-previous-section] Jump to previous manpage section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 \\[Man-goto-section] Go to a manpage section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 \\[Man-goto-see-also-section] Jumps to the SEE ALSO manpage section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 \\[Man-quit] Deletes the manpage, its buffer, and window.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 \\[Man-version] Prints man's version number.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 \\[describe-mode] Prints this help text.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 The following variables may be of some use. Try
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 \"\\[describe-variable] <variable-name> RET\" for more information:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 Man-notify What happens when manpage formatting is done.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 Man-reuse-okay-p Okay to reuse already formatted buffer?
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 Man-downcase-section-letters-p Force section letters to lower case?
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 Man-circular-pages-p Multiple manpage list treated as circular?
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 Man-auto-section-alist List of major modes and their section numbers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 Man-section-translations-alist List of section numbers and their Un*x equiv.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 Man-filter-list Background manpage filter command.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 Man-mode-line-format Mode line format for Man-mode buffers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 Man-mode-map Keymap bindings for Man-mode buffers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 Man-mode-hooks Hooks for Man-mode.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 Man-section-regexp Regexp describing manpage section letters.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 Man-heading-regexp Regexp describing section headers.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 Man-see-also-regexp Regexp for SEE ALSO section (or your equiv).
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 Man-first-heading-regexp Regexp for first heading on a manpage.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 Man-reference-regexp Regexp matching a references in SEE ALSO.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 Man-version-number Superman version number.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 The following key bindings are currently in effect in the buffer:
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 \\{Man-mode-map}"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (setq major-mode 'Man-mode
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 mode-name "Manual"
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 buffer-auto-save-file-name nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 mode-line-format Man-mode-line-format
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 truncate-lines t
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 buffer-read-only t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (buffer-disable-undo (current-buffer))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (auto-fill-mode -1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (use-local-map Man-mode-map)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (Man-build-page-list)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (Man-goto-page 1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (defun Man-build-section-alist ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 "Build the association list of manpage sections."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (setq Man-sections-alist nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (while (re-search-forward Man-heading-regexp (point-max) t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (aput 'Man-sections-alist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (buffer-substring (Man-linepos 'bol) (Man-linepos)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (forward-line 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (defun Man-build-references-alist ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 "Build the association list of references (in the SEE ALSO section)."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (setq Man-refpages-alist nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (save-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (if (Man-find-section Man-see-also-regexp)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (let ((start (progn (forward-line 1) (point)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (end (progn
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (Man-next-section 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (point)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 hyphenated
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (runningpoint -1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (narrow-to-region start end)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (back-to-indentation)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (while (and (not (eobp)) (/= (point) runningpoint))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (setq runningpoint (point))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (let* ((bow (point))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (eow (re-search-forward Man-reference-regexp end t))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (word (buffer-substring bow (match-end 0)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (len (1- (length word))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (if (not eow) nil
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (if hyphenated
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (setq word (concat hyphenated word)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 hyphenated nil))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (if (= (aref word len) ?-)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (setq hyphenated (substring word 0 len))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (aput 'Man-refpages-alist word))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (skip-chars-forward " \t\n,"))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 ))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (defun Man-build-page-list ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 "Build the list of separate manpages in the buffer."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (setq Man-page-list nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (save-excursion
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (let ((page-start (Man-linepos 'bob))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (page-end (Man-linepos 'eob))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (regexp Man-first-heading-regexp))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (re-search-forward regexp (point-max) t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (while (not (eobp))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (if (re-search-forward regexp (point-max) t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (progn
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (setq page-end (Man-linepos 'bol))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (end-of-line))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (goto-char (point-max))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (setq page-end (point)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (setq Man-page-list (append Man-page-list
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (list (cons page-start page-end)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 page-start page-end)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 ))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 ;; ======================================================================
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 ;; Man-mode commands
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (defun Man-next-section (n)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 "Move point to Nth next section (default 1)."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (interactive "p")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (if (looking-at Man-heading-regexp)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (forward-line 1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (if (re-search-forward Man-heading-regexp (point-max) t n)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (beginning-of-line)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (goto-char (point-max))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (defun Man-previous-section (n)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 "Move point to Nth previous section (default 1)."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (interactive "p")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (if (looking-at Man-heading-regexp)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (forward-line -1))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (if (re-search-backward Man-heading-regexp (point-min) t n)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (beginning-of-line)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (goto-char (point-min))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (defun Man-find-section (section)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 "Move point to SECTION if it exists, otherwise don't move point.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 Returns t if section is found, nil otherwise."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (let ((curpos (point)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (goto-char (point-min))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (if (re-search-forward (concat "^" section) (point-max) t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (progn (beginning-of-line) t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (goto-char curpos)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 nil)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 ))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (defun Man-goto-section ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 "Query for section to move point to."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (aput 'Man-sections-alist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (let* ((default (aheadsym Man-sections-alist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (completion-ignore-case t)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 chosen
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (prompt (concat "Go to section: (default " default ") ")))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (setq chosen (completing-read prompt Man-sections-alist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (if (or (not chosen)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (string= chosen ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 default
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 chosen)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (Man-find-section (aheadsym Man-sections-alist)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (defun Man-goto-see-also-section ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 "Move point the the \"SEE ALSO\" section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 Actually the section moved to is described by Man-see-also-regexp."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (if (not (Man-find-section Man-see-also-regexp))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (error (concat "No " Man-see-also-regexp
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 " section found in current manpage."))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (defun Man-follow-manual-reference (arg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 "Get one of the manpages referred to in the \"SEE ALSO\" section.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 Queries you for the page to retrieve. Of course it does this in the
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 background. Universal argument ARG is passed to Man-getpage-in-background."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (interactive "P")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (if (not Man-refpages-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (error (concat "No references found in current manpage."))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (aput 'Man-refpages-alist
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (let* ((default (aheadsym Man-refpages-alist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 chosen
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (prompt (concat "Refer to: (default " default ") ")))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (setq chosen (completing-read prompt Man-refpages-alist nil t))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (if (or (not chosen)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (string= chosen ""))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 default
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 chosen)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (Man-getpage-in-background
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (Man-translate-references (aheadsym Man-refpages-alist))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (consp arg))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (defun Man-quit ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 "Kill the buffer containing the manpage."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (let ((buff (current-buffer)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (delete-windows-on buff)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (kill-buffer buff)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (defun Man-goto-page (page)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 "Go to the manual page on page PAGE."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (interactive
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (if (not Man-page-list)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (error "You're looking at the only manpage in the buffer.")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (format "nGo to manpage [1-%d]: " (length Man-page-list))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (if (or (< page 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (> page (length Man-page-list)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (error "No manpage %d found" page))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (let* ((page-range (nth (1- page) Man-page-list))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (page-start (car page-range))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (page-end (cdr page-range)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (setq Man-current-page page
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 Man-page-mode-string (Man-page-mode-string))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (widen)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (goto-char page-start)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (narrow-to-region page-start page-end)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (Man-build-section-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (Man-build-references-alist)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (widen)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (narrow-to-region page-start page-end)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (goto-char (point-min))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (defun Man-next-manpage ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "Find the next manpage entry in the buffer."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 (if (= (length Man-page-list) 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (error "This is the only manpage in the buffer."))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (if (< Man-current-page (length Man-page-list))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (Man-goto-page (1+ Man-current-page))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (if Man-circular-pages-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (Man-goto-page 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (error "You're looking at the last manpage in the buffer."))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (defun Man-previous-manpage ()
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 "Find the previous manpage entry in the buffer."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (interactive)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (if (= (length Man-page-list) 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (error "This is the only manpage in the buffer."))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (if (> Man-current-page 1)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (Man-goto-page (1- Man-current-page))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (if Man-circular-pages-p
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (Man-goto-page (length Man-page-list))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (error "You're looking at the first manpage in the buffer."))))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (defun Man-version (arg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 "Show man's version.
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 Universal argument (\\[universal-argument]) ARG inserts version
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 information in the current buffer instead of printing the message in
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 the echo area."
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (interactive "P")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (if (consp arg)
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (insert "Using Superman version " Man-version-number ".")
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (message "Using Superman version %s." Man-version-number)))
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763
82c4b81ce570 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 ;;; man.el ends here