annotate lisp/man.el @ 7453:9b14642f7d52

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