Mercurial > emacs
annotate lisp/man.el @ 8767:441af4b664ac
(yank-menu): New variable; kill-ring in menu format.
(menu-bar-update-yank-menu, menu-bar-select-yank): New function.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 15 Sep 1994 22:16:49 +0000 |
parents | c75e435af62f |
children | c0a15f821bd8 |
rev | line source |
---|---|
3235 | 1 ;;; man.el --- browse UNIX manual pages |
2 | |
7298 | 3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
3235 | 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 | |
6676
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
79 (defvar manual-program "man" |
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
80 "The name of the program that produces man pages.") |
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
81 |
3235 | 82 (defvar Man-notify 'friendly |
83 "*Selects the behavior when manpage is ready. | |
84 This variable may have one of the following values: | |
85 | |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
86 newframe -- put the manpage in its own frame (see `Man-frame-parameters') |
3235 | 87 bully -- make the manpage the current buffer and only window |
88 aggressive -- make the manpage the current buffer in the other window | |
89 friendly -- display manpage in other window but don't make current | |
90 polite -- don't display manpage, but prints message when ready (beeps) | |
91 quiet -- like `polite', but don't beep | |
92 meek -- make no indication that manpage is ready | |
93 | |
94 Any other value of `Man-notify' is equivalent to `meek'.") | |
95 | |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
96 (defvar Man-frame-parameters nil |
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
97 "*Frame parameter list for creating a new frame for a manual page.") |
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
98 |
3235 | 99 (defvar Man-reuse-okay-p t |
100 "*Reuse a manpage buffer if possible. | |
7450 | 101 If non-nil, and a manpage buffer already exists with the same |
102 invocation, man just indicates the manpage is ready according to the | |
103 value of `Man-notify'. When nil, it always fires off a background | |
104 process, putting the results in a uniquely named buffer.") | |
3235 | 105 |
106 (defvar Man-downcase-section-letters-p t | |
107 "*Letters in sections are converted to lower case. | |
108 Some Un*x man commands can't handle uppercase letters in sections, for | |
109 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
|
110 with the upper case letter. When this variable is t, the section |
3235 | 111 letter (e.g., \"2V\") is converted to lowercase (e.g., \"2v\") before |
112 being sent to the man background process.") | |
113 | |
114 (defvar Man-circular-pages-p t | |
115 "*If t, the manpage list is treated as circular for traversal.") | |
116 | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
117 ;; 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
|
118 ;; to fail to recognize things in other sections. |
3235 | 119 (defvar Man-auto-section-alist |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
120 nil |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
121 ;; '((c-mode . ("2" "3")) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
122 ;; (c++-mode . ("2" "3")) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
123 ;; (c++-c-mode . ("2" "3")) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
124 ;; (shell-mode . ("1" "8")) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
125 ;; (cmushell-mode . ("1" "8")) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
126 ;; (text-mode . "1") |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
127 ;; ) |
3235 | 128 "*Association list of major modes and their default section numbers. |
129 List is of the form: (MAJOR-MODE . [SECTION | (SECTION*)]). If current | |
130 major mode is not in list, then the default is to check for manpages | |
131 in all sections.") | |
132 | |
133 (defvar Man-section-translations-alist | |
134 '(("3C++" . "3") | |
4378
088883bdcd70
(Man-section-translations-alist): Add entries for xlib.
Richard M. Stallman <rms@gnu.org>
parents:
4377
diff
changeset
|
135 ("3X" . "3") ; Xlib man pages |
088883bdcd70
(Man-section-translations-alist): Add entries for xlib.
Richard M. Stallman <rms@gnu.org>
parents:
4377
diff
changeset
|
136 ("3X11" . "3") |
3235 | 137 ("1-UCB" . "")) |
138 "*Association list of bogus sections to real section numbers. | |
139 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
|
140 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
|
141 association list is used to translate those sections, when found, to |
3235 | 142 the associated section number.") |
143 | |
144 (defvar Man-filter-list | |
145 '(("sed " | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
146 (;;"-e 's/.\010//g'" |
3235 | 147 "-e '/[Nn]o such file or directory/d'" |
6292
a52a879c385c
(Man-filter-list): Don't insist on `...done' after `wait'.
Richard M. Stallman <rms@gnu.org>
parents:
5572
diff
changeset
|
148 "-e '/Reformatting page. Wait/d'" |
a52a879c385c
(Man-filter-list): Don't insist on `...done' after `wait'.
Richard M. Stallman <rms@gnu.org>
parents:
5572
diff
changeset
|
149 "-e '/Reformatting entry. Wait/d'" |
6358
250e69a75938
(Man-filter-list): Extend footer pattern for hpux.
Karl Heuer <kwzh@gnu.org>
parents:
6353
diff
changeset
|
150 "-e '/^ *\\([A-Za-z][A-Za-z.]*([0-9A-Za-z][-0-9A-Za-z+]*)\\).*\\1$/d'" |
7450 | 151 "-e '/^[ \t]*Hewlett-Packard Company[ \t]*- [0-9]* -.*$/d'" |
152 "-e '/^[ \t]*Hewlett-Packard[ \t]*- [0-9]* -.*$/d'" | |
6613
b872dcd6cbbd
(Man-filter-list): New footer format to delete.
Karl Heuer <kwzh@gnu.org>
parents:
6373
diff
changeset
|
153 "-e '/^ *- [0-9]* - *Formatted:.*[0-9]$/d'" |
7450 | 154 "-e '/^[ \t]*Page [0-9]*.*(printed [0-9\\/]*)$/d'" |
3235 | 155 "-e '/^Printed [0-9].*[0-9]$/d'" |
7450 | 156 "-e '/^[ \t]*X Version 1[01].*Release [0-9]/d'" |
4968
1607732e7712
(Man-filter-list): Include anything starting with
Richard M. Stallman <rms@gnu.org>
parents:
4915
diff
changeset
|
157 "-e '/^[A-za-z].*Last change:/d'" |
3235 | 158 "-e '/^Sun Release [0-9].*[0-9]$/d'" |
159 "-e '/^\\n$/D'" | |
160 )) | |
4329
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
161 ("awk '\n" |
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
162 ("BEGIN { blankline=0; anonblank=0; }\n" |
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
163 "/^$/ { if (anonblank==0) next; }\n" |
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
164 "{ anonblank=1; }\n" |
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
165 "/^$/ { blankline++; next; }\n" |
dfabe5b99500
(Man-filter-list): Insert \n newlines in awk script.
Richard M. Stallman <rms@gnu.org>
parents:
4203
diff
changeset
|
166 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" |
3235 | 167 "'" |
168 )) | |
169 ) | |
170 "*Manpage cleaning filter command phrases. | |
171 This variable contains an association list of the following form: | |
172 | |
173 '((command-string (phrase-string*))*) | |
174 | |
175 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
|
176 command filter. The (standard) output (and standard error) of the Un*x |
3235 | 177 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
|
178 commands appear in the association list. The final output is placed in |
3235 | 179 the manpage buffer.") |
180 | |
181 (defvar Man-mode-line-format | |
182 '("" mode-line-modified | |
183 mode-line-buffer-identification " " | |
184 global-mode-string | |
4009
4edc10a61fa7
(Man-mode-line-format): Add a space after global-mode-string.
Richard M. Stallman <rms@gnu.org>
parents:
4002
diff
changeset
|
185 " " Man-page-mode-string |
7067 | 186 " %[(" mode-name mode-line-process minor-mode-alist ")%]----" |
3235 | 187 (-3 . "%p") "-%-") |
188 "*Mode line format for manual mode buffer.") | |
189 | |
190 (defvar Man-mode-map nil | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
191 "*Keymap for Man mode.") |
3235 | 192 |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
193 (defvar Man-mode-hook nil |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
194 "*Normal hook run when Man mode is enabled.") |
3235 | 195 |
6358
250e69a75938
(Man-filter-list): Extend footer pattern for hpux.
Karl Heuer <kwzh@gnu.org>
parents:
6353
diff
changeset
|
196 (defvar Man-cooked-hook nil |
6362 | 197 "*Normal hook run after removing backspaces but before Man-mode processing.") |
6358
250e69a75938
(Man-filter-list): Extend footer pattern for hpux.
Karl Heuer <kwzh@gnu.org>
parents:
6353
diff
changeset
|
198 |
4980
50708e8b133b
(Man-section-regexp): Allow section names l, n, L, N.
Richard M. Stallman <rms@gnu.org>
parents:
4968
diff
changeset
|
199 (defvar Man-section-regexp "[0-9][a-zA-Z+]*\\|[LNln]" |
3235 | 200 "*Regular expression describing a manpage section within parentheses.") |
201 | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
202 ;; Unless some system actually adds leading whitespace other than one space, |
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
203 ;; it is more reliable not to accept any other leading whitespace. |
7518
4430fd0ea0a4
(Man-heading-regexp): Accept multiple whitespace chars.
Richard M. Stallman <rms@gnu.org>
parents:
7499
diff
changeset
|
204 (defvar Man-heading-regexp "^[ \t]*\\([A-Z][A-Z \t]+\\)$" |
3235 | 205 "*Regular expression describing a manpage heading entry.") |
206 | |
207 (defvar Man-see-also-regexp "SEE ALSO" | |
208 "*Regular expression for SEE ALSO heading (or your equivalent). | |
209 This regexp should not start with a `^' character.") | |
210 | |
7450 | 211 (defvar Man-first-heading-regexp "^[ \t]*NAME$\\|^[ \t]*No manual entry fo.*$" |
3235 | 212 "*Regular expression describing first heading on a manpage. |
213 This regular expression should start with a `^' character.") | |
214 | |
4377
09cb5e07f8a3
(Man-build-references-alist): When setting word,
Richard M. Stallman <rms@gnu.org>
parents:
4334
diff
changeset
|
215 (defvar Man-reference-regexp |
09cb5e07f8a3
(Man-build-references-alist): When setting word,
Richard M. Stallman <rms@gnu.org>
parents:
4334
diff
changeset
|
216 "[-a-zA-Z0-9_][-a-zA-Z0-9_.]*\\(([0-9][a-zA-Z+]*)\\)?" |
3235 | 217 "*Regular expression describing a reference in the SEE ALSO section.") |
218 | |
3833
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
219 (defvar Man-switches "" |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
220 "*Switches passed to the man command, as a single string.") |
3235 | 221 |
5108
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
222 ;; Would someone like to provide a good test for being on Solaris? |
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
223 ;; We could give it its own value of system-type, but that has drawbacks; |
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
224 ;; it would require changes in lots of places that test system-type. |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
225 (defvar Man-specified-section-option |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
226 (if (string-match "-solaris[0-9.]*$" system-configuration) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
227 "-s" |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
228 "") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
229 "*Option that indicates a specified a manual section name.") |
5108
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
230 |
3235 | 231 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
232 ;; end user variables | |
233 | |
234 ;; other variables and keymap initializations | |
235 (make-variable-buffer-local 'Man-sections-alist) | |
236 (make-variable-buffer-local 'Man-refpages-alist) | |
237 (make-variable-buffer-local 'Man-page-list) | |
238 (make-variable-buffer-local 'Man-current-page) | |
239 (make-variable-buffer-local 'Man-page-mode-string) | |
6363
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
240 (make-variable-buffer-local 'Man-original-frame) |
3235 | 241 |
242 (setq-default Man-sections-alist nil) | |
243 (setq-default Man-refpages-alist nil) | |
244 (setq-default Man-page-list nil) | |
245 (setq-default Man-current-page 0) | |
246 (setq-default Man-page-mode-string "1 (of 1)") | |
247 | |
248 (if Man-mode-map | |
249 nil | |
250 (setq Man-mode-map (make-keymap)) | |
251 (suppress-keymap Man-mode-map) | |
252 (define-key Man-mode-map " " 'scroll-up) | |
253 (define-key Man-mode-map "\177" 'scroll-down) | |
254 (define-key Man-mode-map "n" 'Man-next-section) | |
255 (define-key Man-mode-map "p" 'Man-previous-section) | |
256 (define-key Man-mode-map "\en" 'Man-next-manpage) | |
257 (define-key Man-mode-map "\ep" 'Man-previous-manpage) | |
258 (define-key Man-mode-map "," 'beginning-of-buffer) | |
259 (define-key Man-mode-map "." 'end-of-buffer) | |
260 (define-key Man-mode-map "r" 'Man-follow-manual-reference) | |
261 (define-key Man-mode-map "t" 'toggle-truncate-lines) | |
262 (define-key Man-mode-map "g" 'Man-goto-section) | |
263 (define-key Man-mode-map "s" 'Man-goto-see-also-section) | |
264 (define-key Man-mode-map "q" 'Man-quit) | |
265 (define-key Man-mode-map "m" 'manual-entry) | |
266 (define-key Man-mode-map "?" 'describe-mode) | |
267 ) | |
268 | |
269 | |
270 ;; ====================================================================== | |
271 ;; utilities | |
272 | |
273 (defun Man-page-mode-string () | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
274 "Formats part of the mode line for Man mode." |
3235 | 275 (format "%d (of %d)" Man-current-page (length Man-page-list))) |
276 | |
277 (defun Man-delete-trailing-newline (str) | |
278 (if (string= (substring str (1- (length str))) "\n") | |
279 (substring str 0 (1- (length str))) | |
280 str)) | |
281 | |
282 (defun Man-build-man-command () | |
283 "Builds the entire background manpage and cleaning command." | |
7453
9b14642f7d52
(Man-build-man-command): Use manual-program, not hardcoded name.
Karl Heuer <kwzh@gnu.org>
parents:
7452
diff
changeset
|
284 (let ((command (concat manual-program " " Man-switches " %s 2>/dev/null")) |
3235 | 285 (flist Man-filter-list)) |
286 (while flist | |
287 (let ((pcom (car (car flist))) | |
288 (pargs (car (cdr (car flist))))) | |
289 (setq flist (cdr flist)) | |
290 (if (or (not (stringp pcom)) | |
291 (not (listp pargs))) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
292 (error "Malformed Man-filter-list")) |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
293 (setq command (concat command " | " pcom |
3235 | 294 (mapconcat '(lambda (phrase) phrase) |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
295 pargs " "))))) |
3235 | 296 command)) |
297 | |
298 (defun Man-downcase (man-args) | |
299 "Downcases section letters in MAN-ARGS." | |
300 (let ((newargs "") | |
301 (s 0) | |
302 mstart mend | |
303 (len (length man-args))) | |
304 (while (and (< s len) | |
305 (setq mstart (string-match Man-section-regexp man-args s))) | |
306 (setq mend (match-end 0) | |
307 newargs (concat newargs (substring man-args s mstart))) | |
308 (setq newargs (concat newargs (downcase | |
309 (substring man-args mstart mend))) | |
310 s mend)) | |
311 (concat newargs (substring man-args s len)))) | |
312 | |
313 (defun Man-translate-references (ref) | |
314 "Translates REF from \"chmod(2V)\" to \"2v chmod\" style." | |
315 (if (string-match (concat "(" Man-section-regexp ")$") ref) | |
316 (let* ((word (progn (string-match "(" ref) | |
317 (substring ref 0 (1- (match-end 0))))) | |
318 (section-re (concat "(\\(" Man-section-regexp "\\))")) | |
319 (section (if (string-match section-re ref) | |
320 (substring ref (match-beginning 1) (match-end 1)) | |
321 "")) | |
322 (slist Man-section-translations-alist) | |
323 ) | |
324 (if Man-downcase-section-letters-p | |
325 (setq section (Man-downcase section))) | |
326 (while slist | |
327 (let ((s1 (car (car slist))) | |
328 (s2 (cdr (car slist)))) | |
329 (setq slist (cdr slist)) | |
330 (if Man-downcase-section-letters-p | |
331 (setq s1 (Man-downcase s1))) | |
332 (if (not (string= s1 section)) nil | |
333 (setq section (if Man-downcase-section-letters-p | |
334 (Man-downcase s2) | |
335 s2) | |
336 slist nil)))) | |
5108
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
337 (concat Man-specified-section-option section " " word)) |
3235 | 338 ref)) |
339 | |
340 (defun Man-linepos (&optional position col-p) | |
341 "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
|
342 Preserves the state of point, mark, etc. Optional arg POSITION can be one |
3235 | 343 of the following symbols: |
344 bol == beginning of line | |
345 boi == beginning of indentation | |
346 eol == end of line [default] | |
347 bob == beginning of buffer | |
348 eob == end of buffer | |
349 | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
350 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
|
351 the current column instead of character position." |
3235 | 352 (let ((tpnt (point)) |
353 rval) | |
354 (cond | |
355 ((eq position 'bol) (beginning-of-line)) | |
356 ((eq position 'boi) (back-to-indentation)) | |
357 ((eq position 'bob) (goto-char (point-min))) | |
358 ((eq position 'eob) (goto-char (point-max))) | |
359 (t (end-of-line))) | |
360 (setq rval (if col-p (current-column) (point))) | |
361 (goto-char tpnt) | |
362 rval)) | |
363 | |
364 | |
365 ;; ====================================================================== | |
366 ;; default man entry and get word under point | |
367 | |
368 (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
|
369 "Build the default man args from MANWORD and buffer's major mode." |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
370 (let ((sections (cdr (assq major-mode Man-auto-section-alist)))) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
371 (cond |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
372 ((null sections) manword) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
373 ((consp sections) |
5572
f1e5e8a324a5
(Man-default-man-args): Use Man-specified-section-option.
Richard M. Stallman <rms@gnu.org>
parents:
5269
diff
changeset
|
374 (mapconcat (lambda (n) (concat Man-specified-section-option |
f1e5e8a324a5
(Man-default-man-args): Use Man-specified-section-option.
Richard M. Stallman <rms@gnu.org>
parents:
5269
diff
changeset
|
375 n " " manword)) |
f1e5e8a324a5
(Man-default-man-args): Use Man-specified-section-option.
Richard M. Stallman <rms@gnu.org>
parents:
5269
diff
changeset
|
376 sections " ")) |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
377 (t |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
378 (concat sections " " manword))))) |
3235 | 379 |
380 (defun Man-default-man-entry () | |
381 "Make a guess at a default manual entry. | |
382 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
|
383 default section number is selected from `Man-auto-section-alist'." |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
384 (let (default-title) |
3235 | 385 (save-excursion |
386 | |
387 ;; Default man entry title is any word the cursor is on, | |
388 ;; or if cursor not on a word, then nearest preceding | |
389 ;; word. | |
390 (and (not (looking-at "[a-zA-Z_]")) | |
391 (skip-chars-backward "^a-zA-Z_")) | |
392 (skip-chars-backward "(a-zA-Z_0-9") | |
393 (and (looking-at "(") (forward-char 1)) | |
394 (setq default-title | |
395 (buffer-substring | |
396 (point) | |
397 (progn (skip-chars-forward "a-zA-Z0-9_") (point)))) | |
398 | |
399 ;; If looking at something like ioctl(2) or brc(1M), include | |
400 ;; section number in default-entry | |
401 (if (looking-at "[ \t]*([ \t]*[0-9][a-zA-Z]?[ \t]*)") | |
402 (progn (skip-chars-forward "^0-9") | |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
403 (setq default-title |
5572
f1e5e8a324a5
(Man-default-man-args): Use Man-specified-section-option.
Richard M. Stallman <rms@gnu.org>
parents:
5269
diff
changeset
|
404 (concat Man-specified-section-option |
f1e5e8a324a5
(Man-default-man-args): Use Man-specified-section-option.
Richard M. Stallman <rms@gnu.org>
parents:
5269
diff
changeset
|
405 (buffer-substring |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
406 (point) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
407 (progn |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
408 (skip-chars-forward "0-9a-zA-Z") |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
409 (point))) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
410 " " |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
411 default-title))) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
412 (setq default-title (Man-default-man-args default-title))) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
413 default-title))) |
3235 | 414 |
415 | |
416 ;; ====================================================================== | |
417 ;; top level command and background process sentinel | |
418 | |
4444 | 419 ;;; This alias makes completion more predictable if ignoring case. |
420 ;;;###autoload | |
421 (defalias 'man 'manual-entry) | |
422 | |
3235 | 423 ;;;###autoload |
424 (defun manual-entry (arg) | |
425 "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
|
426 This command is the top-level command in the man package. It runs a Un*x |
3235 | 427 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
|
428 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
|
429 `Man-notify' for what happens when the buffer is ready. |
6373
284634d109ee
(manual-entry): Document what the arg does.
Karl Heuer <kwzh@gnu.org>
parents:
6363
diff
changeset
|
430 Normally, if a buffer already exists for this man page, it will display |
284634d109ee
(manual-entry): Document what the arg does.
Karl Heuer <kwzh@gnu.org>
parents:
6363
diff
changeset
|
431 immediately; either a prefix argument or a nil value to `Man-reuse-okay-p' |
284634d109ee
(manual-entry): Document what the arg does.
Karl Heuer <kwzh@gnu.org>
parents:
6363
diff
changeset
|
432 overrides this and forces the man page to be regenerated." |
3235 | 433 (interactive "P") |
434 (let* ((default-entry (Man-default-man-entry)) | |
435 (man-args | |
436 (read-string (format "Manual-entry: %s" | |
7450 | 437 (if (string= default-entry "") "" |
438 (format "(default: %s) " | |
439 default-entry)))))) | |
3235 | 440 (and (string= man-args "") |
441 (if (string= default-entry "") | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
442 (error "No man args given") |
3235 | 443 (setq man-args default-entry))) |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
444 |
3644
9e251319cdc8
* man.el (manual-entry): Recognize the subject(section) syntax.
Jim Blandy <jimb@redhat.com>
parents:
3619
diff
changeset
|
445 ;; Recognize the subject(section) syntax. |
4002
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
446 (setq man-args (Man-translate-references man-args)) |
511feb3c2874
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
Jim Blandy <jimb@redhat.com>
parents:
3909
diff
changeset
|
447 |
4968
1607732e7712
(Man-filter-list): Include anything starting with
Richard M. Stallman <rms@gnu.org>
parents:
4915
diff
changeset
|
448 ;; This is apparently already done correctly via Man-translate-references. |
1607732e7712
(Man-filter-list): Include anything starting with
Richard M. Stallman <rms@gnu.org>
parents:
4915
diff
changeset
|
449 ;; (if Man-downcase-section-letters-p |
1607732e7712
(Man-filter-list): Include anything starting with
Richard M. Stallman <rms@gnu.org>
parents:
4915
diff
changeset
|
450 ;; (setq man-args (Man-downcase man-args))) |
3235 | 451 (Man-getpage-in-background man-args (consp arg)) |
452 )) | |
453 | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
454 (defun Man-getpage-in-background (topic &optional override-reuse-p) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
455 "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
|
456 Optional OVERRIDE-REUSE-P, when non-nil, means to |
3235 | 457 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
|
458 `Man-reuse-okay-p' is non-nil." |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
459 (let* ((man-args topic) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
460 (bufname (concat "*man " man-args "*")) |
3235 | 461 (buffer (get-buffer bufname))) |
462 (if (and Man-reuse-okay-p | |
463 (not override-reuse-p) | |
464 buffer) | |
465 (Man-notify-when-ready buffer) | |
6353
f00fc681daa4
(Man-build-man-command): Redirect desc 2 to /dev/null.
Richard M. Stallman <rms@gnu.org>
parents:
6292
diff
changeset
|
466 (require 'env) |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
467 (message "Invoking %s %s in background" manual-program man-args) |
3235 | 468 (setq buffer (generate-new-buffer bufname)) |
6363
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
469 (save-excursion |
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
470 (set-buffer buffer) |
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
471 (setq Man-original-frame (selected-frame))) |
4175
3e4fa4423f5a
(Man-getpage-in-background): Copy process-environment
Richard M. Stallman <rms@gnu.org>
parents:
4009
diff
changeset
|
472 (let ((process-environment (copy-sequence process-environment))) |
3713
c77a3da2d08d
(Man-getpage-in-background): Use TERM=dumb to prevent
Richard M. Stallman <rms@gnu.org>
parents:
3659
diff
changeset
|
473 ;; 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
|
474 (setenv "TERM" "dumb") |
c77a3da2d08d
(Man-getpage-in-background): Use TERM=dumb to prevent
Richard M. Stallman <rms@gnu.org>
parents:
3659
diff
changeset
|
475 (set-process-sentinel |
6676
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
476 (start-process manual-program buffer "sh" "-c" |
3714
a1edd269b2f4
(Man-getpage-in-background): Move close paren.
Richard M. Stallman <rms@gnu.org>
parents:
3713
diff
changeset
|
477 (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
|
478 'Man-bgproc-sentinel)) |
7450 | 479 ))) |
3235 | 480 |
481 (defun Man-notify-when-ready (man-buffer) | |
482 "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
|
483 See the variable `Man-notify' for the different notification behaviors." |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
484 (let ((saved-frame (save-excursion |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
485 (set-buffer man-buffer) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
486 Man-original-frame))) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
487 (cond |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
488 ((eq Man-notify 'newframe) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
489 ;; Since we run asynchronously, perhaps while Emacs is waiting for input, |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
490 ;; we must not leave a different buffer current. |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
491 ;; We can't rely on the editor command loop to reselect |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
492 ;; the selected window's buffer. |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
493 (save-excursion |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
494 (set-buffer man-buffer) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
495 (make-frame Man-frame-parameters))) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
496 ((eq Man-notify 'bully) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
497 (and window-system |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
498 (frame-live-p saved-frame) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
499 (select-frame saved-frame)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
500 (pop-to-buffer man-buffer) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
501 (delete-other-windows)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
502 ((eq Man-notify 'aggressive) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
503 (and window-system |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
504 (frame-live-p saved-frame) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
505 (select-frame saved-frame)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
506 (pop-to-buffer man-buffer)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
507 ((eq Man-notify 'friendly) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
508 (and window-system |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
509 (frame-live-p saved-frame) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
510 (select-frame saved-frame)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
511 (display-buffer man-buffer 'not-this-window)) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
512 ((eq Man-notify 'polite) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
513 (beep) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
514 (message "Manual buffer %s is ready." (buffer-name man-buffer))) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
515 ((eq Man-notify 'quiet) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
516 (message "Manual buffer %s is ready." (buffer-name man-buffer))) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
517 ((or (eq Man-notify 'meek) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
518 t) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
519 (message "")) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
520 ))) |
3235 | 521 |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
522 (defun Man-set-fonts () |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
523 (goto-char (point-min)) |
4203
b42338a458a5
(Man-set-fonts): Don't look for another char after
Richard M. Stallman <rms@gnu.org>
parents:
4175
diff
changeset
|
524 (while (re-search-forward "\\(.\b\\)+" nil t) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
525 (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
|
526 (goto-char st) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
527 (if window-system |
4203
b42338a458a5
(Man-set-fonts): Don't look for another char after
Richard M. Stallman <rms@gnu.org>
parents:
4175
diff
changeset
|
528 (put-text-property st (if (= en (point-max)) en (1+ en)) 'face |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
529 (if (looking-at "_") 'underline 'bold))) |
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
530 (while (and (< (point) en) (looking-at ".\b")) |
4203
b42338a458a5
(Man-set-fonts): Don't look for another char after
Richard M. Stallman <rms@gnu.org>
parents:
4175
diff
changeset
|
531 (replace-match ""))))) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
532 |
3235 | 533 (defun Man-bgproc-sentinel (process msg) |
534 "Manpage background process sentinel." | |
535 (let ((Man-buffer (process-buffer process)) | |
536 (delete-buff nil) | |
8190
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
537 (err-mess nil)) |
3235 | 538 (if (null (buffer-name Man-buffer)) ;; deleted buffer |
539 (set-process-buffer process nil) | |
7450 | 540 (save-match-data |
541 (save-excursion | |
542 (set-buffer Man-buffer) | |
543 (goto-char (point-min)) | |
8190
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
544 (let ((case-fold-search nil)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
545 (cond ((or (looking-at "No \\(manual \\)*entry for") |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
546 (looking-at "[^\n]*: nothing appropriate$")) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
547 (setq err-mess (buffer-substring (point) (Man-linepos 'eol)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
548 delete-buff t)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
549 ((not (and (eq (process-status process) 'exit) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
550 (= (process-exit-status process) 0))) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
551 (setq err-mess |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
552 (concat (buffer-name Man-buffer) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
553 ": process " |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
554 (let ((eos (1- (length msg)))) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
555 (if (= (aref msg eos) ?\n) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
556 (substring msg 0 eos) msg)))) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
557 (goto-char (point-max)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
558 (insert (format "\nprocess %s" msg)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
559 )))) |
7450 | 560 (if delete-buff |
561 (kill-buffer Man-buffer) | |
562 (save-window-excursion | |
563 (save-excursion | |
564 (set-buffer Man-buffer) | |
8190
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
565 (let ((case-fold-search nil)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
566 (Man-set-fonts) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
567 (run-hooks 'Man-cooked-hook) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
568 (Man-mode)) |
7450 | 569 (set-buffer-modified-p nil))) |
570 (Man-notify-when-ready Man-buffer)) | |
3235 | 571 |
7450 | 572 (if err-mess |
573 (error err-mess)))))) | |
3235 | 574 |
575 | |
576 ;; ====================================================================== | |
577 ;; set up manual mode in buffer and build alists | |
578 | |
579 (defun Man-mode () | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
580 "A mode for browsing Un*x manual pages. |
3235 | 581 |
582 The following man commands are available in the buffer. Try | |
583 \"\\[describe-key] <key> RET\" for more information: | |
584 | |
585 \\[manual-entry] Prompt to retrieve a new manpage. | |
586 \\[Man-follow-manual-reference] Retrieve reference in SEE ALSO section. | |
587 \\[Man-next-manpage] Jump to next manpage in circular list. | |
588 \\[Man-previous-manpage] Jump to previous manpage in circular list. | |
589 \\[Man-next-section] Jump to next manpage section. | |
590 \\[Man-previous-section] Jump to previous manpage section. | |
591 \\[Man-goto-section] Go to a manpage section. | |
592 \\[Man-goto-see-also-section] Jumps to the SEE ALSO manpage section. | |
593 \\[Man-quit] Deletes the manpage, its buffer, and window. | |
594 \\[describe-mode] Prints this help text. | |
595 | |
596 The following variables may be of some use. Try | |
597 \"\\[describe-variable] <variable-name> RET\" for more information: | |
598 | |
599 Man-notify What happens when manpage formatting is done. | |
600 Man-reuse-okay-p Okay to reuse already formatted buffer? | |
601 Man-downcase-section-letters-p Force section letters to lower case? | |
602 Man-circular-pages-p Multiple manpage list treated as circular? | |
603 Man-auto-section-alist List of major modes and their section numbers. | |
604 Man-section-translations-alist List of section numbers and their Un*x equiv. | |
605 Man-filter-list Background manpage filter command. | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
606 Man-mode-line-format Mode line format for Man mode buffers. |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
607 Man-mode-map Keymap bindings for Man mode buffers. |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
608 Man-mode-hook Normal hook run on entry to Man mode. |
3235 | 609 Man-section-regexp Regexp describing manpage section letters. |
610 Man-heading-regexp Regexp describing section headers. | |
611 Man-see-also-regexp Regexp for SEE ALSO section (or your equiv). | |
612 Man-first-heading-regexp Regexp for first heading on a manpage. | |
613 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
|
614 Man-switches Background `man' command switches. |
3235 | 615 |
616 The following key bindings are currently in effect in the buffer: | |
617 \\{Man-mode-map}" | |
618 (interactive) | |
619 (setq major-mode 'Man-mode | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
620 mode-name "Man" |
3235 | 621 buffer-auto-save-file-name nil |
622 mode-line-format Man-mode-line-format | |
623 truncate-lines t | |
624 buffer-read-only t) | |
625 (buffer-disable-undo (current-buffer)) | |
626 (auto-fill-mode -1) | |
627 (use-local-map Man-mode-map) | |
628 (goto-char (point-min)) | |
629 (Man-build-page-list) | |
3619
062dbb10173d
(Man-mode): Run Man-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
630 (Man-goto-page 1) |
062dbb10173d
(Man-mode): Run Man-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
631 (run-hooks 'Man-mode-hook)) |
3235 | 632 |
633 (defun Man-build-section-alist () | |
634 "Build the association list of manpage sections." | |
635 (setq Man-sections-alist nil) | |
636 (goto-char (point-min)) | |
7450 | 637 (let ((case-fold-search nil)) |
638 (while (re-search-forward Man-heading-regexp (point-max) t) | |
639 (aput 'Man-sections-alist | |
7452
359c1d0a565e
(Man-heading-regexp): Fix pattern.
Karl Heuer <kwzh@gnu.org>
parents:
7451
diff
changeset
|
640 (buffer-substring (match-beginning 1) (match-end 1))) |
7450 | 641 (forward-line 1)))) |
3235 | 642 |
643 (defun Man-build-references-alist () | |
644 "Build the association list of references (in the SEE ALSO section)." | |
645 (setq Man-refpages-alist nil) | |
646 (save-excursion | |
647 (if (Man-find-section Man-see-also-regexp) | |
648 (let ((start (progn (forward-line 1) (point))) | |
649 (end (progn | |
650 (Man-next-section 1) | |
651 (point))) | |
652 hyphenated | |
653 (runningpoint -1)) | |
7450 | 654 (save-restriction |
655 (narrow-to-region start end) | |
656 (goto-char (point-min)) | |
657 (back-to-indentation) | |
658 (while (and (not (eobp)) (/= (point) runningpoint)) | |
659 (setq runningpoint (point)) | |
660 (let* ((eow (re-search-forward Man-reference-regexp end t)) | |
661 (word (buffer-substring | |
662 (match-beginning 0) (match-end 0))) | |
663 (len (1- (length word)))) | |
664 (if (not eow) nil | |
665 (if hyphenated | |
666 (setq word (concat hyphenated word) | |
667 hyphenated nil)) | |
668 (if (= (aref word len) ?-) | |
669 (setq hyphenated (substring word 0 len)) | |
670 (aput 'Man-refpages-alist word)))) | |
671 (skip-chars-forward " \t\n,"))))))) | |
3235 | 672 |
673 (defun Man-build-page-list () | |
674 "Build the list of separate manpages in the buffer." | |
675 (setq Man-page-list nil) | |
676 (save-excursion | |
677 (let ((page-start (Man-linepos 'bob)) | |
678 (page-end (Man-linepos 'eob)) | |
679 (regexp Man-first-heading-regexp)) | |
680 (goto-char (point-min)) | |
681 (re-search-forward regexp (point-max) t) | |
682 (while (not (eobp)) | |
683 (if (re-search-forward regexp (point-max) t) | |
684 (progn | |
685 (setq page-end (Man-linepos 'bol)) | |
686 (end-of-line)) | |
687 (goto-char (point-max)) | |
688 (setq page-end (point))) | |
689 (setq Man-page-list (append Man-page-list | |
7450 | 690 (list (cons page-start page-end))) |
3235 | 691 page-start page-end) |
7450 | 692 )))) |
3235 | 693 |
694 | |
695 ;; ====================================================================== | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
696 ;; Man mode commands |
3235 | 697 |
698 (defun Man-next-section (n) | |
699 "Move point to Nth next section (default 1)." | |
700 (interactive "p") | |
7450 | 701 (let ((case-fold-search nil)) |
702 (if (looking-at Man-heading-regexp) | |
703 (forward-line 1)) | |
704 (if (re-search-forward Man-heading-regexp (point-max) t n) | |
705 (beginning-of-line) | |
706 (goto-char (point-max))))) | |
3235 | 707 |
708 (defun Man-previous-section (n) | |
709 "Move point to Nth previous section (default 1)." | |
710 (interactive "p") | |
7450 | 711 (let ((case-fold-search nil)) |
712 (if (looking-at Man-heading-regexp) | |
713 (forward-line -1)) | |
714 (if (re-search-backward Man-heading-regexp (point-min) t n) | |
715 (beginning-of-line) | |
716 (goto-char (point-min))))) | |
3235 | 717 |
718 (defun Man-find-section (section) | |
719 "Move point to SECTION if it exists, otherwise don't move point. | |
720 Returns t if section is found, nil otherwise." | |
7450 | 721 (let ((curpos (point)) |
722 (case-fold-search nil)) | |
3235 | 723 (goto-char (point-min)) |
7450 | 724 (if (re-search-forward (concat "^[ \t]*" section) (point-max) t) |
3235 | 725 (progn (beginning-of-line) t) |
726 (goto-char curpos) | |
727 nil) | |
728 )) | |
729 | |
730 (defun Man-goto-section () | |
731 "Query for section to move point to." | |
732 (interactive) | |
733 (aput 'Man-sections-alist | |
734 (let* ((default (aheadsym Man-sections-alist)) | |
735 (completion-ignore-case t) | |
736 chosen | |
737 (prompt (concat "Go to section: (default " default ") "))) | |
738 (setq chosen (completing-read prompt Man-sections-alist)) | |
739 (if (or (not chosen) | |
740 (string= chosen "")) | |
741 default | |
742 chosen))) | |
743 (Man-find-section (aheadsym Man-sections-alist))) | |
744 | |
745 (defun Man-goto-see-also-section () | |
746 "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
|
747 Actually the section moved to is described by `Man-see-also-regexp'." |
3235 | 748 (interactive) |
749 (if (not (Man-find-section Man-see-also-regexp)) | |
750 (error (concat "No " Man-see-also-regexp | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
751 " section found in current manpage")))) |
3235 | 752 |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
753 (defun Man-follow-manual-reference (arg reference) |
3235 | 754 "Get one of the manpages referred to in the \"SEE ALSO\" section. |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
755 Specify which reference to use; default is based on word at point. |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
756 Prefix argument ARG is passed to `Man-getpage-in-background'." |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
757 (interactive |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
758 (if (not Man-refpages-alist) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
759 (error "No references in current man page") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
760 (list current-prefix-arg |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
761 (let* ((default (or |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
762 (car (all-completions |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
763 (save-excursion |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
764 (skip-syntax-backward "w()") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
765 (skip-chars-forward " \t") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
766 (let ((word (current-word))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
767 ;; strip a trailing '-': |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
768 (if (string-match "-$" word) |
7450 | 769 (substring word 0 |
770 (match-beginning 0)) | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
771 word))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
772 Man-refpages-alist)) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
773 (aheadsym Man-refpages-alist))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
774 chosen |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
775 (prompt (concat "Refer to: (default " default ") "))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
776 (setq chosen (completing-read prompt Man-refpages-alist nil t)) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
777 (if (or (not chosen) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
778 (string= chosen "")) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
779 default |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
780 chosen))))) |
3235 | 781 (if (not Man-refpages-alist) |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
782 (error "No references found in current manpage") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
783 (aput 'Man-refpages-alist reference) |
3235 | 784 (Man-getpage-in-background |
785 (Man-translate-references (aheadsym Man-refpages-alist)) | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
786 arg))) |
3235 | 787 |
788 (defun Man-quit () | |
789 "Kill the buffer containing the manpage." | |
790 (interactive) | |
791 (let ((buff (current-buffer))) | |
792 (delete-windows-on buff) | |
793 (kill-buffer buff))) | |
794 | |
795 (defun Man-goto-page (page) | |
796 "Go to the manual page on page PAGE." | |
797 (interactive | |
7450 | 798 (if (= (length Man-page-list) 1) |
3235 | 799 (error "You're looking at the only manpage in the buffer.") |
7450 | 800 (list (read-minibuffer (format "Go to manpage [1-%d]: " |
801 (length Man-page-list)))))) | |
3235 | 802 (if (or (< page 1) |
803 (> page (length Man-page-list))) | |
804 (error "No manpage %d found" page)) | |
805 (let* ((page-range (nth (1- page) Man-page-list)) | |
806 (page-start (car page-range)) | |
807 (page-end (cdr page-range))) | |
808 (setq Man-current-page page | |
809 Man-page-mode-string (Man-page-mode-string)) | |
810 (widen) | |
811 (goto-char page-start) | |
812 (narrow-to-region page-start page-end) | |
813 (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
|
814 ;; 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
|
815 ;; 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
|
816 (condition-case nil |
296caa999ccf
(Man-filter-list): Add an element for X man pages.
Richard M. Stallman <rms@gnu.org>
parents:
3644
diff
changeset
|
817 (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
|
818 (error)) |
3235 | 819 (widen) |
820 (narrow-to-region page-start page-end) | |
821 (goto-char (point-min)))) | |
822 | |
823 | |
824 (defun Man-next-manpage () | |
825 "Find the next manpage entry in the buffer." | |
826 (interactive) | |
827 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
828 (error "This is the only manpage in the buffer")) |
3235 | 829 (if (< Man-current-page (length Man-page-list)) |
830 (Man-goto-page (1+ Man-current-page)) | |
831 (if Man-circular-pages-p | |
832 (Man-goto-page 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
833 (error "You're looking at the last manpage in the buffer")))) |
3235 | 834 |
835 (defun Man-previous-manpage () | |
836 "Find the previous manpage entry in the buffer." | |
837 (interactive) | |
838 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
839 (error "This is the only manpage in the buffer")) |
3235 | 840 (if (> Man-current-page 1) |
841 (Man-goto-page (1- Man-current-page)) | |
842 (if Man-circular-pages-p | |
843 (Man-goto-page (length Man-page-list)) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
844 (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
|
845 |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
846 (provide 'man) |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
847 |
3235 | 848 ;;; man.el ends here |