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