annotate lisp/help.el @ 462:0784d089fdc9 r21-2-46

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