Mercurial > emacs
annotate lisp/man.el @ 88171:4824ab00dc3e
*** empty log message ***
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Mon, 16 Jan 2006 22:22:44 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
88155 | 1 ;;; man.el --- browse UNIX manual pages -*- coding: iso-8859-1 -*- |
3235 | 2 |
88155 | 3 ;; Copyright (C) 1993, 1994, 1996, 1997, 2001, 2002, 2003, |
4 ;; 2004, 2005 Free Software Foundation, Inc. | |
3235 | 5 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36575
diff
changeset
|
6 ;; Author: Barry A. Warsaw <bwarsaw@cen.com> |
28102 | 7 ;; Maintainer: FSF |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36575
diff
changeset
|
8 ;; Keywords: help |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36575
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 | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
88155 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
3235 | 27 |
28 ;;; Commentary: | |
29 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
30 ;; 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
|
31 ;; 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
|
32 ;; can continue to use your Emacs while processing is going on. |
3235 | 33 ;; |
34 ;; The mode also supports hypertext-like following of manual page SEE | |
35 ;; ALSO references, and other features. See below or do `?' in a | |
36 ;; manual page buffer for details. | |
37 | |
28102 | 38 ;; ========== Credits and History ========== |
3235 | 39 ;; In mid 1991, several people posted some interesting improvements to |
40 ;; man.el from the standard emacs 18.57 distribution. I liked many of | |
14040 | 41 ;; these, but wanted everything 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
|
42 ;; to incorporate them into a single manual browsing mode. While |
3235 | 43 ;; much of the code here has been rewritten, and some features added, |
44 ;; these folks deserve lots of credit for providing the initial | |
45 ;; excellent packages on which this one is based. | |
46 | |
47 ;; Nick Duffek <duffek@chaos.cs.brandeis.edu>, posted a very nice | |
48 ;; improvement which retrieved and cleaned the manpages in a | |
49 ;; background process, and which correctly deciphered such options as | |
50 ;; man -k. | |
51 | |
52 ;; Eric Rose <erose@jessica.stanford.edu>, submitted manual.el which | |
53 ;; provided a very nice manual browsing mode. | |
54 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3307
diff
changeset
|
55 ;; This package was available as `superman.el' from the LCD package |
3235 | 56 ;; for some time before it was accepted into Emacs 19. The entry |
57 ;; point and some other names have been changed to make it a drop-in | |
58 ;; replacement for the old man.el package. | |
59 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
60 ;; 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
|
61 ;; making it faster, more robust and more tolerant of different |
14040 | 62 ;; systems' man idiosyncrasies. |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
63 |
3235 | 64 ;; ========== Features ========== |
65 ;; + Runs "man" in the background and pipes the results through a | |
66 ;; series of sed and awk scripts so that all retrieving and cleaning | |
67 ;; is done in the background. The cleaning commands are configurable. | |
68 ;; + Syntax is the same as Un*x man | |
69 ;; + 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
|
70 ;; "man <section>", etc. |
3235 | 71 ;; + Provides a manual browsing mode with keybindings for traversing |
72 ;; the sections of a manpage, following references in the SEE ALSO | |
73 ;; section, and more. | |
74 ;; + Multiple manpages created with the same man command are put into | |
75 ;; a narrowed buffer circular list. | |
76 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
77 ;; ============= TODO =========== |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
78 ;; - 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
|
79 ;; - 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
|
80 ;; 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
|
81 ;; 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
|
82 ;; 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
|
83 ;; 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
|
84 ;; headers, and after the page footer. But it is possible to compute |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
85 ;; the number of blank lines before the page footer by heuristics |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
86 ;; only. Is it worth doing? |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
87 ;; - Allow a user option to mean that all the manpages should go in |
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
88 ;; the same buffer, where they can be browsed with M-n and M-p. |
8970
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 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
95 |
3235 | 96 ;;; Code: |
97 | |
88155 | 98 (eval-when-compile (require 'cl)) |
3235 | 99 (require 'assoc) |
88155 | 100 (require 'button) |
3235 | 101 |
102 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
103 ;; empty defvars (keep the compiler quiet) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
104 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
105 (defgroup man nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
106 "Browse UNIX manual pages." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
107 :prefix "Man-" |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
108 :group 'help) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
109 |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
110 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
111 (defvar Man-notify) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
112 (defvar Man-current-page) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
113 (defvar Man-page-list) |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
114 (defcustom Man-filter-list nil |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
115 "*Manpage cleaning filter command phrases. |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
116 This variable contains a list of the following form: |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
117 |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
118 '((command-string phrase-string*)*) |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
119 |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
120 Each phrase-string is concatenated onto the command-string to form a |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
121 command filter. The (standard) output (and standard error) of the Un*x |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
122 man command is piped through each command filter in the order the |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
123 commands appear in the association list. The final output is placed in |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
124 the manpage buffer." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
125 :type '(repeat (list (string :tag "Command String") |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
126 (repeat :inline t |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
127 (string :tag "Phrase String")))) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
128 :group 'man) |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
129 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
130 (defvar Man-original-frame) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
131 (defvar Man-arguments) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
132 (defvar Man-sections-alist) |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
133 (defvar Man-refpages-alist) |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
134 (defvar Man-uses-untabify-flag t |
28102 | 135 "Non-nil means use `untabify' instead of `Man-untabify-command'.") |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
136 (defvar Man-page-mode-string) |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
137 (defvar Man-sed-script nil |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
138 "Script for sed to nuke backspaces and ANSI codes from manpages.") |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
139 |
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
140 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
3235 | 141 ;; user variables |
142 | |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
143 (defcustom Man-fontify-manpage-flag t |
28102 | 144 "*Non-nil means make up the manpage with fonts." |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
145 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
146 :group 'man) |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
147 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
148 (defcustom Man-overstrike-face 'bold |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
149 "*Face to use when fontifying overstrike." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
150 :type 'face |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
151 :group 'man) |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
152 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
153 (defcustom Man-underline-face 'underline |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
154 "*Face to use when fontifying underlining." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
155 :type 'face |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
156 :group 'man) |
6676
7251020c1c79
(manual-program): New (actually reintroduced) variable.
Karl Heuer <kwzh@gnu.org>
parents:
6613
diff
changeset
|
157 |
88155 | 158 (defcustom Man-reverse-face 'highlight |
159 "*Face to use when fontifying reverse video." | |
160 :type 'face | |
161 :group 'man) | |
162 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
163 ;; Use the value of the obsolete user option Man-notify, if set. |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
164 (defcustom Man-notify-method (if (boundp 'Man-notify) Man-notify 'friendly) |
3235 | 165 "*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
|
166 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
|
167 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
|
168 where the man command was called from: |
3235 | 169 |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 polite -- don't display manpage, but prints message and beep when ready |
3235 | 176 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
|
177 meek -- make no indication that the manpage is ready |
3235 | 178 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
179 Any other value of `Man-notify-method' is equivalent to `meek'." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
180 :type '(radio (const newframe) (const pushy) (const bully) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
181 (const aggressive) (const friendly) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
182 (const polite) (const quiet) (const meek)) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
183 :group 'man) |
3235 | 184 |
88155 | 185 (defcustom Man-width nil |
186 "*Number of columns for which manual pages should be formatted. | |
187 If nil, the width of the window selected at the moment of man | |
188 invocation is used. If non-nil, the width of the frame selected | |
189 at the moment of man invocation is used. The value also can be a | |
190 positive integer." | |
191 :type '(choice (const :tag "Window width" nil) | |
192 (const :tag "Frame width" t) | |
193 (integer :tag "Specific width" :value 65)) | |
194 :group 'man) | |
195 | |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
196 (defcustom Man-frame-parameters nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
197 "*Frame parameter list for creating a new frame for a manual page." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
198 :type 'sexp |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
199 :group 'man) |
4915
c0523a78e6a5
(Man-frame-parameters): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4444
diff
changeset
|
200 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
201 (defcustom Man-downcase-section-letters-flag t |
28102 | 202 "*Non-nil means letters in sections are converted to lower case. |
3235 | 203 Some Un*x man commands can't handle uppercase letters in sections, for |
204 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
|
205 with the upper case letter. When this variable is t, the section |
3235 | 206 letter (e.g., \"2V\") is converted to lowercase (e.g., \"2v\") before |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
207 being sent to the man background process." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
208 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
209 :group 'man) |
3235 | 210 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
211 (defcustom Man-circular-pages-flag t |
28102 | 212 "*Non-nil means the manpage list is treated as circular for traversal." |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
213 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
214 :group 'man) |
3235 | 215 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
216 (defcustom 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
|
217 (list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
218 '("3C++" . "3") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
219 ;; 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
|
220 ;; '("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
|
221 '("3X11" . "3") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
222 '("1-UCB" . "")) |
3235 | 223 "*Association list of bogus sections to real section numbers. |
224 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
|
225 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
|
226 association list is used to translate those sections, when found, to |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
227 the associated section number." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
228 :type '(repeat (cons (string :tag "Bogus Section") |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
229 (string :tag "Real Section"))) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17132
diff
changeset
|
230 :group 'man) |
3235 | 231 |
88155 | 232 (defcustom Man-header-file-path |
233 '("/usr/include" "/usr/local/include") | |
234 "C Header file search path used in Man." | |
235 :type '(repeat string) | |
236 :group 'man) | |
237 | |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
238 (defvar manual-program "man" |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
239 "The name of the program that produces man pages.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
240 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
241 (defvar Man-untabify-command "pr" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
242 "Command used for untabifying.") |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
243 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
244 (defvar Man-untabify-command-args (list "-t" "-e") |
28102 | 245 "List of arguments to be passed to `Man-untabify-command' (which see).") |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
246 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
247 (defvar Man-sed-command "sed" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
248 "Command used for processing sed scripts.") |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
249 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
250 (defvar Man-awk-command "awk" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
251 "Command used for processing awk scripts.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
252 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
253 (defvar Man-mode-map nil |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
254 "Keymap for Man mode.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
255 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
256 (defvar Man-mode-hook nil |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
257 "Hook run when Man mode is enabled.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
258 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
259 (defvar Man-cooked-hook nil |
28102 | 260 "Hook run after removing backspaces but before `Man-mode' processing.") |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
261 |
88155 | 262 (defvar Man-name-regexp "[-a-zA-Z0-9_+][-a-zA-Z0-9_.:+]*" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
263 "Regular expression describing the name of a manpage (without section).") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
264 |
88155 | 265 (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
266 "Regular expression describing a manpage section within parentheses.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
267 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
268 (defvar Man-page-header-regexp |
23644
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
269 (if (and (string-match "-solaris2\\." system-configuration) |
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
270 (not (string-match "-solaris2\\.[123435]$" system-configuration))) |
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
271 (concat "^[-A-Za-z0-9_].*[ \t]\\(" Man-name-regexp |
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
272 "(\\(" Man-section-regexp "\\))\\)$") |
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
273 (concat "^[ \t]*\\(" Man-name-regexp |
3d09886cb53e
(Man-page-header-regexp): Alternate value for Solaris 2.6.
Karl Heuer <kwzh@gnu.org>
parents:
23267
diff
changeset
|
274 "(\\(" Man-section-regexp "\\))\\).*\\1")) |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
275 "Regular expression describing the heading of a page.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
276 |
88155 | 277 (defvar Man-heading-regexp "^\\([A-Z][A-Z -]+\\)$" |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
278 "Regular expression describing a manpage heading entry.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
279 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
280 (defvar Man-see-also-regexp "SEE ALSO" |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
281 "Regular expression for SEE ALSO heading (or your equivalent). |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
282 This regexp should not start with a `^' character.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
283 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
284 (defvar Man-first-heading-regexp "^[ \t]*NAME$\\|^[ \t]*No manual entry fo.*$" |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
285 "Regular expression describing first heading on a manpage. |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
286 This regular expression should start with a `^' character.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
287 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
288 (defvar Man-reference-regexp |
88155 | 289 (concat "\\(" Man-name-regexp "\\)[ \t]*(\\(" Man-section-regexp "\\))") |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
290 "Regular expression describing a reference to another manpage.") |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
291 |
88155 | 292 (defvar Man-apropos-regexp |
293 (concat "\\\[\\(" Man-name-regexp "\\)\\\][ \t]*(\\(" Man-section-regexp "\\))") | |
294 "Regular expression describing a reference to manpages in \"man -k output\".") | |
295 | |
296 (defvar Man-synopsis-regexp "SYNOPSIS" | |
297 "Regular expression for SYNOPSIS heading (or your equivalent). | |
298 This regexp should not start with a `^' character.") | |
299 | |
300 (defvar Man-files-regexp "FILES" | |
301 "Regular expression for FILES heading (or your equivalent). | |
302 This regexp should not start with a `^' character.") | |
303 | |
304 (defvar Man-include-regexp "#[ \t]*include[ \t]*" | |
305 "Regular expression describing the #include (directive of cpp).") | |
306 | |
307 (defvar Man-file-name-regexp "[^<>\", \t\n]+" | |
308 "Regular expression describing <> in #include line (directive of cpp).") | |
309 | |
310 (defvar Man-normal-file-prefix-regexp "[/~$]" | |
311 "Regular expression describing a file path appeared in FILES section.") | |
312 | |
313 (defvar Man-header-regexp | |
314 (concat "\\(" Man-include-regexp "\\)" | |
315 "[<\"]" | |
316 "\\(" Man-file-name-regexp "\\)" | |
317 "[>\"]") | |
318 "Regular expression describing references to header files.") | |
319 | |
320 (defvar Man-normal-file-regexp | |
321 (concat Man-normal-file-prefix-regexp Man-file-name-regexp) | |
322 "Regular expression describing references to normal files.") | |
323 | |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
324 ;; This includes the section as an optional part to catch hyphenated |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
325 ;; refernces to manpages. |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
326 (defvar Man-hyphenated-reference-regexp |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
327 (concat "\\(" Man-name-regexp "\\)\\((\\(" Man-section-regexp "\\))\\)?") |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
328 "Regular expression describing a reference in the SEE ALSO section.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
329 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
330 (defvar Man-switches "" |
38646
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
331 "Switches passed to the man command, as a single string. |
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
332 |
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
333 If you want to be able to see all the manpages for a subject you type, |
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
334 make -a one of the switches, if your `man' program supports it.") |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
335 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
336 (defvar Man-specified-section-option |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
337 (if (string-match "-solaris[0-9.]*$" system-configuration) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
338 "-s" |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
339 "") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
340 "Option that indicates a specified a manual section name.") |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
341 |
88155 | 342 (defvar Man-support-local-filenames 'auto-detect |
343 "Internal cache for the value of the function `Man-support-local-filenames'. | |
344 `auto-detect' means the value is not yet determined. | |
345 Otherwise, the value is whatever the function | |
346 `Man-support-local-filenames' should return.") | |
347 | |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
348 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
349 ;; end user variables |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
350 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
351 ;; other variables and keymap initializations |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
352 (make-variable-buffer-local 'Man-sections-alist) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
353 (make-variable-buffer-local 'Man-refpages-alist) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
354 (make-variable-buffer-local 'Man-page-list) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
355 (make-variable-buffer-local 'Man-current-page) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
356 (make-variable-buffer-local 'Man-page-mode-string) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
357 (make-variable-buffer-local 'Man-original-frame) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
358 (make-variable-buffer-local 'Man-arguments) |
88155 | 359 (put 'Man-arguments 'permanent-local t) |
9726
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
360 |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
361 (setq-default Man-sections-alist nil) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
362 (setq-default Man-refpages-alist nil) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
363 (setq-default Man-page-list nil) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
364 (setq-default Man-current-page 0) |
51a9e9bc5fda
* man.el (Man-fontify-manpage-flag): defvar put at outer level.
Francesco Potortì <pot@gnu.org>
parents:
9679
diff
changeset
|
365 (setq-default Man-page-mode-string "1 of 1") |
3235 | 366 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
367 (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
|
368 /\b/ { s/_\b//g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
369 s/\b_//g |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
370 s/o\b+/o/g |
9867
57ee6c3a0a3c
* man.el (Man-berkeley-sed-script, Man-sysv-sed-script,
Francesco Potortì <pot@gnu.org>
parents:
9838
diff
changeset
|
371 s/+\bo/o/g |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
372 :ovstrk |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
373 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
|
374 t ovstrk |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
375 } |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
376 /\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
|
377 "Script for sysV-like sed to nuke backspaces and ANSI codes from manpages.") |
3235 | 378 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
379 (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
|
380 /\b/ { s/_\b//g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
381 s/\b_//g\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
382 s/o\b+/o/g\\ |
9867
57ee6c3a0a3c
* man.el (Man-berkeley-sed-script, Man-sysv-sed-script,
Francesco Potortì <pot@gnu.org>
parents:
9838
diff
changeset
|
383 s/+\bo/o/g\\ |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
384 :ovstrk\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
385 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
|
386 t ovstrk\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
387 }\\ |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
388 /\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
|
389 "Script for berkeley-like sed to nuke backspaces and ANSI codes from manpages.") |
3235 | 390 |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
391 (defvar man-mode-syntax-table |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
392 (let ((table (copy-syntax-table (standard-syntax-table)))) |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
393 (modify-syntax-entry ?. "w" table) |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
394 (modify-syntax-entry ?_ "w" table) |
88155 | 395 (modify-syntax-entry ?: "w" table) ; for PDL::Primitive in Perl man pages |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
396 table) |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
397 "Syntax table used in Man mode buffers.") |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
398 |
88155 | 399 (unless Man-mode-map |
400 (setq Man-mode-map (make-sparse-keymap)) | |
3235 | 401 (suppress-keymap Man-mode-map) |
88155 | 402 (set-keymap-parent Man-mode-map button-buffer-map) |
403 | |
3235 | 404 (define-key Man-mode-map " " 'scroll-up) |
405 (define-key Man-mode-map "\177" 'scroll-down) | |
406 (define-key Man-mode-map "n" 'Man-next-section) | |
407 (define-key Man-mode-map "p" 'Man-previous-section) | |
408 (define-key Man-mode-map "\en" 'Man-next-manpage) | |
409 (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
|
410 (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
|
411 (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
|
412 (define-key Man-mode-map "." 'beginning-of-buffer) |
3235 | 413 (define-key Man-mode-map "r" 'Man-follow-manual-reference) |
414 (define-key Man-mode-map "g" 'Man-goto-section) | |
415 (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
|
416 (define-key Man-mode-map "k" 'Man-kill) |
3235 | 417 (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
|
418 (define-key Man-mode-map "m" 'man) |
88155 | 419 (define-key Man-mode-map "?" 'describe-mode)) |
420 | |
421 ;; buttons | |
422 (define-button-type 'Man-abstract-xref-man-page | |
423 'follow-link t | |
424 'help-echo "mouse-2, RET: display this man page" | |
425 'func nil | |
426 'action (lambda (button) (funcall | |
427 (button-get button 'func) | |
428 (or (button-get button 'Man-target-string) | |
429 (button-label button))))) | |
430 | |
431 (define-button-type 'Man-xref-man-page | |
432 :supertype 'Man-abstract-xref-man-page | |
433 'func 'man-follow) | |
434 | |
435 | |
436 (define-button-type 'Man-xref-header-file | |
437 'action (lambda (button) | |
438 (let ((w (button-get button 'Man-target-string))) | |
439 (unless (Man-view-header-file w) | |
440 (error "Cannot find header file: %s" w)))) | |
441 'follow-link t | |
442 'help-echo "mouse-2: display this header file") | |
443 | |
444 (define-button-type 'Man-xref-normal-file | |
445 'action (lambda (button) | |
446 (let ((f (substitute-in-file-name | |
447 (button-get button 'Man-target-string)))) | |
448 (if (file-exists-p f) | |
449 (if (file-readable-p f) | |
450 (view-file f) | |
451 (error "Cannot read a file: %s" f)) | |
452 (error "Cannot find a file: %s" f)))) | |
453 'follow-link t | |
454 'help-echo "mouse-2: display this file") | |
3235 | 455 |
456 | |
457 ;; ====================================================================== | |
458 ;; utilities | |
459 | |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
460 (defun Man-init-defvars () |
88155 | 461 "Used for initializing variables based on display's color support. |
28102 | 462 This is necessary if one wants to dump man.el with Emacs." |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
463 |
20266
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
464 ;; Avoid possible error in call-process by using a directory that must exist. |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
465 (let ((default-directory "/")) |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
466 (setq Man-sed-script |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
467 (cond |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
468 (Man-fontify-manpage-flag |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
469 nil) |
88155 | 470 ((eq 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script)) |
20266
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
471 Man-sysv-sed-script) |
88155 | 472 ((eq 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script)) |
20266
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
473 Man-berkeley-sed-script) |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
474 (t |
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
475 nil)))) |
3235 | 476 |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
477 (setq Man-filter-list |
23267
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
478 ;; Avoid trailing nil which confuses customize. |
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
479 (apply 'list |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
480 (cons |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
481 Man-sed-command |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
482 (list |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
483 (if Man-sed-script |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
484 (concat "-e '" Man-sed-script "'") |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
485 "") |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
486 "-e '/^[\001-\032][\001-\032]*$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
487 "-e '/\e[789]/s///g'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
488 "-e '/Reformatting page. Wait/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
489 "-e '/Reformatting entry. Wait/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
490 "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
491 "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
492 "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
493 "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
494 "-e '/^Printed[ \t][0-9].*[0-9]$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
495 "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" |
16974
f4eb94106c89
(Man-init-defvars): Fix case in a char set range.
Richard M. Stallman <rms@gnu.org>
parents:
16973
diff
changeset
|
496 "-e '/^[A-Za-z].*Last[ \t]change:/d'" |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
497 "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
498 "-e '/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
499 "-e '/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
500 )) |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
501 (cons |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
502 Man-awk-command |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
503 (list |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
504 "'\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
505 "BEGIN { blankline=0; anonblank=0; }\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
506 "/^$/ { if (anonblank==0) next; }\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
507 "{ anonblank=1; }\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
508 "/^$/ { blankline++; next; }\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
509 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
510 "'" |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
511 )) |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
512 (if (not Man-uses-untabify-flag) |
23267
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
513 ;; The outer list will be stripped off by apply. |
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
514 (list (cons |
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
515 Man-untabify-command |
a804a047b23d
(Man-init-defvars): Avoid trailing nil on
Andreas Schwab <schwab@suse.de>
parents:
22368
diff
changeset
|
516 Man-untabify-command-args)) |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
517 ))) |
8970
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 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
520 (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
|
521 "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
|
522 (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
|
523 (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
|
524 "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
525 Man-current-page |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
526 (length Man-page-list))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
527 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
528 (defsubst Man-build-man-command () |
3235 | 529 "Builds the entire background manpage and cleaning command." |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
530 (let ((command (concat manual-program " " Man-switches |
88155 | 531 (cond |
532 ;; Already has %s | |
533 ((string-match "%s" manual-program) "") | |
534 ;; Stock MS-DOS shells cannot redirect stderr; | |
535 ;; `call-process' below sends it to /dev/null, | |
536 ;; so we don't need `2>' even with DOS shells | |
537 ;; which do support stderr redirection. | |
538 ((not (fboundp 'start-process)) " %s") | |
539 ((concat " %s 2>" null-device))))) | |
3235 | 540 (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
|
541 (while (and flist (car flist)) |
3235 | 542 (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
|
543 (pargs (cdr (car flist)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
544 (setq command |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
545 (concat command " | " pcom " " |
29585
d3e3a9663705
(Man-build-man-command): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29525
diff
changeset
|
546 (mapconcat (lambda (phrase) |
d3e3a9663705
(Man-build-man-command): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29525
diff
changeset
|
547 (if (not (stringp phrase)) |
d3e3a9663705
(Man-build-man-command): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29525
diff
changeset
|
548 (error "Malformed Man-filter-list")) |
d3e3a9663705
(Man-build-man-command): Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29525
diff
changeset
|
549 phrase) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
550 pargs " "))) |
88155 | 551 (setq flist (cdr flist)))) |
3235 | 552 command)) |
553 | |
88155 | 554 |
555 (defun Man-translate-cleanup (string) | |
556 "Strip leading, trailing and middle spaces." | |
557 (when (stringp string) | |
558 ;; Strip leading and trailing | |
559 (if (string-match "^[ \t\f\r\n]*\\(.+[^ \t\f\r\n]\\)" string) | |
560 (setq string (match-string 1 string))) | |
561 ;; middle spaces | |
562 (setq string (replace-regexp-in-string "[\t\r\n]" " " string)) | |
563 (setq string (replace-regexp-in-string " +" " " string)) | |
564 string)) | |
565 | |
3235 | 566 (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
|
567 "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
|
568 Leave it as is if already in that style. Possibly downcase and |
88155 | 569 translate the section (see the `Man-downcase-section-letters-flag' |
570 and the `Man-section-translations-alist' variables)." | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
571 (let ((name "") |
88155 | 572 (section "") |
573 (slist Man-section-translations-alist)) | |
574 (setq ref (Man-translate-cleanup ref)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
575 (cond |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
576 ;; "chmod(2V)" case ? |
12809
c388f6f7f210
* man.el (Man-translate-references): Anchor the regexps.
Francesco Potortì <pot@gnu.org>
parents:
12457
diff
changeset
|
577 ((string-match (concat "^" Man-reference-regexp "$") ref) |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
578 (setq name (match-string 1 ref) |
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
579 section (match-string 2 ref))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
580 ;; "2v chmod" case ? |
12809
c388f6f7f210
* man.el (Man-translate-references): Anchor the regexps.
Francesco Potortì <pot@gnu.org>
parents:
12457
diff
changeset
|
581 ((string-match (concat "^\\(" Man-section-regexp |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
582 "\\) +\\(" Man-name-regexp "\\)$") ref) |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
583 (setq name (match-string 2 ref) |
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
584 section (match-string 1 ref)))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
585 (if (string= name "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
586 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
|
587 (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
|
588 (setq section (downcase section))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
589 (while slist |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
590 (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
|
591 (s2 (cdr (car slist)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
592 (setq slist (cdr slist)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
593 (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
|
594 (setq s1 (downcase s1))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
595 (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
|
596 (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
|
597 (downcase s2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
598 s2) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
599 slist nil)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
600 (concat Man-specified-section-option section " " name)))) |
3235 | 601 |
88155 | 602 (defun Man-support-local-filenames () |
603 "Check the availability of `-l' option of the man command. | |
604 This option allows `man' to interpret command line arguments | |
605 as local filenames. | |
606 Return the value of the variable `Man-support-local-filenames' | |
607 if it was set to nil or t before the call of this function. | |
608 If t, the man command supports `-l' option. If nil, it doesn't. | |
609 Otherwise, if the value of `Man-support-local-filenames' | |
610 is neither t nor nil, then determine a new value, set it | |
611 to the variable `Man-support-local-filenames' and return | |
612 a new value." | |
613 (if (or (not Man-support-local-filenames) | |
614 (eq Man-support-local-filenames t)) | |
615 Man-support-local-filenames | |
616 (setq Man-support-local-filenames | |
617 (with-temp-buffer | |
618 (and (equal (condition-case nil | |
619 (call-process manual-program nil t nil "--help") | |
620 (error nil)) | |
621 0) | |
622 (progn | |
623 (goto-char (point-min)) | |
624 (search-forward "--local-file" nil t)) | |
625 t))))) | |
626 | |
3235 | 627 |
628 ;; ====================================================================== | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
629 ;; default man entry: get word under point |
3235 | 630 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
631 (defsubst Man-default-man-entry () |
3235 | 632 "Make a guess at a default manual entry. |
35603
8f8be2a8aed8
(Man-default-man-entry, Man-mode): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents:
32495
diff
changeset
|
633 This guess is based on the text surrounding the cursor." |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
634 (let (word) |
3235 | 635 (save-excursion |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
636 ;; Default man entry title is any word the cursor is on, or if |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
637 ;; cursor not on a word, then nearest preceding word. |
48012
73c9cc6e8538
(Man-default-man-entry): Don't look for all word chars,
Richard M. Stallman <rms@gnu.org>
parents:
47891
diff
changeset
|
638 (skip-chars-backward "-a-zA-Z0-9._+:") |
73c9cc6e8538
(Man-default-man-entry): Don't look for all word chars,
Richard M. Stallman <rms@gnu.org>
parents:
47891
diff
changeset
|
639 (let ((start (point))) |
73c9cc6e8538
(Man-default-man-entry): Don't look for all word chars,
Richard M. Stallman <rms@gnu.org>
parents:
47891
diff
changeset
|
640 (skip-chars-forward "-a-zA-Z0-9._+:") |
88155 | 641 (setq word (buffer-substring-no-properties start (point)))) |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
642 (if (string-match "[._]+$" word) |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
643 (setq word (substring word 0 (match-beginning 0)))) |
88155 | 644 ;; If looking at something like *strcat(... , remove the '*' |
645 (if (string-match "^*" word) | |
646 (setq word (substring word 1))) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
647 ;; If looking at something like ioctl(2) or brc(1M), include the |
10642
0e6b71f2ebad
* man.el (Man-default-man-entry): Remove text properties from result.
Francesco Potortì <pot@gnu.org>
parents:
10040
diff
changeset
|
648 ;; section number in the returned value. Remove text properties. |
88155 | 649 (concat word |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
650 (if (looking-at |
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
651 (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)")) |
88155 | 652 (format "(%s)" (match-string-no-properties 1))))))) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
653 |
3235 | 654 |
655 ;; ====================================================================== | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
656 ;; Top level command and background process sentinel |
3235 | 657 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
658 ;; For compatibility with older versions. |
4444 | 659 ;;;###autoload |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
660 (defalias 'manual-entry 'man) |
4444 | 661 |
88155 | 662 |
3235 | 663 ;;;###autoload |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
664 (defun man (man-args) |
3235 | 665 "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
|
666 This command is the top-level command in the man package. It runs a Un*x |
3235 | 667 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
|
668 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
|
669 `Man-notify-method' for what happens when the buffer is ready. |
29838 | 670 If a buffer already exists for this man page, it will display immediately. |
671 | |
672 To specify a man page from a certain section, type SUBJECT(SECTION) or | |
38646
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
673 SECTION SUBJECT when prompted for a manual entry. To see manpages from |
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
674 all sections related to a subject, put something appropriate into the |
5236fd76fef0
(man): Mention Man-switches in the doc string.
Eli Zaretskii <eliz@gnu.org>
parents:
38412
diff
changeset
|
675 `Man-switches' variable, which see." |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
676 (interactive |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
677 (list (let* ((default-entry (Man-default-man-entry)) |
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
678 (input (read-string |
88155 | 679 (format "Manual entry%s" |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
680 (if (string= default-entry "") |
88155 | 681 ": " |
682 (format " (default %s): " default-entry))) | |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
683 nil nil default-entry))) |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
684 (if (string= input "") |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
685 (error "No man args given") |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
686 input)))) |
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
|
687 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
688 ;; 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
|
689 ;; "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
|
690 (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
|
691 |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
692 (Man-getpage-in-background man-args)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
693 |
17129 | 694 ;;;###autoload |
695 (defun man-follow (man-args) | |
696 "Get a Un*x manual page of the item under point and put it in a buffer." | |
697 (interactive (list (Man-default-man-entry))) | |
698 (if (or (not man-args) | |
699 (string= man-args "")) | |
700 (error "No item under point") | |
701 (man man-args))) | |
3235 | 702 |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
703 (defun Man-getpage-in-background (topic) |
28102 | 704 "Use TOPIC to build and fire off the manpage and cleaning command." |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
705 (let* ((man-args topic) |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
706 (bufname (concat "*Man " man-args "*")) |
3235 | 707 (buffer (get-buffer bufname))) |
9828
e78a12b9ef41
* man.el (Man-reuse-okay-flag): Deleted.
Francesco Potortì <pot@gnu.org>
parents:
9726
diff
changeset
|
708 (if buffer |
3235 | 709 (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
|
710 (require 'env) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
711 (message "Invoking %s %s in the background" manual-program man-args) |
3235 | 712 (setq buffer (generate-new-buffer bufname)) |
6363
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
713 (save-excursion |
e5d9ea7852bf
(Man-original-frame): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
6362
diff
changeset
|
714 (set-buffer buffer) |
88155 | 715 (setq buffer-undo-list t) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
716 (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
|
717 (setq Man-arguments man-args)) |
20266
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
718 (let ((process-environment (copy-sequence process-environment)) |
22217
e83578642825
(Man-getpage-in-background): Bind coding-system-for-write
Richard M. Stallman <rms@gnu.org>
parents:
21581
diff
changeset
|
719 ;; The following is so Awk script gets \n intact |
e83578642825
(Man-getpage-in-background): Bind coding-system-for-write
Richard M. Stallman <rms@gnu.org>
parents:
21581
diff
changeset
|
720 ;; But don't prevent decoding of the outside. |
e83578642825
(Man-getpage-in-background): Bind coding-system-for-write
Richard M. Stallman <rms@gnu.org>
parents:
21581
diff
changeset
|
721 (coding-system-for-write 'raw-text-unix) |
30995
75f3cd16a9ab
(Man-getpage-in-background): Decode the process output by the system
Kenichi Handa <handa@m17n.org>
parents:
29973
diff
changeset
|
722 ;; We must decode the output by a coding system that the |
32495 | 723 ;; system's locale suggests in multibyte mode. |
32396
b68d86c19284
(Man-getpage-in-background): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31005
diff
changeset
|
724 (coding-system-for-read |
b68d86c19284
(Man-getpage-in-background): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31005
diff
changeset
|
725 (if default-enable-multibyte-characters |
b68d86c19284
(Man-getpage-in-background): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
31005
diff
changeset
|
726 locale-coding-system 'raw-text-unix)) |
20266
450fdcb00733
(Man-init-defvars, Man-build-man-command):
Karl Heuer <kwzh@gnu.org>
parents:
20154
diff
changeset
|
727 ;; Avoid possible error by using a directory that always exists. |
88155 | 728 (default-directory |
729 (if (and (file-directory-p default-directory) | |
730 (not (find-file-name-handler default-directory | |
731 'file-directory-p))) | |
732 default-directory | |
733 "/"))) | |
3713
c77a3da2d08d
(Man-getpage-in-background): Use TERM=dumb to prevent
Richard M. Stallman <rms@gnu.org>
parents:
3659
diff
changeset
|
734 ;; 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
|
735 (setenv "TERM" "dumb") |
47891
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
736 ;; In Debian Woody, at least, we get overlong lines under X |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
737 ;; unless COLUMNS or MANWIDTH is set. This isn't a problem on |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
738 ;; a tty. man(1) says: |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
739 ;; MANWIDTH |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
740 ;; If $MANWIDTH is set, its value is used as the line |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
741 ;; length for which manual pages should be formatted. |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
742 ;; If it is not set, manual pages will be formatted |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
743 ;; with a line length appropriate to the current ter- |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
744 ;; minal (using an ioctl(2) if available, the value of |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
745 ;; $COLUMNS, or falling back to 80 characters if nei- |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
746 ;; ther is available). |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
747 (if window-system |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
748 (unless (or (getenv "MANWIDTH") (getenv "COLUMNS")) |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
749 ;; This isn't strictly correct, since we don't know how |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
750 ;; the page will actually be displayed, but it seems |
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
751 ;; reasonable. |
88155 | 752 (setenv "COLUMNS" (number-to-string |
753 (cond | |
754 ((and (integerp Man-width) (> Man-width 0)) | |
755 Man-width) | |
756 (Man-width (frame-width)) | |
757 ((window-width))))))) | |
758 (setenv "GROFF_NO_SGR" "1") | |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
759 (if (fboundp 'start-process) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
760 (set-process-sentinel |
88155 | 761 (start-process manual-program buffer |
762 (if (memq system-type '(cygwin windows-nt)) | |
763 shell-file-name | |
764 "sh") | |
765 shell-command-switch | |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
766 (format (Man-build-man-command) man-args)) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
767 'Man-bgproc-sentinel) |
88155 | 768 (let ((exit-status |
769 (call-process shell-file-name nil (list buffer nil) nil | |
770 shell-command-switch | |
771 (format (Man-build-man-command) man-args))) | |
772 (msg "")) | |
773 (or (and (numberp exit-status) | |
774 (= exit-status 0)) | |
775 (and (numberp exit-status) | |
776 (setq msg | |
777 (format "exited abnormally with code %d" | |
778 exit-status))) | |
779 (setq msg exit-status)) | |
780 (Man-bgproc-sentinel bufname msg))))))) | |
3235 | 781 |
782 (defun Man-notify-when-ready (man-buffer) | |
783 "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
|
784 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
|
785 (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
|
786 (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
|
787 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
|
788 (cond |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
789 ((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
|
790 ;; 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
|
791 ;; 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
|
792 ;; 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
|
793 ;; 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
|
794 (save-excursion |
21581
3aad7ffd0cd3
(Man-notify-when-ready) <newframe>:
Richard M. Stallman <rms@gnu.org>
parents:
21433
diff
changeset
|
795 (let ((frame (make-frame Man-frame-parameters))) |
3aad7ffd0cd3
(Man-notify-when-ready) <newframe>:
Richard M. Stallman <rms@gnu.org>
parents:
21433
diff
changeset
|
796 (set-window-buffer (frame-selected-window frame) man-buffer) |
29973
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
797 (set-window-dedicated-p (frame-selected-window frame) t) |
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
798 (or (display-multi-frame-p frame) |
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
799 (select-frame frame))))) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
800 ((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
|
801 (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
|
802 ((eq Man-notify-method 'bully) |
29973
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
803 (and (frame-live-p saved-frame) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
804 (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
|
805 (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
|
806 (delete-other-windows)) |
9003
bfe446409b77
User option Man-notify-flag renamed to Man-notify-method.
Francesco Potortì <pot@gnu.org>
parents:
8970
diff
changeset
|
807 ((eq Man-notify-method 'aggressive) |
29973
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
808 (and (frame-live-p saved-frame) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
809 (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
|
810 (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
|
811 ((eq Man-notify-method 'friendly) |
29973
be9760ddad44
(Man-notify-when-ready): Don't use window-system. If
Eli Zaretskii <eliz@gnu.org>
parents:
29838
diff
changeset
|
812 (and (frame-live-p saved-frame) |
8697
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
813 (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
|
814 (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
|
815 ((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
|
816 (beep) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
817 (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
|
818 ((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
|
819 (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
|
820 ((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
|
821 t) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
822 (message "")) |
c75e435af62f
(Man-notify-when-ready): Get Man-original-frame from the proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
8190
diff
changeset
|
823 ))) |
3235 | 824 |
20154
d0550e30957c
(Man-getpage-in-background): Bind inhibit-eol-conversion
Kenichi Handa <handa@m17n.org>
parents:
17436
diff
changeset
|
825 (defun Man-softhyphen-to-minus () |
47891
e7440f7b0700
(Man-getpage-in-background): Set width in environment.
Dave Love <fx@gnu.org>
parents:
42706
diff
changeset
|
826 ;; \255 is SOFT HYPHEN in Latin-N. Versions of Debian man, at |
25202
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
827 ;; least, emit it even when not in a Latin-N locale. |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
828 (unless (eq t (compare-strings "latin-" 0 nil |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
829 current-language-environment 0 6 t)) |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
830 (goto-char (point-min)) |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
831 (let ((str "\255")) |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
832 (if enable-multibyte-characters |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
833 (setq str (string-as-multibyte str))) |
abd64c56891f
(Man-softhyphen-to-minus): Revert previous change. Avoid unibyte to
Dave Love <fx@gnu.org>
parents:
25201
diff
changeset
|
834 (while (search-forward str nil t) (replace-match "-"))))) |
20154
d0550e30957c
(Man-getpage-in-background): Bind inhibit-eol-conversion
Kenichi Handa <handa@m17n.org>
parents:
17436
diff
changeset
|
835 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
836 (defun Man-fontify-manpage () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
837 "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
|
838 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
|
839 (interactive) |
88155 | 840 (message "Please wait: formatting the %s man page..." Man-arguments) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
841 (goto-char (point-min)) |
88155 | 842 ;; Fontify ANSI escapes. |
843 (let ((faces nil) | |
844 (buffer-undo-list t) | |
845 (start (point))) | |
846 ;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html | |
847 ;; suggests many codes, but we only handle: | |
848 ;; ESC [ 00 m reset to normal display | |
849 ;; ESC [ 01 m bold | |
850 ;; ESC [ 04 m underline | |
851 ;; ESC [ 07 m reverse-video | |
852 ;; ESC [ 22 m no-bold | |
853 ;; ESC [ 24 m no-underline | |
854 ;; ESC [ 27 m no-reverse-video | |
855 (while (re-search-forward "\e\\[0?\\([1470]\\|2\\([247]\\)\\)m" nil t) | |
856 (if faces (put-text-property start (match-beginning 0) 'face | |
857 (if (cdr faces) faces (car faces)))) | |
858 (setq faces | |
859 (cond | |
860 ((match-beginning 2) | |
861 (delq (case (char-after (match-beginning 2)) | |
862 (?2 Man-overstrike-face) | |
863 (?4 Man-underline-face) | |
864 (?7 Man-reverse-face)) | |
865 faces)) | |
866 ((eq (char-after (match-beginning 1)) ?0) nil) | |
867 (t | |
868 (cons (case (char-after (match-beginning 1)) | |
869 (?1 Man-overstrike-face) | |
870 (?4 Man-underline-face) | |
871 (?7 Man-reverse-face)) | |
872 faces)))) | |
873 (delete-region (match-beginning 0) (match-end 0)) | |
874 (setq start (point)))) | |
875 ;; Other highlighting. | |
876 (let ((buffer-undo-list t)) | |
877 (if (< (buffer-size) (position-bytes (point-max))) | |
878 ;; Multibyte characters exist. | |
879 (progn | |
880 (goto-char (point-min)) | |
881 (while (search-forward "__\b\b" nil t) | |
882 (backward-delete-char 4) | |
883 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) | |
884 (goto-char (point-min)) | |
885 (while (search-forward "\b\b__" nil t) | |
886 (backward-delete-char 4) | |
887 (put-text-property (1- (point)) (point) 'face Man-underline-face)))) | |
888 (goto-char (point-min)) | |
889 (while (search-forward "_\b" nil t) | |
890 (backward-delete-char 2) | |
891 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) | |
892 (goto-char (point-min)) | |
893 (while (search-forward "\b_" nil t) | |
894 (backward-delete-char 2) | |
895 (put-text-property (1- (point)) (point) 'face Man-underline-face)) | |
896 (goto-char (point-min)) | |
897 (while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) | |
898 (replace-match "\\1") | |
899 (put-text-property (1- (point)) (point) 'face Man-overstrike-face)) | |
900 (goto-char (point-min)) | |
901 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) | |
902 (replace-match "o") | |
903 (put-text-property (1- (point)) (point) 'face 'bold)) | |
904 (goto-char (point-min)) | |
905 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) | |
906 (replace-match "+") | |
907 (put-text-property (1- (point)) (point) 'face 'bold)) | |
908 (goto-char (point-min)) | |
909 ;; Try to recognize common forms of cross references. | |
910 (Man-highlight-references) | |
911 (Man-softhyphen-to-minus) | |
912 (goto-char (point-min)) | |
913 (while (re-search-forward Man-heading-regexp nil t) | |
914 (put-text-property (match-beginning 0) | |
915 (match-end 0) | |
916 'face Man-overstrike-face))) | |
917 (message "%s man page formatted" Man-arguments)) | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
918 |
88155 | 919 (defun Man-highlight-references (&optional xref-man-type) |
920 "Highlight the references on mouse-over. | |
921 References include items in the SEE ALSO section, | |
922 header file (#include <foo.h>), and files in FILES. | |
923 If optional argument XREF-MAN-TYPE is non-nil, it used as the | |
924 button type for items in SEE ALSO section. If it is nil, the | |
925 default type, `Man-xref-man-page' is used for the buttons." | |
926 ;; `Man-highlight-references' is used from woman.el, too. | |
927 ;; woman.el doesn't set `Man-arguments'. | |
928 (unless Man-arguments | |
929 (setq Man-arguments "")) | |
930 (if (string-match "-k " Man-arguments) | |
931 (progn | |
932 (Man-highlight-references0 nil Man-reference-regexp 1 nil | |
933 (or xref-man-type 'Man-xref-man-page)) | |
934 (Man-highlight-references0 nil Man-apropos-regexp 1 | |
935 (lambda () | |
936 (format "%s(%s)" | |
937 (match-string 1) | |
938 (match-string 2))) | |
939 (or xref-man-type 'Man-xref-man-page))) | |
940 (Man-highlight-references0 Man-see-also-regexp Man-reference-regexp 1 nil | |
941 (or xref-man-type 'Man-xref-man-page)) | |
942 (Man-highlight-references0 Man-synopsis-regexp Man-header-regexp 0 2 | |
943 'Man-xref-header-file) | |
944 (Man-highlight-references0 Man-files-regexp Man-normal-file-regexp 0 0 | |
945 'Man-xref-normal-file))) | |
946 | |
947 (defun Man-highlight-references0 (start-section regexp button-pos target type) | |
948 ;; Based on `Man-build-references-alist' | |
949 (when (or (null start-section) | |
950 (Man-find-section start-section)) | |
951 (let ((end (if start-section | |
952 (progn | |
953 (forward-line 1) | |
954 (back-to-indentation) | |
955 (save-excursion | |
956 (Man-next-section 1) | |
957 (point))) | |
958 (goto-char (point-min)) | |
959 (point-max)))) | |
960 (while (re-search-forward regexp end t) | |
961 (make-text-button | |
962 (match-beginning button-pos) | |
963 (match-end button-pos) | |
964 'type type | |
965 'Man-target-string (cond | |
966 ((numberp target) | |
967 (match-string target)) | |
968 ((functionp target) | |
969 (funcall target)) | |
970 (t nil))))))) | |
971 | |
972 (defun Man-cleanup-manpage (&optional interactive) | |
973 "Remove overstriking and underlining from the current buffer. | |
974 Normally skip any jobs that should have been done by the sed script, | |
975 but when called interactively, do those jobs even if the sed | |
976 script would have done them." | |
977 (interactive "p") | |
9620
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
978 (message "Please wait: cleaning up the %s man page..." |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
979 Man-arguments) |
88155 | 980 (if (or interactive (not Man-sed-script)) |
9620
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
981 (progn |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
982 (goto-char (point-min)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
983 (while (search-forward "_\b" nil t) (backward-delete-char 2)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
984 (goto-char (point-min)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
985 (while (search-forward "\b_" nil t) (backward-delete-char 2)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
986 (goto-char (point-min)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
987 (while (re-search-forward "\\(.\\)\\(\b\\1\\)+" nil t) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
988 (replace-match "\\1")) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
989 (goto-char (point-min)) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
990 (while (re-search-forward "\e\\[[0-9]+m" nil t) (replace-match "")) |
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
991 (goto-char (point-min)) |
9867
57ee6c3a0a3c
* man.el (Man-berkeley-sed-script, Man-sysv-sed-script,
Francesco Potortì <pot@gnu.org>
parents:
9838
diff
changeset
|
992 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) (replace-match "o")) |
9620
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
993 )) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
994 (goto-char (point-min)) |
9620
1f58befcd1f1
* man.el (Man-init-defvars): Corrections to Man-filter-list.
Francesco Potortì <pot@gnu.org>
parents:
9354
diff
changeset
|
995 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) (replace-match "+")) |
20154
d0550e30957c
(Man-getpage-in-background): Bind inhibit-eol-conversion
Kenichi Handa <handa@m17n.org>
parents:
17436
diff
changeset
|
996 (Man-softhyphen-to-minus) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
997 (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
|
998 |
3235 | 999 (defun Man-bgproc-sentinel (process msg) |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1000 "Manpage background process sentinel. |
28102 | 1001 When manpage command is run asynchronously, PROCESS is the process |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1002 object for the manpage command; when manpage command is run |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1003 synchronously, PROCESS is the name of the buffer where the manpage |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1004 command is run. Second argument MSG is the exit message of the |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1005 manpage command." |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1006 (let ((Man-buffer (if (stringp process) (get-buffer process) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1007 (process-buffer process))) |
3235 | 1008 (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
|
1009 (err-mess nil)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1010 |
3235 | 1011 (if (null (buffer-name Man-buffer)) ;; deleted buffer |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1012 (or (stringp process) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1013 (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
|
1014 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1015 (save-excursion |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1016 (set-buffer Man-buffer) |
10040
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1017 (let ((case-fold-search nil)) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1018 (goto-char (point-min)) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1019 (cond ((or (looking-at "No \\(manual \\)*entry for") |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1020 (looking-at "[^\n]*: nothing appropriate$")) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1021 (setq err-mess (buffer-substring (point) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1022 (progn |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1023 (end-of-line) (point))) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1024 delete-buff t)) |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1025 ((or (stringp process) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1026 (not (and (eq (process-status process) 'exit) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1027 (= (process-exit-status process) 0)))) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1028 (or (zerop (length msg)) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1029 (progn |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1030 (setq err-mess |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1031 (concat (buffer-name Man-buffer) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1032 ": process " |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1033 (let ((eos (1- (length msg)))) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1034 (if (= (aref msg eos) ?\n) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1035 (substring msg 0 eos) msg)))) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1036 (goto-char (point-max)) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1037 (insert (format "\nprocess %s" msg)))) |
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1038 )) |
16509
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1039 (if delete-buff |
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1040 (kill-buffer Man-buffer) |
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1041 (if Man-fontify-manpage-flag |
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1042 (Man-fontify-manpage) |
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1043 (Man-cleanup-manpage)) |
88155 | 1044 |
16509
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1045 (run-hooks 'Man-cooked-hook) |
88155 | 1046 (Man-mode) |
1047 | |
1048 (if (not Man-page-list) | |
1049 (let ((args Man-arguments)) | |
1050 (kill-buffer (current-buffer)) | |
1051 (error "Can't find the %s manpage" args))) | |
1052 | |
16509
75d463b202b5
(Man-bgproc-sentinel): Move the buffer creation
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1053 (set-buffer-modified-p nil) |
16973
39569e1b84b2
(Man-build-man-command): When async processes aren't
Eli Zaretskii <eliz@gnu.org>
parents:
16509
diff
changeset
|
1054 )) |
10040
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1055 ;; Restore case-fold-search before calling |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1056 ;; Man-notify-when-ready because it may switch buffers. |
3235 | 1057 |
10040
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1058 (if (not delete-buff) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1059 (Man-notify-when-ready Man-buffer)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1060 |
10040
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1061 (if err-mess |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1062 (error err-mess)) |
c69ddd9fa3a6
(Man-bgproc-sentinel): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9867
diff
changeset
|
1063 )))) |
3235 | 1064 |
1065 | |
1066 ;; ====================================================================== | |
1067 ;; set up manual mode in buffer and build alists | |
1068 | |
88155 | 1069 (put 'Man-mode 'mode-class 'special) |
1070 | |
3235 | 1071 (defun Man-mode () |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
1072 "A mode for browsing Un*x manual pages. |
3235 | 1073 |
28102 | 1074 The following man commands are available in the buffer. Try |
3235 | 1075 \"\\[describe-key] <key> RET\" for more information: |
1076 | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1077 \\[man] Prompt to retrieve a new manpage. |
3235 | 1078 \\[Man-follow-manual-reference] Retrieve reference in SEE ALSO section. |
1079 \\[Man-next-manpage] Jump to next manpage in circular list. | |
1080 \\[Man-previous-manpage] Jump to previous manpage in circular list. | |
1081 \\[Man-next-section] Jump to next manpage section. | |
1082 \\[Man-previous-section] Jump to previous manpage section. | |
1083 \\[Man-goto-section] Go to a manpage section. | |
1084 \\[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
|
1085 \\[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
|
1086 \\[Man-kill] Deletes the manpage window, kill its buffer. |
3235 | 1087 \\[describe-mode] Prints this help text. |
1088 | |
28102 | 1089 The following variables may be of some use. Try |
3235 | 1090 \"\\[describe-variable] <variable-name> RET\" for more information: |
1091 | |
28102 | 1092 `Man-notify-method' What happens when manpage formatting is done. |
1093 `Man-downcase-section-letters-flag' Force section letters to lower case. | |
1094 `Man-circular-pages-flag' Treat multiple manpage list as circular. | |
1095 `Man-section-translations-alist' List of section numbers and their Un*x equiv. | |
1096 `Man-filter-list' Background manpage filter command. | |
1097 `Man-mode-map' Keymap bindings for Man mode buffers. | |
1098 `Man-mode-hook' Normal hook run on entry to Man mode. | |
1099 `Man-section-regexp' Regexp describing manpage section letters. | |
1100 `Man-heading-regexp' Regexp describing section headers. | |
1101 `Man-see-also-regexp' Regexp for SEE ALSO section (or your equiv). | |
1102 `Man-first-heading-regexp' Regexp for first heading on a manpage. | |
1103 `Man-reference-regexp' Regexp matching a references in SEE ALSO. | |
1104 `Man-switches' Background `man' command switches. | |
3235 | 1105 |
1106 The following key bindings are currently in effect in the buffer: | |
1107 \\{Man-mode-map}" | |
1108 (interactive) | |
88155 | 1109 (kill-all-local-variables) |
3235 | 1110 (setq major-mode 'Man-mode |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
1111 mode-name "Man" |
3235 | 1112 buffer-auto-save-file-name nil |
38970
e144797b4ece
(Man-mode-line-format): Variable removed.
Miles Bader <miles@gnu.org>
parents:
38646
diff
changeset
|
1113 mode-line-buffer-identification |
e144797b4ece
(Man-mode-line-format): Variable removed.
Miles Bader <miles@gnu.org>
parents:
38646
diff
changeset
|
1114 (list (default-value 'mode-line-buffer-identification) |
e144797b4ece
(Man-mode-line-format): Variable removed.
Miles Bader <miles@gnu.org>
parents:
38646
diff
changeset
|
1115 " {" 'Man-page-mode-string "}") |
3235 | 1116 truncate-lines t |
1117 buffer-read-only t) | |
88155 | 1118 (buffer-disable-undo) |
3235 | 1119 (auto-fill-mode -1) |
1120 (use-local-map Man-mode-map) | |
17132
07c01fa1e7fc
(man-mode-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17129
diff
changeset
|
1121 (set-syntax-table man-mode-syntax-table) |
88155 | 1122 (setq imenu-generic-expression (list (list nil Man-heading-regexp 0))) |
1123 (set (make-local-variable 'outline-regexp) Man-heading-regexp) | |
1124 (set (make-local-variable 'outline-level) (lambda () 1)) | |
3235 | 1125 (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
|
1126 (Man-strip-page-headers) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1127 (Man-unindent) |
88155 | 1128 (Man-goto-page 1 t) |
1129 (run-mode-hooks 'Man-mode-hook)) | |
3235 | 1130 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1131 (defsubst Man-build-section-alist () |
3235 | 1132 "Build the association list of manpage sections." |
1133 (setq Man-sections-alist nil) | |
1134 (goto-char (point-min)) | |
7450 | 1135 (let ((case-fold-search nil)) |
1136 (while (re-search-forward Man-heading-regexp (point-max) t) | |
41710
6515e3108ceb
(Man-build-section-alist): Remove last Man-match-substring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41698
diff
changeset
|
1137 (aput 'Man-sections-alist (match-string 1)) |
7450 | 1138 (forward-line 1)))) |
3235 | 1139 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1140 (defsubst Man-build-references-alist () |
3235 | 1141 "Build the association list of references (in the SEE ALSO section)." |
1142 (setq Man-refpages-alist nil) | |
1143 (save-excursion | |
1144 (if (Man-find-section Man-see-also-regexp) | |
1145 (let ((start (progn (forward-line 1) (point))) | |
1146 (end (progn | |
1147 (Man-next-section 1) | |
1148 (point))) | |
1149 hyphenated | |
1150 (runningpoint -1)) | |
7450 | 1151 (save-restriction |
1152 (narrow-to-region start end) | |
1153 (goto-char (point-min)) | |
1154 (back-to-indentation) | |
1155 (while (and (not (eobp)) (/= (point) runningpoint)) | |
1156 (setq runningpoint (point)) | |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1157 (if (re-search-forward Man-hyphenated-reference-regexp end t) |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
1158 (let* ((word (match-string 0)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1159 (len (1- (length word)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1160 (if hyphenated |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1161 (setq word (concat hyphenated word) |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1162 hyphenated nil |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1163 ;; Update len, in case a reference spans |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1164 ;; more than two lines (paranoia). |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1165 len (1- (length word)))) |
88155 | 1166 (if (memq (aref word len) '(?- ?)) |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1167 (setq hyphenated (substring word 0 len))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1168 (if (string-match Man-reference-regexp word) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1169 (aput 'Man-refpages-alist word)))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1170 (skip-chars-forward " \t\n,")))))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1171 (setq Man-refpages-alist (nreverse Man-refpages-alist))) |
3235 | 1172 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
1173 (defun Man-build-page-list () |
3235 | 1174 "Build the list of separate manpages in the buffer." |
1175 (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
|
1176 (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
|
1177 (page-end (point-max)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1178 (header "")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1179 (goto-char page-start) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1180 ;; (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
|
1181 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1182 (setq header |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1183 (if (looking-at Man-page-header-regexp) |
41698
722fe545e535
(man-follow-mouse): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38970
diff
changeset
|
1184 (match-string 1) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1185 nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1186 ;; 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
|
1187 (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
|
1188 (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
|
1189 ;; 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
|
1190 ;; 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
|
1191 ;; 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
|
1192 ;; 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
|
1193 ;; previous page header. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1194 (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
|
1195 (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
|
1196 (beginning-of-line)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1197 (setq page-end (point)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1198 (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
|
1199 (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
|
1200 (copy-marker page-end) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1201 header)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1202 (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
|
1203 ))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1204 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
1205 (defun Man-strip-page-headers () |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1206 "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
|
1207 (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
|
1208 (case-fold-search nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1209 (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
|
1210 (page ()) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1211 (header "")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1212 (while page-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1213 (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
|
1214 (and (nth 2 page) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1215 (goto-char (car page)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1216 (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
|
1217 (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
|
1218 ;; 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
|
1219 ;; 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
|
1220 ;; 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
|
1221 ;; 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
|
1222 ;; 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
|
1223 ;; 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
|
1224 ;; line. |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1225 ;; (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
|
1226 (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
|
1227 (replace-match ""))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1228 (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
|
1229 |
9354
1ce43418547c
* man.el (Man-notify, Man-current-page, Man-page-list,
Francesco Potortì <pot@gnu.org>
parents:
9210
diff
changeset
|
1230 (defun Man-unindent () |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1231 "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
|
1232 (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
|
1233 (case-fold-search nil) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1234 (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
|
1235 (while page-list |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1236 (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
|
1237 (indent "") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1238 (nindent 0)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1239 (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
|
1240 (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
|
1241 (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
|
1242 (if (catch 'unindent |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1243 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1244 (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
|
1245 (throw 'unindent nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1246 (beginning-of-line) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1247 (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
|
1248 (progn |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1249 (skip-chars-forward " ") |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1250 (point)))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1251 (setq nindent (length indent)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1252 (if (zerop nindent) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1253 (throw 'unindent nil)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1254 (setq indent (concat indent "\\|$")) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1255 (goto-char (point-min)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1256 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1257 (if (looking-at indent) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1258 (forward-line 1) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1259 (throw 'unindent nil))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1260 (goto-char (point-min))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1261 (while (not (eobp)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1262 (or (eolp) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1263 (delete-char nindent)) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1264 (forward-line 1))) |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1265 (setq page-list (cdr page-list)) |
7450 | 1266 )))) |
3235 | 1267 |
1268 | |
1269 ;; ====================================================================== | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1270 ;; Man mode commands |
3235 | 1271 |
1272 (defun Man-next-section (n) | |
1273 "Move point to Nth next section (default 1)." | |
1274 (interactive "p") | |
7450 | 1275 (let ((case-fold-search nil)) |
1276 (if (looking-at Man-heading-regexp) | |
1277 (forward-line 1)) | |
1278 (if (re-search-forward Man-heading-regexp (point-max) t n) | |
1279 (beginning-of-line) | |
1280 (goto-char (point-max))))) | |
3235 | 1281 |
1282 (defun Man-previous-section (n) | |
1283 "Move point to Nth previous section (default 1)." | |
1284 (interactive "p") | |
7450 | 1285 (let ((case-fold-search nil)) |
1286 (if (looking-at Man-heading-regexp) | |
1287 (forward-line -1)) | |
1288 (if (re-search-backward Man-heading-regexp (point-min) t n) | |
1289 (beginning-of-line) | |
1290 (goto-char (point-min))))) | |
3235 | 1291 |
1292 (defun Man-find-section (section) | |
1293 "Move point to SECTION if it exists, otherwise don't move point. | |
1294 Returns t if section is found, nil otherwise." | |
7450 | 1295 (let ((curpos (point)) |
1296 (case-fold-search nil)) | |
3235 | 1297 (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
|
1298 (if (re-search-forward (concat "^" section) (point-max) t) |
3235 | 1299 (progn (beginning-of-line) t) |
1300 (goto-char curpos) | |
1301 nil) | |
1302 )) | |
1303 | |
1304 (defun Man-goto-section () | |
1305 "Query for section to move point to." | |
1306 (interactive) | |
1307 (aput 'Man-sections-alist | |
1308 (let* ((default (aheadsym Man-sections-alist)) | |
1309 (completion-ignore-case t) | |
1310 chosen | |
88155 | 1311 (prompt (concat "Go to section (default " default "): "))) |
3235 | 1312 (setq chosen (completing-read prompt Man-sections-alist)) |
1313 (if (or (not chosen) | |
1314 (string= chosen "")) | |
1315 default | |
1316 chosen))) | |
1317 (Man-find-section (aheadsym Man-sections-alist))) | |
1318 | |
1319 (defun Man-goto-see-also-section () | |
42706 | 1320 "Move point to the \"SEE ALSO\" section. |
3909
192e7aa8389a
(Man-auto-section-alist): Default value nil.
Richard M. Stallman <rms@gnu.org>
parents:
3833
diff
changeset
|
1321 Actually the section moved to is described by `Man-see-also-regexp'." |
3235 | 1322 (interactive) |
1323 (if (not (Man-find-section Man-see-also-regexp)) | |
1324 (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
|
1325 " section found in the current manpage")))) |
3235 | 1326 |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1327 (defun Man-possibly-hyphenated-word () |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1328 "Return a possibly hyphenated word at point. |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1329 If the word starts at the first non-whitespace column, and the |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1330 previous line ends with a hyphen, return the last word on the previous |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1331 line instead. Thus, if a reference to \"tcgetpgrp(3V)\" is hyphenated |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1332 as \"tcgetp-grp(3V)\", and point is at \"grp(3V)\", we return |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1333 \"tcgetp-\" instead of \"grp\"." |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1334 (save-excursion |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1335 (skip-syntax-backward "w()") |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1336 (skip-chars-forward " \t") |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1337 (let ((beg (point)) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1338 (word (current-word))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1339 (when (eq beg (save-excursion |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1340 (back-to-indentation) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1341 (point))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1342 (end-of-line 0) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1343 (if (eq (char-before) ?-) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1344 (setq word (current-word)))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1345 word))) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1346 |
9838
5fbd6165b408
(Man-follow-manual-reference): First arg deleted. Call
Karl Heuer <kwzh@gnu.org>
parents:
9828
diff
changeset
|
1347 (defun Man-follow-manual-reference (reference) |
3235 | 1348 "Get one of the manpages referred to in the \"SEE ALSO\" section. |
28102 | 1349 Specify which REFERENCE to use; default is based on word at point." |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1350 (interactive |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1351 (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
|
1352 (error "There are no references in the current man page") |
9838
5fbd6165b408
(Man-follow-manual-reference): First arg deleted. Call
Karl Heuer <kwzh@gnu.org>
parents:
9828
diff
changeset
|
1353 (list (let* ((default (or |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1354 (car (all-completions |
88155 | 1355 (let ((word |
1356 (or (Man-possibly-hyphenated-word) | |
1357 ""))) | |
36575
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1358 ;; strip a trailing '-': |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1359 (if (string-match "-$" word) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1360 (substring word 0 |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1361 (match-beginning 0)) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1362 word)) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1363 Man-refpages-alist)) |
5394dc1db9f4
(Man-hyphenated-reference-regexp): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
35603
diff
changeset
|
1364 (aheadsym Man-refpages-alist))) |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1365 chosen |
88155 | 1366 (prompt (concat "Refer to (default " default "): "))) |
1367 (setq chosen (completing-read prompt Man-refpages-alist)) | |
5269
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1368 (if (or (not chosen) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1369 (string= chosen "")) |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1370 default |
c6588bd7dd93
(Man-specified-section-option): Test system-configuration.
Richard M. Stallman <rms@gnu.org>
parents:
5108
diff
changeset
|
1371 chosen))))) |
3235 | 1372 (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
|
1373 (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
|
1374 (aput 'Man-refpages-alist reference) |
3235 | 1375 (Man-getpage-in-background |
9838
5fbd6165b408
(Man-follow-manual-reference): First arg deleted. Call
Karl Heuer <kwzh@gnu.org>
parents:
9828
diff
changeset
|
1376 (Man-translate-references (aheadsym Man-refpages-alist))))) |
3235 | 1377 |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1378 (defun Man-kill () |
3235 | 1379 "Kill the buffer containing the manpage." |
1380 (interactive) | |
22368
c3a15ab5924f
(Man-kill, Man-quit): Use quit-window.
Richard M. Stallman <rms@gnu.org>
parents:
22217
diff
changeset
|
1381 (quit-window t)) |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1382 |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1383 (defun Man-quit () |
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1384 "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
|
1385 (interactive) |
22368
c3a15ab5924f
(Man-kill, Man-quit): Use quit-window.
Richard M. Stallman <rms@gnu.org>
parents:
22217
diff
changeset
|
1386 (quit-window)) |
3235 | 1387 |
88155 | 1388 (defun Man-goto-page (page &optional noerror) |
3235 | 1389 "Go to the manual page on page PAGE." |
1390 (interactive | |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1391 (if (not Man-page-list) |
88155 | 1392 (error "Not a man page buffer") |
8970
c0a15f821bd8
* man.el (Man-notify-flag): replaces the old Man-notify
Francesco Potortì <pot@gnu.org>
parents:
8697
diff
changeset
|
1393 (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
|
1394 (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
|
1395 (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
|
1396 (length Man-page-list))))))) |
88155 | 1397 (if (and (not Man-page-list) (not noerror)) |
1398 (error "Not a man page buffer")) | |
1399 (when Man-page-list | |
1400 (if (or (< page 1) | |
1401 (> page (length Man-page-list))) | |
1402 (error "No manpage %d found" page)) | |
1403 (let* ((page-range (nth (1- page) Man-page-list)) | |
1404 (page-start (car page-range)) | |
1405 (page-end (car (cdr page-range)))) | |
1406 (setq Man-current-page page | |
1407 Man-page-mode-string (Man-make-page-mode-string)) | |
1408 (widen) | |
1409 (goto-char page-start) | |
1410 (narrow-to-region page-start page-end) | |
1411 (Man-build-section-alist) | |
1412 (Man-build-references-alist) | |
1413 (goto-char (point-min))))) | |
3235 | 1414 |
1415 | |
1416 (defun Man-next-manpage () | |
1417 "Find the next manpage entry in the buffer." | |
1418 (interactive) | |
1419 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1420 (error "This is the only manpage in the buffer")) |
3235 | 1421 (if (< Man-current-page (length Man-page-list)) |
1422 (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
|
1423 (if Man-circular-pages-flag |
3235 | 1424 (Man-goto-page 1) |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1425 (error "You're looking at the last manpage in the buffer")))) |
3235 | 1426 |
1427 (defun Man-previous-manpage () | |
1428 "Find the previous manpage entry in the buffer." | |
1429 (interactive) | |
1430 (if (= (length Man-page-list) 1) | |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1431 (error "This is the only manpage in the buffer")) |
3235 | 1432 (if (> Man-current-page 1) |
1433 (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
|
1434 (if Man-circular-pages-flag |
3235 | 1435 (Man-goto-page (length Man-page-list)) |
7499
b3cacdf7bbfa
Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
7453
diff
changeset
|
1436 (error "You're looking at the first manpage in the buffer")))) |
88155 | 1437 |
1438 ;; Header file support | |
1439 (defun Man-view-header-file (file) | |
1440 "View a header file specified by FILE from `Man-header-file-path'." | |
1441 (let ((path Man-header-file-path) | |
1442 complete-path) | |
1443 (while path | |
1444 (setq complete-path (concat (car path) "/" file) | |
1445 path (cdr path)) | |
1446 (if (file-readable-p complete-path) | |
1447 (progn (view-file complete-path) | |
1448 (setq path nil)) | |
1449 (setq complete-path nil))) | |
1450 complete-path)) | |
3833
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
1451 |
14672
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1452 ;; Init the man package variables, if not already done. |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1453 (Man-init-defvars) |
9556c7cfabe4
(man): Don't call Man-init-defvars here.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1454 |
28102 | 1455 (add-to-list 'debug-ignored-errors "^No manpage [0-9]* found$") |
1456 (add-to-list 'debug-ignored-errors "^Can't find the .* manpage$") | |
1457 | |
3833
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
1458 (provide 'man) |
70551a213fae
* man.el (Man-switches): New variable.
Jim Blandy <jimb@redhat.com>
parents:
3714
diff
changeset
|
1459 |
88155 | 1460 ;; arch-tag: 587cda76-8e23-4594-b1f3-89b6b09a0d47 |
3235 | 1461 ;;; man.el ends here |