annotate lisp/help.el @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 74fd4e045ea6
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; help.el --- help commands for XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Keywords: help, internal, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;;; Synched up with: FSF 19.30.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27 ;;; Commentary:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
28
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31 ;; This code implements XEmacs's on-line help system, the one invoked by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;;`M-x help-for-help'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; 06/11/1997 -- Converted to use char-after instead of broken
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 ;; following-char. -slb
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 ;; Get the macro make-help-screen when this is compiled,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 ;; or run interpreted, but not when the compiled code is loaded.
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
41 (eval-when-compile (require 'help-macro))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
43 (defgroup help nil
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
44 "Support for on-line help systems."
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
45 :group 'emacs)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
46
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 (defgroup help-appearance nil
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
48 "Appearance of help buffers."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 :group 'help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 (defvar help-map (let ((map (make-sparse-keymap)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 (set-keymap-name map 'help-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 (set-keymap-prompt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 map (purecopy (gettext "(Type ? for further options)")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55 map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 "Keymap for characters following the Help key.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 ;; global-map definitions moved to keydefs.el
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 (fset 'help-command help-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 (define-key help-map (vector help-char) 'help-for-help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 (define-key help-map "?" 'help-for-help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 (define-key help-map 'help 'help-for-help)
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 239
diff changeset
64 (define-key help-map '(f1) 'help-for-help)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 (define-key help-map "\C-d" 'describe-distribution)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 (define-key help-map "\C-w" 'describe-no-warranty)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (define-key help-map "A" 'command-apropos)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 (define-key help-map "b" 'describe-bindings)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 (define-key help-map "B" 'describe-beta)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 (define-key help-map "\C-p" 'describe-pointer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 (define-key help-map "C" 'customize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 (define-key help-map "c" 'describe-key-briefly)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 (define-key help-map "k" 'describe-key)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 (define-key help-map "d" 'describe-function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 (define-key help-map "e" 'describe-last-error)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 (define-key help-map "f" 'describe-function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84 (define-key help-map "F" 'xemacs-local-faq)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86 (define-key help-map "i" 'info)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 (define-key help-map '(control i) 'Info-query)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 ;; for Info-elisp-ref
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 (define-key help-map '(control c) 'Info-goto-emacs-command-node)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 (define-key help-map '(control k) 'Info-goto-emacs-key-command-node)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 (define-key help-map '(control f) 'Info-elisp-ref)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 (define-key help-map "l" 'view-lossage)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (define-key help-map "m" 'describe-mode)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 (define-key help-map "\C-n" 'view-emacs-news)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 (define-key help-map "n" 'view-emacs-news)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 (define-key help-map "p" 'finder-by-keyword)
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
102
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
103 ;; Do this right with an autoload cookie in finder.el.
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
104 ;;(autoload 'finder-by-keyword "finder"
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
105 ;; "Find packages matching a given keyword." t)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (define-key help-map "s" 'describe-syntax)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 (define-key help-map "t" 'help-with-tutorial)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 (define-key help-map "w" 'where-is)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 (define-key help-map "v" 'describe-variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (if (fboundp 'view-last-error)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 (define-key help-map "e" 'view-last-error))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 (define-key help-map "q" 'help-quit)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121 ;#### This stuff was an attempt to have font locking and hyperlinks in the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 ;help buffer, but it doesn't really work. Some of this stuff comes from
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 ;FSF Emacs; but the FSF Emacs implementation is rather broken, as usual.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 ;What needs to happen is this:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 ;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 ; -- we probably need a "hyperlink mode" from which help-mode is derived.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 ; -- this means we probably need multiple inheritance of modes!
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 ; Thankfully this is not hard to implement; we already have the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 ; ability for a keymap to have multiple parents. However, we'd
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 ; have to define any multiply-inherited-from modes using a standard
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 ; `define-mode' construction instead of manually doing it, because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 ; we don't want each guy calling `kill-all-local-variables' and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 ; messing up the previous one.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 ; -- we need to scan the buffer ourselves (not from font-lock, because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 ; the user might not have font-lock enabled) and highlight only
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 ; those words that are *documented* functions and variables (and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 ; probably excluding words without dashes in them unless enclosed
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 ; in quotes, so that common words like "list" and "point" don't
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 ; become hyperlinks.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 ; -- we should *not* use font-lock keywords like below. Instead we
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141 ; should add the font-lock stuff ourselves during the scanning phase,
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
142 ; if font-lock is enabled in this buffer.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 ;(defun help-follow-reference (event extent user-data)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 ; (let ((symbol (intern-soft (extent-string extent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 ; (cond ((and symbol (fboundp symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 ; (describe-function symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 ; ((and symbol (boundp symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 ; (describe-variable symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 ; (t nil))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 ;(defvar help-font-lock-keywords
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 ; (let ((name-char "[-+a-zA-Z0-9_*]") (sym-char "[-+a-zA-Z0-9_:*]"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 ; (list
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 ; ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 ; ;; The symbol itself.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 ; (list (concat "\\`\\(" name-char "+\\)\\(:\\)?")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 ; '(1 (if (match-beginning 2)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 ; 'font-lock-function-name-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 ; 'font-lock-variable-name-face)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161 ; nil t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 ; ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 ; ;; Words inside `' which tend to be symbol names.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164 ; (list (concat "`\\(" sym-char sym-char "+\\)'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 ; 1 '(prog1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 ; 'font-lock-reference-face
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 ; (add-list-mode-item (match-beginning 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 ; (match-end 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 ; nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 ; 'help-follow-reference))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 ; t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 ; ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 ; ;; CLisp `:' keywords as references.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 ; (list (concat "\\<:" sym-char "+\\>") 0 'font-lock-reference-face t)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 ; "Default expressions to highlight in Help mode.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 ;(put 'help-mode 'font-lock-defaults '(help-font-lock-keywords))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179 (define-derived-mode help-mode view-major-mode "Help"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 "Major mode for viewing help text.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 Entry to this mode runs the normal hook `help-mode-hook'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 Commands:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 \\{help-mode-map}"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 (define-key help-mode-map "q" 'help-mode-quit)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
187 (define-key help-mode-map "Q" 'help-mode-bury)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 (define-key help-mode-map "f" 'find-function-at-point)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
189 (define-key help-mode-map "d" 'describe-function-at-point)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
190 (define-key help-mode-map "v" 'describe-variable-at-point)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
191 (define-key help-mode-map "i" 'Info-elisp-ref)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
192 (define-key help-mode-map "c" 'customize-variable)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
193 (define-key help-mode-map [tab] 'help-next-symbol)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
194 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
195 (define-key help-mode-map "n" 'help-next-section)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
196 (define-key help-mode-map "p" 'help-prev-section)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 (defun describe-function-at-point ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 "Describe directly the function at point in the other window."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 (let ((symb (function-at-point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202 (when symb
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 (describe-function symb))))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
204
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 (defun describe-variable-at-point ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 "Describe directly the variable at point in the other window."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 (let ((symb (variable-at-point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209 (when symb
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 (describe-variable symb))))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
211
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 (defun help-next-symbol ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 "Move point to the next quoted symbol."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 (search-forward "`" nil t))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
216
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 (defun help-prev-symbol ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 "Move point to the previous quoted symbol."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 (search-backward "'" nil t))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
221
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
222 (defun help-next-section ()
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
223 "Move point to the next quoted symbol."
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
224 (interactive)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
225 (search-forward-regexp "^\\w+:" nil t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
227 (defun help-prev-section ()
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
228 "Move point to the previous quoted symbol."
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
229 (interactive)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
230 (search-backward-regexp "^\\w+:" nil t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
232 (defun help-mode-bury ()
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
233 "Bury the help buffer, possibly restoring the previous window configuration."
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
234 (interactive)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
235 (help-mode-quit t))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
236
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
237 (defun help-mode-quit (&optional bury)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
238 "Exit from help mode, possibly restoring the previous window configuration.
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
239 If the optional argument BURY is non-nil, the help buffer is buried,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
240 otherwise it is killed."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (let ((buf (current-buffer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 (cond ((frame-property (selected-frame) 'help-window-config)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (set-window-configuration
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 (frame-property (selected-frame) 'help-window-config))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (set-frame-property (selected-frame) 'help-window-config nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 ((not (one-window-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 (delete-window)))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
249 (if bury
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
250 (bury-buffer buf)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
251 (kill-buffer buf))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 (defun help-quit ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257 ;; This is a grody hack of the same genotype as `advertised-undo'; if the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 ;; bindings of Backspace and C-h are the same, we want the menubar to claim
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 369
diff changeset
259 ;; that `info' in invoked with `C-h i', not `BS i'.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261 (defun deprecated-help-command ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 (if (eq 'help-command (key-binding "\C-h"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 (setq unread-command-event (character-to-event ?\C-h))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 (help-for-help)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 ;;(define-key global-map 'backspace 'deprecated-help-command)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 ;; This function has been moved to help-nomule.el and mule-help.el.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 ;; TUTORIAL arg is XEmacs addition
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 ;(defun help-with-tutorial (&optional tutorial)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 ; "Select the XEmacs learn-by-doing tutorial.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 ;Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\"."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 ; (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275 ; (if (null tutorial)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 ; (setq tutorial "TUTORIAL"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 ; (let ((file (expand-file-name (concat "~/" tutorial))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 ; (delete-other-windows)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 ; (if (get-file-buffer file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 ; (switch-to-buffer (get-file-buffer file))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281 ; (switch-to-buffer (create-file-buffer file))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282 ; (setq buffer-file-name file)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 ; (setq default-directory (expand-file-name "~/"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 ; (setq buffer-auto-save-file-name nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 ; (insert-file-contents (expand-file-name tutorial data-directory))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 ; (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 ; (search-forward "\n<<")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 ; (delete-region (point-at-bol) (point-at-eol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 ; (let ((n (- (window-height (selected-window))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290 ; (count-lines (point-min) (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 ; 6)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 ; (if (< n 12)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 ; (newline n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 ; ;; Some people get confused by the large gap.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 ; (newline (/ n 2))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 ; (insert "[Middle of page left blank for didactic purposes. "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 ; "Text continues below]")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 ; (newline (- n (/ n 2)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 ; (goto-char (point-min))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 ; (set-buffer-modified-p nil))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 (defun key-or-menu-binding (key &optional menu-flag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 "Return the command invoked by KEY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 Like `key-binding', but handles menu events and toolbar presses correctly.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 KEY is any value returned by `next-command-event'.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
308 MENU-FLAG is a symbol that should be set to t if KEY is a menu event,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
309 or nil otherwise"
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 (let (defn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311 (and menu-flag (set menu-flag nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 ;; If the key typed was really a menu selection, grab the form out
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313 ;; of the event object and intuit the function that would be called,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 ;; and describe that instead.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 (if (and (vectorp key) (= 1 (length key))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 (or (misc-user-event-p (aref key 0))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (eq (car-safe (aref key 0)) 'menu-selection)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 (let ((event (aref key 0)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319 (setq defn (if (eventp event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 (list (event-function event) (event-object event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321 (cdr event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 (and menu-flag (set menu-flag t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 (when (eq (car defn) 'eval)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 (setq defn (car (cdr defn))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 (when (eq (car-safe defn) 'call-interactively)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 (setq defn (car (cdr defn))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 (when (and (consp defn) (null (cdr defn)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 (setq defn (car defn))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 ;; else
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 (setq defn (key-binding key)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 ;; kludge: if a toolbar button was pressed on, try to find the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 ;; binding of the toolbar button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 (if (and (eq defn 'press-toolbar-button)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 (vectorp key)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 (button-press-event-p (aref key (1- (length key)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 ;; wait for the button release. We're on shaky ground here ...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 (let ((event (next-command-event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338 button)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 (if (and (button-release-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 (event-over-toolbar-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341 (eq 'release-and-activate-toolbar-button
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342 (key-binding (vector event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 (setq button (event-toolbar-button event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344 (toolbar-button-callback button)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 ;; if anything went wrong, try returning the binding of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 ;; the button-up event, of the original binding
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 (or (key-or-menu-binding (vector event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348 defn)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349 ;; no toolbar kludge
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350 defn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
351 ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
353 (defun describe-key-briefly (key &optional insert)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
354 "Print the name of the function KEY invokes. KEY is a string.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
355 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
356 (interactive "kDescribe key briefly: \nP")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
357 (let ((standard-output (if insert (current-buffer) t))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
358 defn menup)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
359 (setq defn (key-or-menu-binding key 'menup))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 (if (or (null defn) (integerp defn))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
361 (princ (format "%s is undefined" (key-description key)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 ;; If it's a keyboard macro which trivially invokes another command,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 ;; document that instead.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 (if (or (stringp defn) (vectorp defn))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 (setq defn (or (key-binding defn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 defn)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 (let ((last-event (and (vectorp key)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 (aref key (1- (length key))))))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
369 (princ (format (cond (insert
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
370 "%s (%s)")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
371 ((or (button-press-event-p last-event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
372 (button-release-event-p last-event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
373 (gettext "%s at that spot runs the command %s"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
374 (t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
375 (gettext "%s runs the command %s")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
376 ;; This used to say 'This menu item' but it
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
377 ;; could also be a scrollbar event. We can't
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
378 ;; distinguish at the moment.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
379 (if menup
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
380 (if insert "item" "This item")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
381 (key-description key))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
382 (if (symbolp defn) defn (prin1-to-string defn))))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 ;; #### this is a horrible piece of shit function that should
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 ;; not exist. In FSF 19.30 this function has gotten three times
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 ;; as long and has tons and tons of dumb shit checking
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 ;; special-display-buffer-names and such crap. I absolutely
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 ;; refuse to insert that Ebolification here. I wanted to delete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 ;; this function entirely but Mly bitched.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 ;; If your user-land code calls this function, rewrite it to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 ;; call with-displaying-help-buffer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 (defun print-help-return-message (&optional function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 "Display or return message saying how to restore windows after help command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 Computes a message and applies the optional argument FUNCTION to it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 If FUNCTION is nil, applies `message' to it, thus printing it."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (and (not (get-buffer-window standard-output))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (funcall
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 (or function 'message)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 (concat
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (substitute-command-keys
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 (if (one-window-p t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 (if pop-up-windows
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 (gettext "Type \\[delete-other-windows] to remove help window.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407 (gettext "Type \\[switch-to-buffer-other-window] RET to restore the other window.")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 (substitute-command-keys
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
409 (gettext " \\[scroll-other-window] to scroll the help."))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
410
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
411 (defcustom help-selects-help-window t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
412 "*If nil, use the \"old Emacs\" behavior for Help buffers.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
413 This just displays the buffer in another window, rather than selecting
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
414 the window."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
415 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
416 :group 'help-appearance)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
417
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
418 (defcustom help-max-help-buffers 10
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
419 "*Maximum help buffers to allow before they start getting killed.
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
420 If this is a positive integer, before a help buffer is displayed
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
421 by `with-displaying-help-buffer', any excess help buffers which
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
422 are not being displayed are first killed. Otherwise, if it is
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
423 zero or nil, only one help buffer, \"*Help*\" is ever used."
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
424 :type '(choice integer (const :tag "None" nil))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
425 :group 'help-appearance)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
426
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
427 (defvar help-buffer-list nil
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
428 "List of help buffers used by `help-register-and-maybe-prune-excess'")
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
429
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
430 (defun help-register-and-maybe-prune-excess (newbuf)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
431 "Register use of a help buffer and possibly kill any excess ones."
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
432 ;; remove new buffer from list
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
433 (setq help-buffer-list (remove newbuf help-buffer-list))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
434 ;; maybe kill excess help buffers
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
435 (if (and (integerp help-max-help-buffers)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
436 (> (length help-buffer-list) help-max-help-buffers))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
437 (let ((keep-list nil)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
438 (num-kill (- (length help-buffer-list)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
439 help-max-help-buffers)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
440 (while help-buffer-list
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
441 (let ((buf (car help-buffer-list)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
442 (if (and (or (equal buf newbuf) (get-buffer buf))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
443 (string-match "^*Help" buf)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
444 (save-excursion (set-buffer buf)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
445 (eq major-mode 'help-mode)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
446 (if (and (>= num-kill (length help-buffer-list))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
447 (not (get-buffer-window buf t t)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
448 (kill-buffer buf)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
449 (setq keep-list (cons buf keep-list)))))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
450 (setq help-buffer-list (cdr help-buffer-list)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
451 (setq help-buffer-list (nreverse keep-list))))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
452 ;; push new buffer
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
453 (setq help-buffer-list (cons newbuf help-buffer-list)))
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
454
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
455 (defvar help-buffer-prefix-string "Help"
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
456 "Initial string to use in constructing help buffer names.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
457 You should never set this directory, only let-bind it.")
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
458
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
459 (defun help-buffer-name (name)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
460 "Return a name for a Help buffer using string NAME for context."
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
461 (if (and (integerp help-max-help-buffers)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
462 (> help-max-help-buffers 0)
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
463 (stringp name))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
464 (if help-buffer-prefix-string
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
465 (format "*%s: %s*" help-buffer-prefix-string name)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
466 (format "*%s*" name))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
467 (format "*%s*" help-buffer-prefix-string)))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
468
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
469 ;; Use this function for displaying help when C-h something is pressed
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
470 ;; or in similar situations. Do *not* use it when you are displaying
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
471 ;; a help message and then prompting for input in the minibuffer --
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472 ;; this macro usually selects the help buffer, which is not what you
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 ;; want in those situations.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
474
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
475 ;; #### Should really be a macro to eliminate the requirement of
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
476 ;; caller to code a lambda form in THUNK -- mrb
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
477
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
478 ;; #### BEFORE you rush to make this a macro, think about backward
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
479 ;; compatibility. The right way would be to create a macro with
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
480 ;; another name (which is a shame, because w-d-h-b is a perfect name
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
481 ;; for a macro) that uses with-displaying-help-buffer internally.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
482
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
483 (defun with-displaying-help-buffer (thunk &optional name)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
484 "Form which makes a help buffer with given NAME and evaluates BODY there.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
485 The actual name of the buffer is generated by the function `help-buffer-name'."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
486 (let* ((winconfig (current-window-configuration))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
487 (was-one-window (one-window-p))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
488 (buffer-name (help-buffer-name name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
489 (help-not-visible
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
490 (not (and (windows-of-buffer buffer-name) ;shortcut
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
491 (memq (selected-frame)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
492 (mapcar 'window-frame
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
493 (windows-of-buffer buffer-name)))))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
494 (help-register-and-maybe-prune-excess buffer-name)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
495 (prog1 (with-output-to-temp-buffer buffer-name
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
496 (prog1 (funcall thunk)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
497 (save-excursion
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
498 (set-buffer standard-output)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
499 (help-mode))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
500 (let ((helpwin (get-buffer-window buffer-name)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
501 (when helpwin
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
502 (with-current-buffer (window-buffer helpwin)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
503 ;; If the *Help* buffer is already displayed on this
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
504 ;; frame, don't override the previous configuration
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
505 (when help-not-visible
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
506 (set-frame-property (selected-frame)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
507 'help-window-config winconfig)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
508 (when help-selects-help-window
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
509 (select-window helpwin))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
510 (cond ((eq helpwin (selected-window))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
511 (display-message 'command
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
512 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
513 (was-one-window
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
514 (display-message 'command
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
515 (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
516 (t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
517 (display-message 'command
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
518 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
519
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
520 (defun describe-key (key)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
521 "Display documentation of the function invoked by KEY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
522 KEY is a string, or vector of events.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
523 When called interactively, KEY may also be a menu selection."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
524 (interactive "kDescribe key: ")
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
525 (let ((defn (key-or-menu-binding key))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
526 (key-string (key-description key)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
527 (if (or (null defn) (integerp defn))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
528 (message "%s is undefined" key-string)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
529 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
530 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
531 (princ key-string)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
532 (princ " runs ")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
533 (if (symbolp defn)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
534 (princ (format "`%s'" defn))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
535 (princ defn))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
536 (princ "\n\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
537 (cond ((or (stringp defn) (vectorp defn))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
538 (let ((cmd (key-binding defn)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
539 (if (not cmd)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
540 (princ "a keyboard macro")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
541 (progn
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
542 (princ "a keyboard macro which runs the command ")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
543 (princ cmd)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
544 (princ ":\n\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
545 (if (documentation cmd) (princ (documentation cmd)))))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
546 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
547 (let ((describe-function-show-arglist nil))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
548 (describe-function-1 (car defn))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
549 ((symbolp defn)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
550 (describe-function-1 defn))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
551 ((documentation defn)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
552 (princ (documentation defn)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
553 (t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
554 (princ "not documented"))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
555 (format "key `%s'" key-string)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
556
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
557 (defun describe-mode ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
558 "Display documentation of current major mode and minor modes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
559 For this to work correctly for a minor mode, the mode's indicator variable
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
560 \(listed in `minor-mode-alist') must also be a function whose documentation
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
561 describes the minor mode."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
562 (interactive)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
563 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
564 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
565 ;; XEmacs change: print the major-mode documentation before
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
566 ;; the minor modes.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
567 (princ mode-name)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
568 (princ " mode:\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
569 (princ (documentation major-mode))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
570 (princ "\n\n----\n\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
571 (let ((minor-modes minor-mode-alist))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
572 (while minor-modes
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
573 (let* ((minor-mode (car (car minor-modes)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
574 (indicator (car (cdr (car minor-modes)))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
575 ;; Document a minor mode if it is listed in minor-mode-alist,
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
576 ;; bound locally in this buffer, non-nil, and has a function
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
577 ;; definition.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
578 (if (and (boundp minor-mode)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
579 (symbol-value minor-mode)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
580 (fboundp minor-mode))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
581 (let ((pretty-minor-mode minor-mode))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
582 (if (string-match "-mode\\'" (symbol-name minor-mode))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
583 (setq pretty-minor-mode
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
584 (capitalize
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
585 (substring (symbol-name minor-mode)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
586 0 (match-beginning 0)))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
587 (while (and (consp indicator) (extentp (car indicator)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
588 (setq indicator (cdr indicator)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
589 (while (and indicator (symbolp indicator))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
590 (setq indicator (symbol-value indicator)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
591 (princ (format "%s minor mode (indicator%s):\n"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
592 pretty-minor-mode indicator))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
593 (princ (documentation minor-mode))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
594 (princ "\n\n----\n\n"))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
595 (setq minor-modes (cdr minor-modes)))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
596 (format "%s mode" mode-name)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
597
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
598 ;; So keyboard macro definitions are documented correctly
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
599 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
600
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
601 (defun describe-distribution ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
602 "Display info on how to obtain the latest version of XEmacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
603 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
604 (find-file-read-only
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
605 (locate-data-file "DISTRIB")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
606
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
607 (defun describe-beta ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
608 "Display info on how to deal with Beta versions of XEmacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
609 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
610 (find-file-read-only
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
611 (locate-data-file "BETA"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
612 (goto-char (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
613
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
614 (defun describe-copying ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
615 "Display info on how you may redistribute copies of XEmacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
616 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
617 (find-file-read-only
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
618 (locate-data-file "COPYING"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
619 (goto-char (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
620
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
621 (defun describe-pointer ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
622 "Show a list of all defined mouse buttons, and their definitions."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
623 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
624 (describe-bindings nil t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
625
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
626 (defun describe-project ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
627 "Display info on the GNU project."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
628 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
629 (find-file-read-only
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
630 (locate-data-file "GNU"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
631 (goto-char (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
632
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
633 (defun describe-no-warranty ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
634 "Display info on all the kinds of warranty XEmacs does NOT have."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
635 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
636 (describe-copying)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
637 (let (case-fold-search)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
638 (search-forward "NO WARRANTY")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
639 (recenter 0)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
640
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
641 (defun describe-bindings (&optional prefix mouse-only-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
642 "Show a list of all defined keys, and their definitions.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
643 The list is put in a buffer, which is displayed.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
644 If the optional argument PREFIX is supplied, only commands which
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
645 start with that sequence of keys are described.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
646 If the second argument (prefix arg, interactively) is non-null
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
647 then only the mouse bindings are displayed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
648 (interactive (list nil current-prefix-arg))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
649 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
650 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
651 (describe-bindings-1 prefix mouse-only-p))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
652 (format "bindings for %s" major-mode)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
653
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
654 (defun describe-bindings-1 (&optional prefix mouse-only-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
655 (let ((heading (if mouse-only-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
656 (gettext "button binding\n------ -------\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
657 (gettext "key binding\n--- -------\n")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
658 (buffer (current-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
659 (minor minor-mode-map-alist)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
660 (extent-maps (mapcar-extents
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
661 'extent-keymap
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
662 nil (current-buffer) (point) (point) nil 'keymap))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
663 (local (current-local-map))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
664 (shadow '()))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
665 (set-buffer standard-output)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
666 (while extent-maps
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
667 (insert "Bindings for Text Region:\n"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
668 heading)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
669 (describe-bindings-internal
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
670 (car extent-maps) nil shadow prefix mouse-only-p)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
671 (insert "\n")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
672 (setq shadow (cons (car extent-maps) shadow)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
673 extent-maps (cdr extent-maps)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
674 (while minor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
675 (let ((sym (car (car minor)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
676 (map (cdr (car minor))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
677 (if (symbol-value-in-buffer sym buffer nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
678 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
679 (insert (format "Minor Mode Bindings for `%s':\n"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
680 sym)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
681 heading)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
682 (describe-bindings-internal map nil shadow prefix mouse-only-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
683 (insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
684 (setq shadow (cons map shadow))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
685 (setq minor (cdr minor))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
686 (if local
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
687 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
688 (insert "Local Bindings:\n" heading)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
689 (describe-bindings-internal local nil shadow prefix mouse-only-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
690 (insert "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
691 (setq shadow (cons local shadow))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
692 (insert "Global Bindings:\n" heading)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
693 (describe-bindings-internal (current-global-map)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
694 nil shadow prefix mouse-only-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
695 (when (and prefix function-key-map (not mouse-only-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
696 (insert "\nFunction key map translations:\n" heading)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
697 (describe-bindings-internal function-key-map nil nil
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
698 prefix mouse-only-p))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
699 (set-buffer buffer)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
700 standard-output))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
701
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
702 (defun describe-prefix-bindings ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
703 "Describe the bindings of the prefix used to reach this command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
704 The prefix described consists of all but the last event
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
705 of the key sequence that ran this command."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
706 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
707 (let* ((key (this-command-keys))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
708 (prefix (make-vector (1- (length key)) nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
709 i)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
710 (setq i 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
711 (while (< i (length prefix))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
712 (aset prefix i (aref key i))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
713 (setq i (1+ i)))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
714 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
715 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
716 (princ "Key bindings starting with ")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
717 (princ (key-description prefix))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
718 (princ ":\n\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
719 (describe-bindings-1 prefix nil))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
720 (format "%s prefix" (key-description prefix)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
721
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
722 ;; Make C-h after a prefix, when not specifically bound,
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
723 ;; run describe-prefix-bindings.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
724 (setq prefix-help-command 'describe-prefix-bindings)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
725
261
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
726 (defun describe-installation ()
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
727 "Display a buffer showing information about this XEmacs was compiled."
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
728 (interactive)
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
729 (if (and (boundp 'Installation-string)
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
730 (stringp Installation-string))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
731 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
732 (lambda ()
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 398
diff changeset
733 (princ
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 398
diff changeset
734 (if (fboundp 'decode-coding-string)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 398
diff changeset
735 (decode-coding-string Installation-string 'automatic-conversion)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 398
diff changeset
736 Installation-string)))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
737 "Installation")
261
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
738 (error "No Installation information available.")))
405dd6d1825b Import from CVS: tag r20-5b29
cvs
parents: 259
diff changeset
739
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
740 (defun view-emacs-news ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
741 "Display info on recent changes to XEmacs."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
742 (interactive)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
743 (find-file (locate-data-file "NEWS")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
744
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
745 (defun xemacs-www-page ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
746 "Go to the XEmacs World Wide Web page."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
747 (interactive)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
748 (if (boundp 'browse-url-browser-function)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
749 (funcall browse-url-browser-function "http://www.xemacs.org/")
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
750 (error "xemacs-www-page requires browse-url")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
751
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
752 (defun xemacs-www-faq ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
753 "View the latest and greatest XEmacs FAQ using the World Wide Web."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
754 (interactive)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
755 (if (boundp 'browse-url-browser-function)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
756 (funcall browse-url-browser-function
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
757 "http://www.xemacs.org/faq/index.html")
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 215
diff changeset
758 (error "xemacs-www-faq requires browse-url")))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
759
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
760 (defun xemacs-local-faq ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
761 "View the local copy of the XEmacs FAQ.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
762 If you have access to the World Wide Web, you should use `xemacs-www-faq'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
763 instead, to ensure that you get the most up-to-date information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
764 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
765 (save-window-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
766 (info)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
767 (Info-find-node "xemacs-faq" "Top"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
768 (switch-to-buffer "*info*"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
769
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
770 (defcustom view-lossage-key-count 100
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
771 "*Number of keys `view-lossage' shows.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
772 The maximum number of available keys is governed by `recent-keys-ring-size'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
773 :type 'integer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
774 :group 'help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
775
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
776 (defcustom view-lossage-message-count 100
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
777 "*Number of minibuffer messages `view-lossage' shows."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
778 :type 'integer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
779 :group 'help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
780
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
781 (defun print-recent-messages (n)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
782 "Print N most recent messages to standard-output, most recent first.
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
783 If N is nil, all messages will be printed."
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
784 (save-excursion
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
785 (let ((buffer (get-buffer-create " *Message-Log*"))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
786 oldpoint extent)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
787 (goto-char (point-max buffer) buffer)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
788 (set-buffer standard-output)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
789 (while (and (not (bobp buffer))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
790 (or (null n) (>= (decf n) 0)))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
791 (setq oldpoint (point buffer))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
792 (setq extent (extent-at oldpoint buffer
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
793 'message-multiline nil 'before))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
794 ;; If the message was multiline, move all the way to the
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
795 ;; beginning.
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
796 (if extent
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
797 (goto-char (extent-start-position extent) buffer)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
798 (forward-line -1 buffer))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
799 (insert-buffer-substring buffer (point buffer) oldpoint)))))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
800
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
801 (defun view-lossage ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
802 "Display recent input keystrokes and recent minibuffer messages.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
803 The number of keys shown is controlled by `view-lossage-key-count'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
804 The number of messages shown is controlled by `view-lossage-message-count'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
805 (interactive)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
806 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
807 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
808 (princ (key-description (recent-keys view-lossage-key-count)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
809 (save-excursion
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
810 (set-buffer standard-output)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
811 (goto-char (point-min))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
812 (insert "Recent keystrokes:\n\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
813 (while (progn (move-to-column 50) (not (eobp)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
814 (search-forward " " nil t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
815 (insert "\n")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
816 ;; XEmacs addition: copy the messages from " *Message-Log*",
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
817 ;; reversing their order and handling multiline messages
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
818 ;; correctly.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
819 (princ "\n\n\nRecent minibuffer messages (most recent first):\n\n")
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
820 (print-recent-messages view-lossage-message-count))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
821 "lossage"))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
822
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
823 (define-function 'help 'help-for-help)
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
824
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
825 (make-help-screen help-for-help
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
826 "A B C F I K L M N P S T V W C-c C-d C-f C-i C-k C-n C-w; ? for more help:"
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
827 "Type a Help option:
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
828 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
829
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
830 \\[hyper-apropos] Type a substring; it shows a hypertext list of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
831 functions and variables that contain that substring.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
832 See also the `apropos' command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
833 \\[command-apropos] Type a substring; it shows a list of commands
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
834 (interactively callable functions) that contain that substring.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
835 \\[describe-bindings] Table of all key bindings.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
836 \\[describe-key-briefly] Type a command key sequence;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
837 it displays the function name that sequence runs.
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
838 \\[customize] Customize Emacs options.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
839 \\[Info-goto-emacs-command-node] Type a function name; it displays the Info node for that command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
840 \\[describe-function] Type a function name; it shows its documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
841 \\[Info-elisp-ref] Type a function name; it jumps to the full documentation
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
842 in the XEmacs Lisp Programmer's Manual.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
843 \\[xemacs-local-faq] Local copy of the XEmacs FAQ.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
844 \\[info] Info documentation reader.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
845 \\[Info-query] Type an Info file name; it displays it in Info reader.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
846 \\[describe-key] Type a command key sequence;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
847 it displays the documentation for the command bound to that key.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
848 \\[Info-goto-emacs-key-command-node] Type a command key sequence;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
849 it displays the Info node for the command bound to that key.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
850 \\[view-lossage] Recent input keystrokes and minibuffer messages.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
851 \\[describe-mode] Documentation of current major and minor modes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
852 \\[view-emacs-news] News of recent XEmacs changes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
853 \\[finder-by-keyword] Type a topic keyword; it finds matching packages.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
854 \\[describe-pointer] Table of all mouse-button bindings.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
855 \\[describe-syntax] Contents of syntax table with explanations.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
856 \\[help-with-tutorial] XEmacs learn-by-doing tutorial.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
857 \\[describe-variable] Type a variable name; it displays its documentation and value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
858 \\[where-is] Type a command name; it displays which keystrokes invoke that command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
859 \\[describe-distribution] XEmacs ordering information.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
860 \\[describe-no-warranty] Information on absence of warranty for XEmacs.
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
861 \\[describe-copying] XEmacs copying permission (General Public License)."
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
862 help-map)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
863
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
864 (defmacro with-syntax-table (syntab &rest body)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
865 "Evaluate BODY with the syntax-table SYNTAB"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
866 `(let ((stab (syntax-table)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
867 (unwind-protect
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
868 (progn
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
869 (set-syntax-table (copy-syntax-table ,syntab))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
870 ,@body)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
871 (set-syntax-table stab))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
872 (put 'with-syntax-table 'lisp-indent-function 1)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
873 (put 'with-syntax-table 'edebug-form-spec '(form body))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
874
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
875 (defun function-called-at-point ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
876 "Return the function which is called by the list containing point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
877 If that gives no function, return the function whose name is around point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
878 If that doesn't give a function, return nil."
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
879 (or (ignore-errors
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
880 (save-excursion
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
881 (save-restriction
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
882 (narrow-to-region (max (point-min) (- (point) 1000))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
883 (point-max))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
884 (backward-up-list 1)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
885 (forward-char 1)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
886 (let (obj)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
887 (setq obj (read (current-buffer)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
888 (and (symbolp obj) (fboundp obj) obj)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
889 (ignore-errors
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
890 (with-syntax-table emacs-lisp-mode-syntax-table
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
891 (save-excursion
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
892 (or (not (zerop (skip-syntax-backward "_w")))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
893 (eq (char-syntax (char-after (point))) ?w)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
894 (eq (char-syntax (char-after (point))) ?_)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
895 (forward-sexp -1))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
896 (skip-chars-forward "`'")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
897 (let ((obj (read (current-buffer))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
898 (and (symbolp obj) (fboundp obj) obj)))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
899
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
900 (defun function-at-point ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
901 "Return the function whose name is around point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
902 If that gives no function, return the function which is called by the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
903 list containing point. If that doesn't give a function, return nil."
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
904 (or (ignore-errors
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
905 (with-syntax-table emacs-lisp-mode-syntax-table
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
906 (save-excursion
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
907 (or (not (zerop (skip-syntax-backward "_w")))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
908 (eq (char-syntax (char-after (point))) ?w)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
909 (eq (char-syntax (char-after (point))) ?_)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
910 (forward-sexp -1))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
911 (skip-chars-forward "`'")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
912 (let ((obj (read (current-buffer))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
913 (and (symbolp obj) (fboundp obj) obj)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
914 (ignore-errors
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
915 (save-excursion
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
916 (save-restriction
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
917 (narrow-to-region (max (point-min) (- (point) 1000))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
918 (point-max))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
919 (backward-up-list 1)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
920 (forward-char 1)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
921 (let (obj)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
922 (setq obj (read (current-buffer)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
923 (and (symbolp obj) (fboundp obj) obj)))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
924
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
925 ;; Default to nil for the non-hackers? Not until we find a way to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
926 ;; distinguish hackers from non-hackers automatically!
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
927 (defcustom describe-function-show-arglist t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
928 "*If non-nil, describe-function will show its arglist,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
929 unless the function is autoloaded."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
930 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
931 :group 'help-appearance)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
932
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
933 (defun describe-symbol-find-file (symbol)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
934 (loop for (file . load-data) in load-history
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
935 do (when (memq symbol load-data)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
936 (return file))))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
937
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
938 (define-obsolete-function-alias
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
939 'describe-function-find-file
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
940 'describe-symbol-find-file)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
941
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
942 (defun describe-function (function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
943 "Display the full documentation of FUNCTION (a symbol).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
944 When run interactively, it defaults to any function found by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
945 `function-at-point'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
946 (interactive
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
947 (let* ((fn (function-at-point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
948 (val (let ((enable-recursive-minibuffers t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
949 (completing-read
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
950 (if fn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
951 (format (gettext "Describe function (default %s): ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
952 fn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
953 (gettext "Describe function: "))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
954 obarray 'fboundp t nil 'function-history
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
955 (symbol-name fn)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
956 (list (intern val))))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
957 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
958 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
959 (describe-function-1 function)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
960 ;; Return the text we displayed.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
961 (buffer-string nil nil standard-output))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
962 (format "function `%s'" function)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
963
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
964 (defun function-obsolete-p (function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
965 "Return non-nil if FUNCTION is obsolete."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
966 (not (null (get function 'byte-obsolete-info))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
967
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
968 (defun function-obsoleteness-doc (function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
969 "If FUNCTION is obsolete, return a string describing this."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
970 (let ((obsolete (get function 'byte-obsolete-info)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
971 (if obsolete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
972 (format "Obsolete; %s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
973 (if (stringp (car obsolete))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
974 (car obsolete)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
975 (format "use `%s' instead." (car obsolete)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
976
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
977 (defun function-compatible-p (function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
978 "Return non-nil if FUNCTION is present for Emacs compatibility."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
979 (not (null (get function 'byte-compatible-info))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
980
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
981 (defun function-compatibility-doc (function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
982 "If FUNCTION is Emacs compatible, return a string describing this."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
983 (let ((compatible (get function 'byte-compatible-info)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
984 (if compatible
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
985 (format "Emacs Compatible; %s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
986 (if (stringp (car compatible))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
987 (car compatible)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
988 (format "use `%s' instead." (car compatible)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
989
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
990 ;Here are all the possibilities below spelled out, for the benefit
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
991 ;of the I18N3 snarfer.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
992 ;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
993 ;(gettext "a built-in function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
994 ;(gettext "an interactive built-in function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
995 ;(gettext "a built-in macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
996 ;(gettext "an interactive built-in macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
997 ;(gettext "a compiled Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
998 ;(gettext "an interactive compiled Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
999 ;(gettext "a compiled Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1000 ;(gettext "an interactive compiled Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1001 ;(gettext "a Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1002 ;(gettext "an interactive Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1003 ;(gettext "a Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1004 ;(gettext "an interactive Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1005 ;(gettext "a mocklisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1006 ;(gettext "an interactive mocklisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1007 ;(gettext "a mocklisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1008 ;(gettext "an interactive mocklisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1009 ;(gettext "an autoloaded Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1010 ;(gettext "an interactive autoloaded Lisp function")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1011 ;(gettext "an autoloaded Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1012 ;(gettext "an interactive autoloaded Lisp macro")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1013
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1014 ;; taken out of `describe-function-1'
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1015 (defun function-arglist (function)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1016 "Return a string giving the argument list of FUNCTION.
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1017 For example:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1018
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1019 (function-arglist 'function-arglist)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1020 => (function-arglist FUNCTION)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1021
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1022 This function is used by `describe-function-1' to list function
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1023 arguments in the standard Lisp style."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1024 (let* ((fnc (indirect-function function))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1025 (fndef (if (eq (car-safe fnc) 'macro)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1026 (cdr fnc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1027 fnc))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1028 (arglist
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1029 (cond ((compiled-function-p fndef)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1030 (compiled-function-arglist fndef))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1031 ((eq (car-safe fndef) 'lambda)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1032 (nth 1 fndef))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1033 ((subrp fndef)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1034 (let* ((doc (documentation function))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1035 (args (and (string-match
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1036 "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1037 doc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1038 (match-string 1 doc))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1039 ;; If there are no arguments documented for the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1040 ;; subr, rather don't print anything.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1041 (cond ((null args) t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1042 ((equal args "") nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1043 (args))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1044 (t t))))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1045 (cond ((listp arglist)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1046 (prin1-to-string
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1047 (cons function (mapcar (lambda (arg)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1048 (if (memq arg '(&optional &rest))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1049 arg
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1050 (intern (upcase (symbol-name arg)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1051 arglist))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1052 t))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1053 ((stringp arglist)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1054 (format "(%s %s)" function arglist)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1055
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1056 (defun function-documentation (function &optional strip-arglist)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1057 "Return a string giving the documentation for FUNCTION, if any.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1058 If the optional argument STRIP-ARGLIST is non-nil, remove the arglist
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1059 part of the documentation of internal subroutines."
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1060 (let ((doc (condition-case nil
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1061 (or (documentation function)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1062 (gettext "not documented"))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1063 (void-function ""))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1064 (if (and strip-arglist
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1065 (string-match "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'" doc))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1066 (setq doc (substring doc 0 (match-beginning 0))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1067 doc))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1068
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1069 (defun describe-function-1 (function &optional nodoc)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1070 "This function does the work for `describe-function'."
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 239
diff changeset
1071 (princ (format "`%s' is " function))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1072 (let* ((def function)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1073 aliases file-name autoload-file kbd-macro-p fndef macrop)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1074 (while (and (symbolp def) (fboundp def))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1075 (when (not (eq def function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1076 (setq aliases
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1077 (if aliases
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1078 ;; I18N3 Need gettext due to concat
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1079 (concat aliases
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1080 (format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1081 "\n which is an alias for `%s', "
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1082 (symbol-name def)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1083 (format "an alias for `%s', " (symbol-name def)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1084 (setq def (symbol-function def)))
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1085 (if (and (fboundp 'compiled-function-annotation)
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1086 (compiled-function-p def))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1087 (setq file-name (compiled-function-annotation def)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1088 (if (eq 'macro (car-safe def))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1089 (setq fndef (cdr def)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1090 file-name (and (compiled-function-p (cdr def))
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1091 (fboundp 'compiled-function-annotation)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1092 (compiled-function-annotation (cdr def)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1093 macrop t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1094 (setq fndef def))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1095 (if aliases (princ aliases))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1096 (let ((int #'(lambda (string an-p macro-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1097 (princ (format
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1098 (gettext (concat
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1099 (cond ((commandp def)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1100 "an interactive ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1101 (an-p "an ")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1102 (t "a "))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1103 "%s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1104 (if macro-p " macro" " function")))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1105 string)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1106 (cond ((or (stringp def) (vectorp def))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1107 (princ "a keyboard macro.")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1108 (setq kbd-macro-p t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1109 ((subrp fndef)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1110 (funcall int "built-in" nil macrop))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1111 ((compiled-function-p fndef)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1112 (funcall int "compiled Lisp" nil macrop))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1113 ((eq (car-safe fndef) 'lambda)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1114 (funcall int "Lisp" nil macrop))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1115 ((eq (car-safe fndef) 'mocklisp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1116 (funcall int "mocklisp" nil macrop))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1117 ((eq (car-safe def) 'autoload)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1118 (setq autoload-file (elt def 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1119 (funcall int "autoloaded Lisp" t (elt def 4)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1120 ((and (symbolp def) (not (fboundp def)))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1121 (princ "a symbol with a void (unbound) function definition."))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1122 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1123 nil)))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1124 (princ "\n")
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1125 (if autoload-file
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1126 (princ (format " -- autoloads from \"%s\"\n" autoload-file)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1127 (or file-name
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1128 (setq file-name (describe-symbol-find-file function)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1129 (if file-name
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1130 (princ (format " -- loaded from \"%s\"\n" file-name)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1131 ;; (terpri)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1132 (if describe-function-show-arglist
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1133 (let ((arglist (function-arglist function)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1134 (when arglist
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1135 (princ arglist)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1136 (terpri))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1137 (terpri)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1138 (cond (kbd-macro-p
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1139 (princ "These characters are executed:\n\n\t")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1140 (princ (key-description def))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1141 (cond ((setq def (key-binding def))
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 239
diff changeset
1142 (princ (format "\n\nwhich executes the command `%s'.\n\n"
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 239
diff changeset
1143 def))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1144 (describe-function-1 def))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1145 (nodoc nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1146 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1147 ;; tell the user about obsoleteness.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1148 ;; If the function is obsolete and is aliased, don't
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1149 ;; even bother to report the documentation, as a further
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1150 ;; encouragement to use the new function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1151 (let ((obsolete (function-obsoleteness-doc function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1152 (compatible (function-compatibility-doc function)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1153 (when obsolete
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1154 (princ obsolete)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1155 (terpri)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1156 (terpri))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1157 (when compatible
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1158 (princ compatible)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1159 (terpri)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1160 (terpri))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1161 (unless (and obsolete aliases)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1162 (let ((doc (function-documentation function t)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1163 (princ "Documentation:\n")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1164 (princ doc)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1165 (unless (or (equal doc "")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1166 (eq ?\n (aref doc (1- (length doc)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1167 (terpri)))))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1168
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1169
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1170 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1171 ;;; are binding this to keys.]
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1172 (defun describe-function-arglist (function)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1173 (interactive (list (or (function-at-point)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1174 (error "no function call at point"))))
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1175 (message nil)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1176 (message (function-arglist function)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1177
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1178
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1179 (defun variable-at-point ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1180 (ignore-errors
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1181 (with-syntax-table emacs-lisp-mode-syntax-table
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1182 (save-excursion
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1183 (or (not (zerop (skip-syntax-backward "_w")))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1184 (eq (char-syntax (char-after (point))) ?w)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1185 (eq (char-syntax (char-after (point))) ?_)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1186 (forward-sexp -1))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1187 (skip-chars-forward "'")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1188 (let ((obj (read (current-buffer))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1189 (and (symbolp obj) (boundp obj) obj))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1190
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1191 (defun variable-obsolete-p (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1192 "Return non-nil if VARIABLE is obsolete."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1193 (not (null (get variable 'byte-obsolete-variable))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1194
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1195 (defun variable-obsoleteness-doc (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1196 "If VARIABLE is obsolete, return a string describing this."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1197 (let ((obsolete (get variable 'byte-obsolete-variable)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1198 (if obsolete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1199 (format "Obsolete; %s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1200 (if (stringp obsolete)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1201 obsolete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1202 (format "use `%s' instead." obsolete))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1203
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1204 (defun variable-compatible-p (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1205 "Return non-nil if VARIABLE is Emacs compatible."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1206 (not (null (get variable 'byte-compatible-variable))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1207
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1208 (defun variable-compatibility-doc (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1209 "If VARIABLE is Emacs compatible, return a string describing this."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1210 (let ((compatible (get variable 'byte-compatible-variable)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1211 (if compatible
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1212 (format "Emacs Compatible; %s"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1213 (if (stringp compatible)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1214 compatible
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1215 (format "use `%s' instead." compatible))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1216
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1217 (defun built-in-variable-doc (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1218 "Return a string describing whether VARIABLE is built-in."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1219 (let ((type (built-in-variable-type variable)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1220 (case type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1221 (integer "a built-in integer variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1222 (const-integer "a built-in constant integer variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1223 (boolean "a built-in boolean variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1224 (const-boolean "a built-in constant boolean variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1225 (object "a simple built-in variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1226 (const-object "a simple built-in constant variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1227 (const-specifier "a built-in constant specifier variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1228 (current-buffer "a built-in buffer-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1229 (const-current-buffer "a built-in constant buffer-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1230 (default-buffer "a built-in default buffer-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1231 (selected-console "a built-in console-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1232 (const-selected-console "a built-in constant console-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1233 (default-console "a built-in default console-local variable")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1234 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1235 (if type "an unknown type of built-in variable?"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1236 "a variable declared in Lisp")))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1237
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1238 (defun describe-variable (variable)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1239 "Display the full documentation of VARIABLE (a symbol)."
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1240 (interactive
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1241 (let* ((v (variable-at-point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1242 (val (let ((enable-recursive-minibuffers t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1243 (completing-read
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1244 (if v
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1245 (format "Describe variable (default %s): " v)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1246 (gettext "Describe variable: "))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1247 obarray 'boundp t nil 'variable-history
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1248 (symbol-name v)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1249 (list (intern val))))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1250 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1251 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1252 (let ((origvar variable)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1253 aliases)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1254 (let ((print-escape-newlines t))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1255 (princ (format "`%s' is " (symbol-name variable)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1256 (while (variable-alias variable)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1257 (let ((newvar (variable-alias variable)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1258 (if aliases
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1259 ;; I18N3 Need gettext due to concat
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1260 (setq aliases
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1261 (concat aliases
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1262 (format "\n which is an alias for `%s',"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1263 (symbol-name newvar))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1264 (setq aliases
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1265 (format "an alias for `%s',"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1266 (symbol-name newvar))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1267 (setq variable newvar)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1268 (if aliases
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1269 (princ (format "%s" aliases)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1270 (princ (built-in-variable-doc variable))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1271 (princ ".\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1272 (let ((file-name (describe-symbol-find-file variable)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1273 (if file-name
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1274 (princ (format " -- loaded from \"%s\"\n" file-name))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1275 (princ "\nValue: ")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1276 (if (not (boundp variable))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1277 (princ "void\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1278 (prin1 (symbol-value variable))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1279 (terpri))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1280 (terpri)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1281 (cond ((local-variable-p variable (current-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1282 (let* ((void (cons nil nil))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1283 (def (condition-case nil
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1284 (default-value variable)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1285 (error void))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1286 (princ "This value is specific to the current buffer.\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1287 (if (local-variable-p variable nil)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1288 (princ "(Its value is local to each buffer.)\n"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1289 (terpri)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1290 (if (if (eq def void)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1291 (boundp variable)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1292 (not (eq (symbol-value variable) def)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1293 ;; #### I18N3 doesn't localize properly!
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1294 (progn (princ "Default-value: ")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1295 (if (eq def void)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1296 (princ "void\n")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1297 (prin1 def)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1298 (terpri))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1299 (terpri)))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1300 ((local-variable-p variable (current-buffer) t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1301 (princ "Setting it would make its value buffer-local.\n\n"))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1302 (princ "Documentation:")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1303 (terpri)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1304 (let ((doc (documentation-property variable 'variable-documentation))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1305 (obsolete (variable-obsoleteness-doc origvar))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1306 (compatible (variable-compatibility-doc origvar)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1307 (when obsolete
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1308 (princ obsolete)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1309 (terpri)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1310 (terpri))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1311 (when compatible
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1312 (princ compatible)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1313 (terpri)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1314 (terpri))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1315 ;; don't bother to print anything if variable is obsolete and aliased.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1316 (when (or (not obsolete) (not aliases))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1317 (if doc
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1318 ;; note: documentation-property calls substitute-command-keys.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1319 (princ doc)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1320 (princ "not documented as a variable."))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1321 (terpri)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1322 (format "variable `%s'" variable)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1323
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1324 (defun sorted-key-descriptions (keys &optional separator)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1325 "Sort and separate the key descriptions for KEYS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1326 The sorting is done by length (shortest bindings first), and the bindings
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1327 are separated with SEPARATOR (\", \" by default)."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1328 (mapconcat 'key-description
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1329 (sort keys #'(lambda (x y)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1330 (< (length x) (length y))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1331 (or separator ", ")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1332
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1333 (defun where-is (definition &optional insert)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1334 "Print message listing key sequences that invoke specified command.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1335 Argument is a command definition, usually a symbol with a function definition.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1336 When run interactively, it defaults to any function found by
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1337 `function-at-point'.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1338 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1339 (interactive
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1340 (let ((fn (function-at-point))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 261
diff changeset
1341 (enable-recursive-minibuffers t)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1342 val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1343 (setq val (read-command
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1344 (if fn (format "Where is command (default %s): " fn)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1345 "Where is command: ")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1346 (list (if (equal (symbol-name val) "")
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1347 fn val)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1348 current-prefix-arg)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1349 (let ((keys (where-is-internal definition)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1350 (if keys
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1351 (if insert
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1352 (princ (format "%s (%s)" (sorted-key-descriptions keys)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1353 definition) (current-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1354 (message "%s is on %s" definition (sorted-key-descriptions keys)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1355 (if insert
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1356 (princ (format (if (commandp definition) "M-x %s RET"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1357 "M-: (%s ...)") definition) (current-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1358 (message "%s is not on any keys" definition))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1359 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1360
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1361 ;; `locate-library' moved to "packages.el"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1362
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1363
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1364 ;; Functions ported from C into Lisp in XEmacs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1365
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1366 (defun describe-syntax ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1367 "Describe the syntax specifications in the syntax table.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1368 The descriptions are inserted in a buffer, which is then displayed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1369 (interactive)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1370 (with-displaying-help-buffer
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1371 (lambda ()
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1372 ;; defined in syntax.el
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1373 (describe-syntax-table (syntax-table) standard-output))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1374 (format "syntax-table for %s" major-mode)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1375
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1376 (defun list-processes ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1377 "Display a list of all processes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1378 \(Any processes listed as Exited or Signaled are actually eliminated
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1379 after the listing is made.)"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1380 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1381 (with-output-to-temp-buffer "*Process List*"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1382 (set-buffer standard-output)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1383 (buffer-disable-undo standard-output)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1384 (make-local-variable 'truncate-lines)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1385 (setq truncate-lines t)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1386 ;; 00000000001111111111222222222233333333334444444444
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1387 ;; 01234567890123456789012345678901234567890123456789
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1388 ;; rewritten for I18N3. This one should stay rewritten
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1389 ;; so that the dashes will line up properly.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1390 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1391 (let ((tail (process-list)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1392 (while tail
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1393 (let* ((p (car tail))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1394 (pid (process-id p))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1395 (s (process-status p)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1396 (setq tail (cdr tail))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1397 (princ (format "%-13s" (process-name p)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1398 (princ s)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1399 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1400 (princ (format " %d" (process-exit-status p))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1401 (if (memq s '(signal exit closed))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1402 ;; Do delete-exited-processes' work
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1403 (delete-process p))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1404 (indent-to 22 1) ;####
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1405 (let ((b (process-buffer p)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1406 (cond ((not b)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1407 (princ "(none)"))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1408 ((not (buffer-name b))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1409 (princ "(killed)"))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1410 (t
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1411 (princ (buffer-name b)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1412 (indent-to 37 1) ;####
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1413 (let ((tn (process-tty-name p)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1414 (cond ((not tn)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1415 (princ "(none)"))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1416 (t
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1417 (princ (format "%s" tn)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1418 (indent-to 49 1) ;####
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1419 (if (not (integerp pid))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1420 (progn
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1421 (princ "network stream connection ")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1422 (princ (car pid))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1423 (princ "@")
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1424 (princ (cdr pid)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1425 (let ((cmd (process-command p)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1426 (while cmd
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1427 (princ (car cmd))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1428 (setq cmd (cdr cmd))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1429 (if cmd (princ " ")))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 229
diff changeset
1430 (terpri))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1431
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
1432 ;; Stop gap for 21.0 until we do help-char etc properly.
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1433 (defun help-keymap-with-help-key (keymap form)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1434 "Return a copy of KEYMAP with an help-key binding according to help-char
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1435 invoking FORM like help-form. An existing binding is not overridden.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1436 If FORM is nil then no binding is made."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1437 (let ((map (copy-keymap keymap))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1438 (key (if (characterp help-char)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1439 (vector (character-to-event help-char))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1440 help-char)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1441 (when (and form key (not (lookup-key map key)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1442 (define-key map key
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1443 `(lambda () (interactive) (help-print-help-form ,form))))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1444 map))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1445
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1446 (defun help-print-help-form (form)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1447 (let ((string (eval form)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1448 (if (stringp string)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1449 (with-displaying-help-buffer
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1450 (insert string)))))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1451
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
1452
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1453 ;;; help.el ends here