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