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