Mercurial > emacs
annotate lisp/man.el @ 9023:1f1081c31047
Initial revision
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 23 Sep 1994 18:35:06 +0000 |
parents | bfe446409b77 |
children | 5c7bf3247185 |
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> | |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
6 ;; Last-Modified: $Date: 1994/09/21 16:15:42 $ |
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
7 ;; Version: $Revision: 1.48 $ |
3235 | 8 ;; Keywords: help |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
9 ;; Adapted-By: ESR, pot |
3235 | 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 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
29 ;; This code provides a function, `man', with which you can browse |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
30 ;; UNIX manual pages. Formatting is done in background so that you |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
31 ;; can continue to use your Emacs while processing is going on. |
3235 | 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 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
41 ;; to incorporate them into a single manual browsing mode. While |
3235 | 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 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
59 ;; Francesco Potorti` <pot@cnuce.cnr.it> cleaned it up thoroughly, |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
60 ;; making it faster, more robust and more tolerant of different |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
61 ;; systems' man idiosynchrasies. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
62 |
3235 | 63 ;; ========== Features ========== |
64 ;; + Runs "man" in the background and pipes the results through a | |
65 ;; series of sed and awk scripts so that all retrieving and cleaning | |
66 ;; is done in the background. The cleaning commands are configurable. | |
67 ;; + Syntax is the same as Un*x man | |
68 ;; + 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
|
69 ;; "man <section>", etc. |
3235 | 70 ;; + Provides a manual browsing mode with keybindings for traversing |
71 ;; the sections of a manpage, following references in the SEE ALSO | |
72 ;; section, and more. | |
73 ;; + Multiple manpages created with the same man command are put into | |
74 ;; a narrowed buffer circular list. | |
75 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
76 ;; ============= TODO =========== |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
77 ;; - Add a command for printing. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
78 ;; - The awk script deletes multiple blank lines. This behaviour does |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
79 ;; not allow to understand if there was indeed a blank line at the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
80 ;; end or beginning of a page (after the header, or before the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
81 ;; footer). A different algorithm should be used. It is easy to |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
82 ;; compute how many blank lines there are before and after the page |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
83 ;; headers, and after the page footer. But it is possible to compute |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
84 ;; the number of blank lines before the page footer by euristhics |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
85 ;; only. Is it worth doing? |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
86 ;; - Allow the Man-reuse-okay-flag to be set to 'always, meaning that all |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
87 ;; the manpages should go in the same buffer, where they can be browsed |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
88 ;; with M-n and M-p. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
89 ;; - Allow completion on the manpage name when calling man. This |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
90 ;; requires a reliable list of places where manpages can be found. The |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
91 ;; drawback would be that if the list is not complete, the user might |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
92 ;; be led to believe that the manpages in the missing directories do |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
93 ;; not exist. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
94 |
3235 | 95 ;;; Code: |
96 | |
97 (require 'assoc) | |
98 | |
99 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | |
100 ;; user variables | |
101 | |
6676
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
102 (defvar manual-program "man" |
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
103 "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
|
104 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
105 ;; Use the value of the obsolete user option Man-notify, if set. |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
106 (defvar Man-notify-method (if (boundp 'Man-notify) Man-notify 'friendly) |
3235 | 107 "*Selects the behavior when manpage is ready. |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
108 This variable may have one of the following values, where (sf) means |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
109 that the frames are switched, so the manpage is displayed in the frame |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
110 where the man command was called from: |
3235 | 111 |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
112 newframe -- put the manpage in its own frame (see `Man-frame-parameters') |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
113 pushy -- make the manpage the current buffer in the current window |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
114 bully -- make the manpage the current buffer and only window (sf) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
115 aggressive -- make the manpage the current buffer in the other window (sf) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
116 friendly -- display manpage in the other window but don't make current (sf) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
117 polite -- don't display manpage, but prints message and beep when ready |
3235 | 118 quiet -- like `polite', but don't beep |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
119 meek -- make no indication that the manpage is ready |
3235 | 120 |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
121 Any other value of `Man-notify-method' is equivalent to `meek'.") |
3235 | 122 |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
123 (defvar Man-frame-parameters nil |
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
124 "*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
|
125 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
126 (defvar Man-reuse-okay-flag t |
3235 | 127 "*Reuse a manpage buffer if possible. |
7450 | 128 If non-nil, and a manpage buffer already exists with the same |
129 invocation, man just indicates the manpage is ready according to the | |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
130 value of `Man-notify-method'. When nil, it always fires off a |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
131 background process,putting the results in a uniquely named buffer.") |
3235 | 132 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
133 (defvar Man-downcase-section-letters-flag t |
3235 | 134 "*Letters in sections are converted to lower case. |
135 Some Un*x man commands can't handle uppercase letters in sections, for | |
136 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
|
137 with the upper case letter. When this variable is t, the section |
3235 | 138 letter (e.g., \"2V\") is converted to lowercase (e.g., \"2v\") before |
139 being sent to the man background process.") | |
140 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
141 (defvar Man-circular-pages-flag t |
3235 | 142 "*If t, the manpage list is treated as circular for traversal.") |
143 | |
144 (defvar Man-section-translations-alist | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
145 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
146 '("3C++" . "3") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
147 ;; Some systems have a real 3x man section, so let's comment this. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
148 ;; '("3X" . "3") ; Xlib man pages |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
149 '("3X11" . "3") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
150 '("1-UCB" . "")) |
3235 | 151 "*Association list of bogus sections to real section numbers. |
152 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
|
153 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
|
154 association list is used to translate those sections, when found, to |
3235 | 155 the associated section number.") |
156 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
157 (defvar Man-untabify-command "pr" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
158 "*Command used for untabifying.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
159 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
160 (defvar Man-untabify-command-args (list "-t" "-e") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
161 "*List of arguments to be passed to Man-untabify-command (which see).") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
162 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
163 (defvar Man-sed-command "sed" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
164 "*Command used for processing sed scripts.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
165 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
166 (defvar Man-awk-command "awk" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
167 "*Command used for processing awk scripts.") |
3235 | 168 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
169 (defconst Man-sysv-sed-script "\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
170 /\b/ { s/_\b//g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
171 s/\b_//g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
172 s/o\b+/o/g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
173 :ovstrk |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
174 s/\\(.\\)\b\\1/\\1/g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
175 t ovstrk |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
176 } |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
177 /\e\\[[0-9][0-9]*m/ s///g" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
178 "Script for sysV-like sed to nuke backspaces and ANSI codes from manpages.") |
3235 | 179 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
180 (defconst Man-berkeley-sed-script "\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
181 /\b/ { s/_\b//g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
182 s/\b_//g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
183 s/o\b+/o/g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
184 :ovstrk\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
185 s/\\(.\\)\b\\1/\\1/g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
186 t ovstrk\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
187 }\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
188 /\e\\[[0-9][0-9]*m/ s///g" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
189 "Script for berkeley-like sed to nuke backspaces and ANSI codes from manpages.") |
3235 | 190 |
191 (defvar Man-mode-line-format | |
192 '("" mode-line-modified | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
193 mode-line-buffer-identification " " |
3235 | 194 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
|
195 " " Man-page-mode-string |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
196 " %[(" mode-name mode-line-process minor-mode-alist ")%]----" |
3235 | 197 (-3 . "%p") "-%-") |
198 "*Mode line format for manual mode buffer.") | |
199 | |
200 (defvar Man-mode-map nil | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
201 "*Keymap for Man mode.") |
3235 | 202 |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
203 (defvar Man-mode-hook nil |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
204 "*Hook run when Man mode is enabled.") |
3235 | 205 |
6358
250e69a75938
(Man-filter-list): Extend footer pattern for hpux.
Karl Heuer <kwzh@gnu.org>
parents:
6353
diff
changeset
|
206 (defvar Man-cooked-hook nil |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
207 "*Hook run after removing backspaces but before Man-mode processing.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
208 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
209 (defvar Man-name-regexp "[-a-zA-Z0-9_][-a-zA-Z0-9_.]*" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
210 "*Regular expression describing the name of a manpage (without section).") |
6358
250e69a75938
(Man-filter-list): Extend footer pattern for hpux.
Karl Heuer <kwzh@gnu.org>
parents:
6353
diff
changeset
|
211 |
4980
50708e8b133b
(Man-section-regexp): Allow section names l, n, L, N.
Richard M. Stallman <rms@gnu.org>
parents:
4968
diff
changeset
|
212 (defvar Man-section-regexp "[0-9][a-zA-Z+]*\\|[LNln]" |
3235 | 213 "*Regular expression describing a manpage section within parentheses.") |
214 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
215 (defvar Man-page-header-regexp |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
216 (concat "^[ \t]*\\(" Man-name-regexp |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
217 "(\\(" Man-section-regexp "\\))\\).*\\1") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
218 "*Regular expression describing the heading of a page.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
219 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
220 (defvar Man-heading-regexp "^\\([A-Z][A-Z ]+\\)$" |
3235 | 221 "*Regular expression describing a manpage heading entry.") |
222 | |
223 (defvar Man-see-also-regexp "SEE ALSO" | |
224 "*Regular expression for SEE ALSO heading (or your equivalent). | |
225 This regexp should not start with a `^' character.") | |
226 | |
7450 | 227 (defvar Man-first-heading-regexp "^[ \t]*NAME$\\|^[ \t]*No manual entry fo.*$" |
3235 | 228 "*Regular expression describing first heading on a manpage. |
229 This regular expression should start with a `^' character.") | |
230 | |
4377
09cb5e07f8a3
(Man-build-references-alist): When setting word,
Richard M. Stallman <rms@gnu.org>
parents:
4334
diff
changeset
|
231 (defvar Man-reference-regexp |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
232 (concat "\\(" Man-name-regexp "\\)(\\(" Man-section-regexp "\\))") |
3235 | 233 "*Regular expression describing a reference in the SEE ALSO section.") |
234 | |
3833
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
235 (defvar Man-switches "" |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
236 "*Switches passed to the man command, as a single string.") |
3235 | 237 |
5108
8c482171bb10
(Man-specified-section-option): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4980
diff
changeset
|
238 ;; 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
|
239 ;; 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
|
240 ;; 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
|
241 (defvar Man-specified-section-option |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
242 (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
|
243 "-s" |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
244 "") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
245 "*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
|
246 |
3235 | 247 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
248 ;; end user variables | |
249 | |
250 ;; other variables and keymap initializations | |
251 (make-variable-buffer-local 'Man-sections-alist) | |
252 (make-variable-buffer-local 'Man-refpages-alist) | |
253 (make-variable-buffer-local 'Man-page-list) | |
254 (make-variable-buffer-local 'Man-current-page) | |
255 (make-variable-buffer-local 'Man-page-mode-string) | |
6363
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
256 (make-variable-buffer-local 'Man-original-frame) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
257 (make-variable-buffer-local 'Man-arguments) |
3235 | 258 |
259 (setq-default Man-sections-alist nil) | |
260 (setq-default Man-refpages-alist nil) | |
261 (setq-default Man-page-list nil) | |
262 (setq-default Man-current-page 0) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
263 (setq-default Man-page-mode-string "1 of 1") |
3235 | 264 |
265 (if Man-mode-map | |
266 nil | |
267 (setq Man-mode-map (make-keymap)) | |
268 (suppress-keymap Man-mode-map) | |
269 (define-key Man-mode-map " " 'scroll-up) | |
270 (define-key Man-mode-map "\177" 'scroll-down) | |
271 (define-key Man-mode-map "n" 'Man-next-section) | |
272 (define-key Man-mode-map "p" 'Man-previous-section) | |
273 (define-key Man-mode-map "\en" 'Man-next-manpage) | |
274 (define-key Man-mode-map "\ep" 'Man-previous-manpage) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
275 (define-key Man-mode-map ">" 'end-of-buffer) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
276 (define-key Man-mode-map "<" 'beginning-of-buffer) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
277 (define-key Man-mode-map "." 'beginning-of-buffer) |
3235 | 278 (define-key Man-mode-map "r" 'Man-follow-manual-reference) |
279 (define-key Man-mode-map "t" 'toggle-truncate-lines) | |
280 (define-key Man-mode-map "g" 'Man-goto-section) | |
281 (define-key Man-mode-map "s" 'Man-goto-see-also-section) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
282 (define-key Man-mode-map "k" 'Man-kill) |
3235 | 283 (define-key Man-mode-map "q" 'Man-quit) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
284 (define-key Man-mode-map "m" 'man) |
3235 | 285 (define-key Man-mode-map "?" 'describe-mode) |
286 ) | |
287 | |
288 | |
289 ;; ====================================================================== | |
290 ;; utilities | |
291 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
292 (defsubst Man-init-defvars () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
293 "Used for initialising variables based on the value of window-system. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
294 This is necessary if one wants to dump man.el with emacs." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
295 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
296 (defvar Man-fontify-manpage-flag t |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
297 "*Make up the manpage with fonts.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
298 ;; The following is necessary until fonts are implemented on |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
299 ;; terminals. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
300 (setq Man-fontify-manpage-flag (and Man-fontify-manpage-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
301 window-system)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
302 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
303 (defconst Man-uses-untabify-flag t |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
304 ;; don't use pr: it is buggy |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
305 ;; (or (not (file-readable-p "/etc/passwd")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
306 ;; (/= 0 (apply 'call-process |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
307 ;; Man-untabify-command nil nil nil |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
308 ;; (append Man-untabify-command-args |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
309 ;; (list "/etc/passwd"))))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
310 "Use `untabify', because Man-untabify-command cannot do that.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
311 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
312 (defconst Man-sed-script |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
313 (cond |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
314 (Man-fontify-manpage-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
315 nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
316 ((= 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
317 Man-sysv-sed-script) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
318 ((= 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
319 Man-berkeley-sed-script) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
320 (t |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
321 nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
322 "Script for sed to nuke backspaces and ANSI codes from manpages.") |
3235 | 323 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
324 (defvar Man-filter-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
325 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
326 (cons |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
327 Man-sed-command |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
328 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
329 (if Man-sed-script |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
330 (concat "-e '" Man-sed-script "'") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
331 "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
332 "-e '/\e[789]/s///g'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
333 "-e '/o\b+/s//o/g'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
334 "-e '/^\\n$/D'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
335 "-e '/[Nn]o such file or directory/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
336 "-e '/Reformatting page. Wait/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
337 "-e '/Reformatting entry. Wait/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
338 "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
339 "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
340 "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
341 "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
342 "-e '/^Printed[ \t][0-9].*[0-9]$/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
343 "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
344 "-e '/^[A-za-z].*Last[ \t]change:/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
345 "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
346 )) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
347 (cons |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
348 Man-awk-command |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
349 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
350 "'\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
351 "BEGIN { blankline=0; anonblank=0; }\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
352 "/^$/ { if (anonblank==0) next; }\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
353 "{ anonblank=1; }\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
354 "/^$/ { blankline++; next; }\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
355 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
356 "'" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
357 )) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
358 (if (not Man-uses-untabify-flag) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
359 (cons |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
360 Man-untabify-command |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
361 Man-untabify-command-args) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
362 )) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
363 "*Manpage cleaning filter command phrases. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
364 This variable contains a list of the following form: |
3235 | 365 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
366 '((command-string phrase-string*)*) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
367 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
368 Each phrase-string is concatenated onto the command-string to form a |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
369 command filter. The (standard) output (and standard error) of the Un*x |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
370 man command is piped through each command filter in the order the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
371 commands appear in the association list. The final output is placed in |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
372 the manpage buffer.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
373 ) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
374 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
375 (defsubst Man-make-page-mode-string () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
376 "Formats part of the mode line for Man mode." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
377 (format "%s page %d of %d" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
378 (or (nth 2 (nth (1- Man-current-page) Man-page-list)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
379 "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
380 Man-current-page |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
381 (length Man-page-list))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
382 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
383 (defsubst Man-build-man-command () |
3235 | 384 "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
|
385 (let ((command (concat manual-program " " Man-switches " %s 2>/dev/null")) |
3235 | 386 (flist Man-filter-list)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
387 (while (and flist (car flist)) |
3235 | 388 (let ((pcom (car (car flist))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
389 (pargs (cdr (car flist)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
390 (setq command |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
391 (concat command " | " pcom " " |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
392 (mapconcat '(lambda (phrase) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
393 (if (not (stringp phrase)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
394 (error "Malformed Man-filter-list")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
395 phrase) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
396 pargs " "))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
397 (setq flist (cdr flist)))) |
3235 | 398 command)) |
399 | |
400 (defun Man-translate-references (ref) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
401 "Translates REF from \"chmod(2V)\" to \"2v chmod\" style. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
402 Leave it as is if already in that style. Possibly downcase and |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
403 translate the section (see the Man-downcase-section-letters-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
404 and the Man-section-translations-alist variables)." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
405 (let ((name "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
406 (section "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
407 (slist Man-section-translations-alist)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
408 (cond |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
409 ;; "chmod(2V)" case ? |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
410 ((string-match (concat Man-reference-regexp "$") ref) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
411 (setq name (Man-match-substring 1 ref) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
412 section (Man-match-substring 2 ref))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
413 ;; "2v chmod" case ? |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
414 ((string-match (concat "\\(" Man-section-regexp |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
415 "\\) +\\(" Man-name-regexp "\\)$") ref) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
416 (setq name (Man-match-substring 2 ref) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
417 section (Man-match-substring 1 ref)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
418 (if (string= name "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
419 ref ; Return the reference as is |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
420 (if Man-downcase-section-letters-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
421 (setq section (downcase section))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
422 (while slist |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
423 (let ((s1 (car (car slist))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
424 (s2 (cdr (car slist)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
425 (setq slist (cdr slist)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
426 (if Man-downcase-section-letters-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
427 (setq s1 (downcase s1))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
428 (if (not (string= s1 section)) nil |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
429 (setq section (if Man-downcase-section-letters-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
430 (downcase s2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
431 s2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
432 slist nil)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
433 (concat Man-specified-section-option section " " name)))) |
3235 | 434 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
435 (defsubst Man-match-substring (&optional n string) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
436 "Return the substring matched by the last search. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
437 Optional arg N means return the substring matched by the Nth paren |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
438 grouping. Optinal second arg STRING means return a substring from |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
439 that string instead of from the current buffer." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
440 (if (null n) (setq n 0)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
441 (if string |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
442 (substring string (match-beginning n) (match-end n)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
443 (buffer-substring (match-beginning n) (match-end n)))) |
3235 | 444 |
445 | |
446 ;; ====================================================================== | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
447 ;; default man entry: get word under point |
3235 | 448 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
449 (defsubst Man-default-man-entry () |
3235 | 450 "Make a guess at a default manual entry. |
451 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
|
452 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
|
453 (let (default-title) |
3235 | 454 (save-excursion |
455 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
456 ;; Default man entry title is any word the cursor is on, or if |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
457 ;; cursor not on a word, then nearest preceding word. Cannot |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
458 ;; use the current-word function because it skips the dots. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
459 (if (not (looking-at "[-a-zA-Z_.]")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
460 (skip-chars-backward "^a-zA-Z")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
461 (skip-chars-backward "-(a-zA-Z_0-9_.") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
462 (if (looking-at "(") (forward-char 1)) |
3235 | 463 (setq default-title |
464 (buffer-substring | |
465 (point) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
466 (progn (skip-chars-forward "-a-zA-Z0-9_.") (point)))) |
3235 | 467 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
468 ;; If looking at something like ioctl(2) or brc(1M), include the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
469 ;; section number in the returned value. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
470 (concat |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
471 default-title |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
472 (if (looking-at |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
473 (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
474 (format "(%s)" (Man-match-substring 1))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
475 )))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
476 |
3235 | 477 |
478 ;; ====================================================================== | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
479 ;; Top level command and background process sentinel |
3235 | 480 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
481 ;; For compatibility with older versions. |
4444 | 482 ;;;###autoload |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
483 (defalias 'manual-entry 'man) |
4444 | 484 |
3235 | 485 ;;;###autoload |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
486 (defun man (man-args prefix-arg) |
3235 | 487 "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
|
488 This command is the top-level command in the man package. It runs a Un*x |
3235 | 489 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
|
490 results in a Man mode (manpage browsing) buffer. See variable |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
491 `Man-notify-method' 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
|
492 Normally, if a buffer already exists for this man page, it will display |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
493 immediately; either a prefix argument or a nil value to `Man-reuse-okay-flag' |
6373
284634d109ee
(manual-entry): Document what the arg does.
Karl Heuer <kwzh@gnu.org>
parents:
6363
diff
changeset
|
494 overrides this and forces the man page to be regenerated." |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
495 (interactive |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
496 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
497 ;; first argument |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
498 (let* ((default-entry (Man-default-man-entry)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
499 (input (read-string |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
500 (format "Manual entry%s: " |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
501 (if (string= default-entry "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
502 "" |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
503 (format " (default %s)" default-entry)))))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
504 (if (string= input "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
505 (if (string= default-entry "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
506 (error "No man args given") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
507 default-entry) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
508 input)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
509 ;; second argument |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
510 current-prefix-arg)) |
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
|
511 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
512 ;; Init the man package variables, if not already done. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
513 (Man-init-defvars) |
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
|
514 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
515 ;; Possibly translate the "subject(section)" syntax into the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
516 ;; "section subject" syntax and possibly downcase the section. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
517 (setq man-args (Man-translate-references man-args)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
518 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
519 (Man-getpage-in-background man-args (consp prefix-arg))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
520 |
3235 | 521 |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
522 (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
|
523 "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
|
524 Optional OVERRIDE-REUSE-P, when non-nil, means to |
3235 | 525 start a background process even if a buffer already exists and |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
526 `Man-reuse-okay-flag' is non-nil." |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
527 (let* ((man-args topic) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
528 (bufname (concat "*man " man-args "*")) |
3235 | 529 (buffer (get-buffer bufname))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
530 (if (and Man-reuse-okay-flag |
3235 | 531 (not override-reuse-p) |
532 buffer) | |
533 (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
|
534 (require 'env) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
535 (message "Invoking %s %s in the background" manual-program man-args) |
3235 | 536 (setq buffer (generate-new-buffer bufname)) |
6363
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
537 (save-excursion |
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
538 (set-buffer buffer) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
539 (setq Man-original-frame (selected-frame)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
540 (setq Man-arguments man-args)) |
4175
3e4fa4423f5a
(Man-getpage-in-background): Copy process-environment
Richard M. Stallman <rms@gnu.org>
parents:
4009
diff
changeset
|
541 (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
|
542 ;; 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
|
543 (setenv "TERM" "dumb") |
c77a3da2d08d
(Man-getpage-in-background): Use TERM=dumb to prevent
Richard M. Stallman <rms@gnu.org>
parents:
3659
diff
changeset
|
544 (set-process-sentinel |
6676
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
545 (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
|
546 (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
|
547 'Man-bgproc-sentinel)) |
7450 | 548 ))) |
3235 | 549 |
550 (defun Man-notify-when-ready (man-buffer) | |
551 "Notify the user when MAN-BUFFER is ready. | |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
552 See the variable `Man-notify-method' 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
|
553 (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
|
554 (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
|
555 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
|
556 (cond |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
557 ((eq Man-notify-method 'newframe) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
558 ;; Since we run asynchronously, perhaps while Emacs is waiting |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
559 ;; for input, we must not leave a different buffer current. We |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
560 ;; can't rely on the editor command loop to reselect the |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
561 ;; selected window's buffer. |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
562 (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
|
563 (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
|
564 (make-frame Man-frame-parameters))) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
565 ((eq Man-notify-method 'pushy) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
566 (switch-to-buffer man-buffer)) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
567 ((eq Man-notify-method 'bully) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
568 (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
|
569 (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
|
570 (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
|
571 (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
|
572 (delete-other-windows)) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
573 ((eq Man-notify-method 'aggressive) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
574 (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
|
575 (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
|
576 (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
|
577 (pop-to-buffer man-buffer)) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
578 ((eq Man-notify-method 'friendly) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
579 (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
|
580 (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
|
581 (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
|
582 (display-buffer man-buffer 'not-this-window)) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
583 ((eq Man-notify-method 'polite) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
584 (beep) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
585 (message "Manual buffer %s is ready" (buffer-name man-buffer))) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
586 ((eq Man-notify-method 'quiet) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
587 (message "Manual buffer %s is ready" (buffer-name man-buffer))) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
588 ((or (eq Man-notify-method 'meek) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
589 t) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
590 (message "")) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
591 ))) |
3235 | 592 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
593 (defun Man-fontify-manpage () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
594 "Convert overstriking and underlining to the correct fonts. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
595 Same for the ANSI bold and normal escape sequences." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
596 (interactive) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
597 (message "Please wait: making up the %s man page..." Man-arguments) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
598 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
599 (while (search-forward "\e[1m" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
600 (delete-backward-char 4) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
601 (put-text-property (point) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
602 (progn (if (search-forward "\e[0m" nil 'move) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
603 (delete-backward-char 4)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
604 (point)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
605 'face 'bold)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
606 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
607 (while (search-forward "_\b" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
608 (backward-delete-char 2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
609 (put-text-property (point) (1+ (point)) 'face 'underline)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
610 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
611 (while (search-forward "\b_" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
612 (backward-delete-char 2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
613 (put-text-property (1- (point)) (point) 'face 'underline)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
614 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
615 (while (re-search-forward "\e[789]" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
616 (backward-delete-char 2)) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
617 (goto-char (point-min)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
618 (while (search-forward "o\b+" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
619 (backward-delete-char 2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
620 (put-text-property (1- (point)) (point) 'face 'bold)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
621 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
622 (while (re-search-forward "\\(.\\)\\(\b\\1\\)+" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
623 (replace-match "\\1") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
624 (put-text-property (1- (point)) (point) 'face 'bold)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
625 (message "%s man page made up" Man-arguments)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
626 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
627 (defun Man-cleanup-manpage () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
628 "Remove overstriking and underlining from the current buffer." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
629 (interactive) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
630 (message "Please wait: cleaning up the %s man page..." Man-arguments) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
631 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
632 (while (re-search-forward "\e\\[[0-9]+m" nil t) (replace-match "")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
633 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
634 (while (search-forward "_\b" nil t) (backward-delete-char 2)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
635 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
636 (while (search-forward "\b_" nil t) (backward-delete-char 2)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
637 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
638 (while (re-search-forward "\e[789]" nil t) (backward-delete-char 2)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
639 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
640 (while (search-forward "o\b+" nil t) (backward-delete-char 2)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
641 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
642 (while (re-search-forward "\\(.\\)\\(\b\\1\\)+" nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
643 (replace-match "\\1")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
644 (message "%s man page cleaned up" Man-arguments)) |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
645 |
3235 | 646 (defun Man-bgproc-sentinel (process msg) |
647 "Manpage background process sentinel." | |
648 (let ((Man-buffer (process-buffer process)) | |
649 (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
|
650 (err-mess nil)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
651 |
3235 | 652 (if (null (buffer-name Man-buffer)) ;; deleted buffer |
653 (set-process-buffer process nil) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
654 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
655 (save-excursion |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
656 (set-buffer Man-buffer) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
657 (save-match-data |
8190
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
658 (let ((case-fold-search nil)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
659 (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
|
660 (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
|
661 (looking-at "[^\n]*: nothing appropriate$")) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
662 (setq err-mess (buffer-substring (point) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
663 (progn |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
664 (end-of-line) (point))) |
8190
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
665 delete-buff t)) |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
666 ((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
|
667 (= (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
|
668 (setq err-mess |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
669 (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
|
670 ": process " |
04aa77218846
(Man-bgproc-sentinel): Bind case-fold-search for just the
Richard M. Stallman <rms@gnu.org>
parents:
7518
diff
changeset
|
671 (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
|
672 (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
|
673 (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
|
674 (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
|
675 (insert (format "\nprocess %s" msg)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
676 )) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
677 (if delete-buff |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
678 (kill-buffer Man-buffer) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
679 (if Man-fontify-manpage-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
680 (Man-fontify-manpage) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
681 (if (not Man-sed-script) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
682 (Man-cleanup-manpage))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
683 (run-hooks 'Man-cooked-hook) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
684 (Man-mode) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
685 (set-buffer-modified-p nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
686 )) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
687 ;; Restore case-fold-search before calling |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
688 ;; Man-notify-when-ready because it may switch buffers. |
3235 | 689 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
690 (if (not delete-buff) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
691 (Man-notify-when-ready Man-buffer)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
692 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
693 (if err-mess |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
694 (error err-mess)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
695 ))))) |
3235 | 696 |
697 | |
698 ;; ====================================================================== | |
699 ;; set up manual mode in buffer and build alists | |
700 | |
701 (defun Man-mode () | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
702 "A mode for browsing Un*x manual pages. |
3235 | 703 |
704 The following man commands are available in the buffer. Try | |
705 \"\\[describe-key] <key> RET\" for more information: | |
706 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
707 \\[man] Prompt to retrieve a new manpage. |
3235 | 708 \\[Man-follow-manual-reference] Retrieve reference in SEE ALSO section. |
709 \\[Man-next-manpage] Jump to next manpage in circular list. | |
710 \\[Man-previous-manpage] Jump to previous manpage in circular list. | |
711 \\[Man-next-section] Jump to next manpage section. | |
712 \\[Man-previous-section] Jump to previous manpage section. | |
713 \\[Man-goto-section] Go to a manpage section. | |
714 \\[Man-goto-see-also-section] Jumps to the SEE ALSO manpage section. | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
715 \\[Man-quit] Deletes the manpage window, bury its buffer. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
716 \\[Man-kill] Deletes the manpage window, kill its buffer. |
3235 | 717 \\[describe-mode] Prints this help text. |
718 | |
719 The following variables may be of some use. Try | |
720 \"\\[describe-variable] <variable-name> RET\" for more information: | |
721 | |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
722 Man-notify-method What happens when manpage formatting is done. |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
723 Man-reuse-okay-flag Reuse already formatted buffer. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
724 Man-downcase-section-letters-flag Force section letters to lower case. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
725 Man-circular-pages-flag Treat multiple manpage list as circular. |
3235 | 726 Man-auto-section-alist List of major modes and their section numbers. |
727 Man-section-translations-alist List of section numbers and their Un*x equiv. | |
728 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
|
729 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
|
730 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
|
731 Man-mode-hook Normal hook run on entry to Man mode. |
3235 | 732 Man-section-regexp Regexp describing manpage section letters. |
733 Man-heading-regexp Regexp describing section headers. | |
734 Man-see-also-regexp Regexp for SEE ALSO section (or your equiv). | |
735 Man-first-heading-regexp Regexp for first heading on a manpage. | |
736 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
|
737 Man-switches Background `man' command switches. |
3235 | 738 |
739 The following key bindings are currently in effect in the buffer: | |
740 \\{Man-mode-map}" | |
741 (interactive) | |
742 (setq major-mode 'Man-mode | |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
743 mode-name "Man" |
3235 | 744 buffer-auto-save-file-name nil |
745 mode-line-format Man-mode-line-format | |
746 truncate-lines t | |
747 buffer-read-only t) | |
748 (buffer-disable-undo (current-buffer)) | |
749 (auto-fill-mode -1) | |
750 (use-local-map Man-mode-map) | |
751 (Man-build-page-list) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
752 (Man-strip-page-headers) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
753 (Man-unindent) |
3619
062dbb10173d
(Man-mode): Run Man-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
754 (Man-goto-page 1) |
062dbb10173d
(Man-mode): Run Man-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
755 (run-hooks 'Man-mode-hook)) |
3235 | 756 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
757 (defsubst Man-build-section-alist () |
3235 | 758 "Build the association list of manpage sections." |
759 (setq Man-sections-alist nil) | |
760 (goto-char (point-min)) | |
7450 | 761 (let ((case-fold-search nil)) |
762 (while (re-search-forward Man-heading-regexp (point-max) t) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
763 (aput 'Man-sections-alist (Man-match-substring 1)) |
7450 | 764 (forward-line 1)))) |
3235 | 765 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
766 (defsubst Man-build-references-alist () |
3235 | 767 "Build the association list of references (in the SEE ALSO section)." |
768 (setq Man-refpages-alist nil) | |
769 (save-excursion | |
770 (if (Man-find-section Man-see-also-regexp) | |
771 (let ((start (progn (forward-line 1) (point))) | |
772 (end (progn | |
773 (Man-next-section 1) | |
774 (point))) | |
775 hyphenated | |
776 (runningpoint -1)) | |
7450 | 777 (save-restriction |
778 (narrow-to-region start end) | |
779 (goto-char (point-min)) | |
780 (back-to-indentation) | |
781 (while (and (not (eobp)) (/= (point) runningpoint)) | |
782 (setq runningpoint (point)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
783 (if (re-search-forward Man-reference-regexp end t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
784 (let* ((word (Man-match-substring 0)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
785 (len (1- (length word)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
786 (if hyphenated |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
787 (setq word (concat hyphenated word) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
788 hyphenated nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
789 (if (= (aref word len) ?-) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
790 (setq hyphenated (substring word 0 len)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
791 (aput 'Man-refpages-alist word)))) |
7450 | 792 (skip-chars-forward " \t\n,"))))))) |
3235 | 793 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
794 (defsubst Man-build-page-list () |
3235 | 795 "Build the list of separate manpages in the buffer." |
796 (setq Man-page-list nil) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
797 (let ((page-start (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
798 (page-end (point-max)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
799 (header "")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
800 (goto-char page-start) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
801 ;; (switch-to-buffer (current-buffer))(debug) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
802 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
803 (setq header |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
804 (if (looking-at Man-page-header-regexp) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
805 (Man-match-substring 1) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
806 nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
807 ;; Go past both the current and the next Man-first-heading-regexp |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
808 (if (re-search-forward Man-first-heading-regexp nil 'move 2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
809 (let ((p (progn (beginning-of-line) (point)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
810 ;; We assume that the page header is delimited by blank |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
811 ;; lines and that it contains at most one blank line. So |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
812 ;; if we back by three blank lines we will be sure to be |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
813 ;; before the page header but not before the possible |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
814 ;; previous page header. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
815 (search-backward "\n\n" nil t 3) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
816 (if (re-search-forward Man-page-header-regexp p 'move) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
817 (beginning-of-line)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
818 (setq page-end (point)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
819 (setq Man-page-list (append Man-page-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
820 (list (list (copy-marker page-start) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
821 (copy-marker page-end) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
822 header)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
823 (setq page-start page-end) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
824 ))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
825 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
826 (defsubst Man-strip-page-headers () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
827 "Strip all the page headers but the first from the manpage." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
828 (let ((buffer-read-only nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
829 (case-fold-search nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
830 (page-list Man-page-list) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
831 (page ()) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
832 (header "")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
833 (while page-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
834 (setq page (car page-list)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
835 (and (nth 2 page) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
836 (goto-char (car page)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
837 (re-search-forward Man-first-heading-regexp nil t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
838 (setq header (buffer-substring (car page) (match-beginning 0))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
839 ;; Since the awk script collapses all successive blank |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
840 ;; lines into one, and since we don't want to get rid of |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
841 ;; the fast awk script, one must choose between adding |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
842 ;; spare blank lines between pages when there were none and |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
843 ;; deleting blank lines at page boundaries when there were |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
844 ;; some. We choose the first, so we comment the following |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
845 ;; line. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
846 ;; (setq header (concat "\n" header))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
847 (while (search-forward header (nth 1 page) t) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
848 (replace-match ""))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
849 (setq page-list (cdr page-list))))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
850 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
851 (defsubst Man-unindent () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
852 "Delete the leading spaces that indent the manpage." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
853 (let ((buffer-read-only nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
854 (case-fold-search nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
855 (page-list Man-page-list)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
856 (while page-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
857 (let ((page (car page-list)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
858 (indent "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
859 (nindent 0)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
860 (narrow-to-region (car page) (car (cdr page))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
861 (if Man-uses-untabify-flag |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
862 (untabify (point-min) (point-max))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
863 (if (catch 'unindent |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
864 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
865 (if (not (re-search-forward Man-first-heading-regexp nil t)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
866 (throw 'unindent nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
867 (beginning-of-line) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
868 (setq indent (buffer-substring (point) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
869 (progn |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
870 (skip-chars-forward " ") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
871 (point)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
872 (setq nindent (length indent)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
873 (if (zerop nindent) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
874 (throw 'unindent nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
875 (setq indent (concat indent "\\|$")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
876 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
877 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
878 (if (looking-at indent) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
879 (forward-line 1) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
880 (throw 'unindent nil))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
881 (goto-char (point-min))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
882 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
883 (or (eolp) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
884 (delete-char nindent)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
885 (forward-line 1))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
886 (setq page-list (cdr page-list)) |
7450 | 887 )))) |
3235 | 888 |
889 | |
890 ;; ====================================================================== | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
891 ;; Man mode commands |
3235 | 892 |
893 (defun Man-next-section (n) | |
894 "Move point to Nth next section (default 1)." | |
895 (interactive "p") | |
7450 | 896 (let ((case-fold-search nil)) |
897 (if (looking-at Man-heading-regexp) | |
898 (forward-line 1)) | |
899 (if (re-search-forward Man-heading-regexp (point-max) t n) | |
900 (beginning-of-line) | |
901 (goto-char (point-max))))) | |
3235 | 902 |
903 (defun Man-previous-section (n) | |
904 "Move point to Nth previous section (default 1)." | |
905 (interactive "p") | |
7450 | 906 (let ((case-fold-search nil)) |
907 (if (looking-at Man-heading-regexp) | |
908 (forward-line -1)) | |
909 (if (re-search-backward Man-heading-regexp (point-min) t n) | |
910 (beginning-of-line) | |
911 (goto-char (point-min))))) | |
3235 | 912 |
913 (defun Man-find-section (section) | |
914 "Move point to SECTION if it exists, otherwise don't move point. | |
915 Returns t if section is found, nil otherwise." | |
7450 | 916 (let ((curpos (point)) |
917 (case-fold-search nil)) | |
3235 | 918 (goto-char (point-min)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
919 (if (re-search-forward (concat "^" section) (point-max) t) |
3235 | 920 (progn (beginning-of-line) t) |
921 (goto-char curpos) | |
922 nil) | |
923 )) | |
924 | |
925 (defun Man-goto-section () | |
926 "Query for section to move point to." | |
927 (interactive) | |
928 (aput 'Man-sections-alist | |
929 (let* ((default (aheadsym Man-sections-alist)) | |
930 (completion-ignore-case t) | |
931 chosen | |
932 (prompt (concat "Go to section: (default " default ") "))) | |
933 (setq chosen (completing-read prompt Man-sections-alist)) | |
934 (if (or (not chosen) | |
935 (string= chosen "")) | |
936 default | |
937 chosen))) | |
938 (Man-find-section (aheadsym Man-sections-alist))) | |
939 | |
940 (defun Man-goto-see-also-section () | |
941 "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
|
942 Actually the section moved to is described by `Man-see-also-regexp'." |
3235 | 943 (interactive) |
944 (if (not (Man-find-section Man-see-also-regexp)) | |
945 (error (concat "No " Man-see-also-regexp | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
946 " section found in the current manpage")))) |
3235 | 947 |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
948 (defun Man-follow-manual-reference (arg reference) |
3235 | 949 "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
|
950 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
|
951 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
|
952 (interactive |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
953 (if (not Man-refpages-alist) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
954 (error "There are no references in the current man page") |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
955 (list current-prefix-arg |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
956 (let* ((default (or |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
957 (car (all-completions |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
958 (save-excursion |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
959 (skip-syntax-backward "w()") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
960 (skip-chars-forward " \t") |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
961 (let ((word (current-word))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
962 ;; strip a trailing '-': |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
963 (if (string-match "-$" word) |
7450 | 964 (substring word 0 |
965 (match-beginning 0)) | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
966 word))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
967 Man-refpages-alist)) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
968 (aheadsym Man-refpages-alist))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
969 chosen |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
970 (prompt (concat "Refer to: (default " default ") "))) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
971 (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
|
972 (if (or (not chosen) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
973 (string= chosen "")) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
974 default |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
975 chosen))))) |
3235 | 976 (if (not Man-refpages-alist) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
977 (error "Can't find any references in the current manpage") |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
978 (aput 'Man-refpages-alist reference) |
3235 | 979 (Man-getpage-in-background |
980 (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
|
981 arg))) |
3235 | 982 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
983 (defun Man-kill () |
3235 | 984 "Kill the buffer containing the manpage." |
985 (interactive) | |
986 (let ((buff (current-buffer))) | |
987 (delete-windows-on buff) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
988 (kill-buffer buff)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
989 (if (and window-system |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
990 (or (eq Man-notify-method 'newframe) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
991 (and pop-up-frames |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
992 (eq Man-notify-method 'bully)))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
993 (delete-frame))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
994 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
995 (defun Man-quit () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
996 "Bury the buffer containing the manpage." |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
997 (interactive) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
998 (let ((buff (current-buffer))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
999 (delete-windows-on buff) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1000 (bury-buffer buff)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1001 (if (and window-system |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
1002 (or (eq Man-notify-method 'newframe) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1003 (and pop-up-frames |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
1004 (eq Man-notify-method 'bully)))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1005 (delete-frame))) |
3235 | 1006 |
1007 (defun Man-goto-page (page) | |
1008 "Go to the manual page on page PAGE." | |
1009 (interactive | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1010 (if (not Man-page-list) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1011 (let ((args Man-arguments)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1012 (kill-buffer (current-buffer)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1013 (error "Can't find the %s manpage" args)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1014 (if (= (length Man-page-list) 1) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1015 (error "You're looking at the only manpage in the buffer") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1016 (list (read-minibuffer (format "Go to manpage [1-%d]: " |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1017 (length Man-page-list))))))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1018 (if (not Man-page-list) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1019 (let ((args Man-arguments)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1020 (kill-buffer (current-buffer)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1021 (error "Can't find the %s manpage" args))) |
3235 | 1022 (if (or (< page 1) |
1023 (> page (length Man-page-list))) | |
1024 (error "No manpage %d found" page)) | |
1025 (let* ((page-range (nth (1- page) Man-page-list)) | |
1026 (page-start (car page-range)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1027 (page-end (car (cdr page-range)))) |
3235 | 1028 (setq Man-current-page page |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1029 Man-page-mode-string (Man-make-page-mode-string)) |
3235 | 1030 (widen) |
1031 (goto-char page-start) | |
1032 (narrow-to-region page-start page-end) | |
1033 (Man-build-section-alist) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1034 (Man-build-references-alist) |
3235 | 1035 (goto-char (point-min)))) |
1036 | |
1037 | |
1038 (defun Man-next-manpage () | |
1039 "Find the next manpage entry in the buffer." | |
1040 (interactive) | |
1041 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1042 (error "This is the only manpage in the buffer")) |
3235 | 1043 (if (< Man-current-page (length Man-page-list)) |
1044 (Man-goto-page (1+ Man-current-page)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1045 (if Man-circular-pages-flag |
3235 | 1046 (Man-goto-page 1) |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1047 (error "You're looking at the last manpage in the buffer")))) |
3235 | 1048 |
1049 (defun Man-previous-manpage () | |
1050 "Find the previous manpage entry in the buffer." | |
1051 (interactive) | |
1052 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1053 (error "This is the only manpage in the buffer")) |
3235 | 1054 (if (> Man-current-page 1) |
1055 (Man-goto-page (1- Man-current-page)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1056 (if Man-circular-pages-flag |
3235 | 1057 (Man-goto-page (length Man-page-list)) |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1058 (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
|
1059 |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
1060 (provide 'man) |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
1061 |
3235 | 1062 ;;; man.el ends here |