annotate lisp/help.el @ 428:3ecd8885ac67 r21-2-22

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