annotate lisp/prim/help.el @ 179:9ad43877534d r20-3b16

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