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