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