annotate lisp/man.el @ 5108:8c482171bb10

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