annotate lisp/help.el @ 227:0e522484dd2a r20-5b12

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