annotate lisp/prim/help.el @ 14:9ee227acff29 r19-15b90

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