annotate lisp/help.el @ 5030:422b4b4fb2a6

Winclient updates
author Vin Shelton <acs@xemacs.org>
date Thu, 11 Feb 2010 19:33:50 -0500
parents d6368048cd8c
children b0f4adffca7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1 ;; help.el --- help commands for XEmacs.
428
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.
2537
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
4 ;; Copyright (C) 2001, 2002, 2003 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
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
44 (require 'loadhist) ;; For symbol-file.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
45
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (defgroup help nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 "Support for on-line help systems."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 :group 'emacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (defgroup help-appearance nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 "Appearance of help buffers."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (defvar help-map (let ((map (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (set-keymap-name map 'help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (set-keymap-prompt
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
57 map (gettext "(Type ? for further options)"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 "Keymap for characters following the Help key.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 ;; global-map definitions moved to keydefs.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (fset 'help-command help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (define-key help-map (vector help-char) 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (define-key help-map "?" 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (define-key help-map 'help 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (define-key help-map '(f1) 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
70 (define-key help-map "A" 'command-hyper-apropos)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
71 ;; #### should be hyper-apropos-documentation, once that's written.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
72 (define-key help-map "\C-a" 'apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (define-key help-map "b" 'describe-bindings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (define-key help-map "B" 'describe-beta)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
77 (define-key help-map "c" 'describe-key-briefly)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (define-key help-map "C" 'customize)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
79 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
80 ;; for Info-elisp-ref
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
81 (define-key help-map "\C-c" 'Info-goto-emacs-command-node)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (define-key help-map "d" 'describe-function)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
84 (define-key help-map "\C-d" 'describe-distribution)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
85
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
86 (define-key help-map "e" (if (fboundp 'view-last-error) 'view-last-error
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
87 'describe-last-error))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
88
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (define-key help-map "f" 'describe-function)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
90 ;; #### not a good interface. no way to specify that C-h is preferred
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
91 ;; as a prefix and not BS. should instead be specified as part of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
92 ;; `define-key'.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
93 ;; (put 'describe-function 'preferred-key-sequence "\C-hf")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (define-key help-map "F" 'xemacs-local-faq)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
95 (define-key help-map "\C-f" 'Info-elisp-ref)
428
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 "i" 'info)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
98 (define-key help-map "I" 'Info-search-index-in-xemacs-and-lispref)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
99 (define-key help-map "\C-i" 'Info-query)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
100
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
101 (define-key help-map "k" 'describe-key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
102 (define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
428
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 (define-key help-map "l" 'view-lossage)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
105 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (define-key help-map "m" 'describe-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
109 (define-key help-map "n" 'view-emacs-news)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (define-key help-map "\C-n" 'view-emacs-news)
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 "p" 'finder-by-keyword)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
113 (define-key help-map "\C-p" 'describe-pointer)
3074
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
114 (define-key help-map "P" 'view-xemacs-problems)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
115
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
116 (define-key help-map "q" 'help-quit)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 ;; Do this right with an autoload cookie in finder.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 ;;(autoload 'finder-by-keyword "finder"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 ;; "Find packages matching a given keyword." t)
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 (define-key help-map "s" 'describe-syntax)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
123 (define-key help-map "S" 'view-sample-init-el)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (define-key help-map "t" 'help-with-tutorial)
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 (define-key help-map "v" 'describe-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
129 (define-key help-map "w" 'where-is)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
130 (define-key help-map "\C-w" 'describe-no-warranty)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
132 ;; #### It would be nice if the code below to add hyperlinks was
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
133 ;; generalized. We would probably need a "hyperlink mode" from which
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
134 ;; help-mode is derived. This means we probably need multiple
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
135 ;; inheritance of modes! Thankfully this is not hard to implement; we
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
136 ;; already have the ability for a keymap to have multiple parents.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
137 ;; However, we'd have to define any multiply-inherited-from modes using
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
138 ;; a standard `define-mode' construction instead of manually doing it,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
139 ;; because we don't want each guy calling `kill-all-local-variables' and
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
140 ;; messing up the previous one.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (define-derived-mode help-mode view-major-mode "Help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 "Major mode for viewing help text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 Entry to this mode runs the normal hook `help-mode-hook'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 Commands:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 \\{help-mode-map}"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (define-key help-mode-map "q" 'help-mode-quit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (define-key help-mode-map "Q" 'help-mode-bury)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (define-key help-mode-map "f" 'find-function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (define-key help-mode-map "d" 'describe-function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (define-key help-mode-map "v" 'describe-variable-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (define-key help-mode-map "i" 'Info-elisp-ref)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (define-key help-mode-map "c" 'customize-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (define-key help-mode-map [tab] 'help-next-symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
158 (define-key help-mode-map [return] 'help-find-source-or-scroll-up)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
159 (define-key help-mode-map [button2] 'help-mouse-find-source-or-track)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (define-key help-mode-map "n" 'help-next-section)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (define-key help-mode-map "p" 'help-prev-section)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
163 (define-derived-mode temp-buffer-mode view-major-mode "Temp"
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
164 "Major mode for viewing temporary buffers.
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
165 Exit using \\<temp-buffer-mode-map>\\[help-mode-quit].
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
166
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
167 Entry to this mode runs the normal hook `temp-buffer-mode-hook'.
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
168 Commands:
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
169 \\{temp-buffer-mode-map}"
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
170 )
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
171
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
172 (define-key temp-buffer-mode-map "q" 'help-mode-quit)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
173 (define-key temp-buffer-mode-map "Q" 'help-mode-bury)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
174
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (defun describe-function-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 "Describe directly the function at point in the other window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (let ((symb (function-at-point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (when symb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (describe-function symb))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (defun describe-variable-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 "Describe directly the variable at point in the other window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (let ((symb (variable-at-point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (when symb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (describe-variable symb))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (defun help-next-symbol ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 "Move point to the next quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (search-forward "`" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (defun help-prev-symbol ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 "Move point to the previous quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (search-backward "'" nil t))
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 help-next-section ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 "Move point to the next quoted symbol."
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 (search-forward-regexp "^\\w+:" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (defun help-prev-section ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 "Move point to the previous quoted symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (search-backward-regexp "^\\w+:" nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (defun help-mode-bury ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 "Bury the help buffer, possibly restoring the previous window configuration."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (help-mode-quit t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (defun help-mode-quit (&optional bury)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 "Exit from help mode, possibly restoring the previous window configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 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
217 otherwise it is killed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (let ((buf (current-buffer)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220 (cond (help-window-config
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221 (set-window-configuration help-window-config))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 ((not (one-window-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (delete-window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 (if bury
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (bury-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (kill-buffer buf))))
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-quit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
232 (define-obsolete-function-alias 'deprecated-help-command 'help-for-help)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 ;;(define-key global-map 'backspace 'deprecated-help-command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
236 (defconst tutorial-supported-languages
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
237 '(
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
238 ("Croatian" hr iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
239 ("Czech" cs iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
240 ("Dutch" nl iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
241 ("English" nil raw-text)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
242 ("French" fr iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
243 ("German" de iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
244 ("Norwegian" no iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
245 ("Polish" pl iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
246 ("Romanian" ro iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
247 ("Slovak" sk iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
248 ("Slovenian" sl iso-8859-2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
249 ("Spanish" es iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
250 ("Swedish" se iso-8859-1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
251 )
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
252 "Alist of supported languages in TUTORIAL files.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
253 Add languages here, as more are translated.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
254
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
255 ;; TUTORIAL arg is XEmacs addition
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
256 (defun help-with-tutorial (&optional tutorial language)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
257 "Select the XEmacs learn-by-doing tutorial.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
258 Optional arg TUTORIAL specifies the tutorial file; if not specified or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
259 if this command is invoked interactively, the tutorial appropriate to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
260 the current language environment is used. If there is no tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
261 written in that language, or if this version of XEmacs has no
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
262 international (Mule) support, the English-language tutorial is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
263 With a prefix argument, you are asked to select which language."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
264 (interactive "i\nP")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
265 (when (and language (consp language))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
266 (setq language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
267 (if (featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
268 (or (declare-fboundp (read-language-name 'tutorial "Language: "))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
269 (error "No tutorial file of the specified language"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
270 (let ((completion-ignore-case t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
271 (completing-read "Language: "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
272 tutorial-supported-languages nil t)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
273 (or language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
274 (setq language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
275 (if (featurep 'mule) (declare-boundp current-language-environment)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
276 "English")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
277 (or tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
278 (setq tutorial
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
279 (cond ((featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
280 (or (declare-fboundp (get-language-info language 'tutorial))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
281 "TUTORIAL"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
282 ((equal language "English") "TUTORIAL")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
283 (t (format "TUTORIAL.%s"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
284 (cadr (assoc language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
285 tutorial-supported-languages)))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
286 (let ((file (expand-file-name tutorial "~")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
287 (delete-other-windows)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
288 (let ((buffer (or (get-file-buffer file)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
289 (create-file-buffer file)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
290 (window-configuration (current-window-configuration)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
291 (condition-case error-data
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
292 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
293 (switch-to-buffer buffer)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
294 (setq buffer-file-name file)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
295 (setq default-directory (expand-file-name "~/"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
296 (setq buffer-auto-save-file-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
297 ;; Because of non-Mule users, TUTORIALs are not coded
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
298 ;; independently, so we must guess the coding according to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
299 ;; the language.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
300 (let ((coding-system-for-read
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
301 (if (featurep 'mule)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
302 (with-fboundp 'get-language-info
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
303 (or (get-language-info language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
304 'tutorial-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
305 (car (get-language-info language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
306 'coding-system))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
307 (nth 2 (assoc language tutorial-supported-languages)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
308 (insert-file-contents (locate-data-file tutorial)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
309 (goto-char (point-min))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
310 ;; [The 'didactic' blank lines: possibly insert blank lines
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
311 ;; around <<nya nya nya>> and replace << >> with [ ].] No more
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
312 ;; didactic blank lines. It was just a bad idea, anyway. I
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
313 ;; rewrote the TUTORIAL so it doesn't need them. However, some
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
314 ;; tutorials in other languages haven't yet been updated. ####
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
315 ;; Delete this code when they're all updated.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
316 (if (re-search-forward "^<<.+>>" nil t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
317 (let ((n (- (window-height (selected-window))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
318 (count-lines (point-min) (point-at-bol))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
319 6)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
320 (if (< n 12)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
321 (progn (beginning-of-line) (kill-line))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
322 ;; Some people get confused by the large gap
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
323 (delete-backward-char 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
324 (insert "]")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
325 (beginning-of-line)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
326 (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
327 (delete-char 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
328 (insert "["))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
329 (newline (/ n 2))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
330 (next-line 1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
331 (newline (- n (/ n 2))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
332 (goto-char (point-min))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
333 (set-buffer-modified-p nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
334 ;; TUTORIAL was not found: kill the buffer and restore the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
335 ;; window configuration.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
336 (file-error (kill-buffer buffer)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
337 (set-window-configuration window-configuration)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
338 ;; Now, signal the error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
339 (signal (car error-data) (cdr error-data)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (defun key-or-menu-binding (key &optional menu-flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 "Return the command invoked by KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 Like `key-binding', but handles menu events and toolbar presses correctly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 KEY is any value returned by `next-command-event'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 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
347 or nil otherwise."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (let (defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (and menu-flag (set menu-flag nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 ;; 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
351 ;; of the event object and intuit the function that would be called,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ;; and describe that instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (if (and (vectorp key) (= 1 (length key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (or (misc-user-event-p (aref key 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (eq (car-safe (aref key 0)) 'menu-selection)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (let ((event (aref key 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (setq defn (if (eventp event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (list (event-function event) (event-object event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (cdr event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (and menu-flag (set menu-flag t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (when (eq (car defn) 'eval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (setq defn (car (cdr defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (when (eq (car-safe defn) 'call-interactively)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (setq defn (car (cdr defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (when (and (consp defn) (null (cdr defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (setq defn (car defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 ;; else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (setq defn (key-binding key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 ;; kludge: if a toolbar button was pressed on, try to find the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 ;; binding of the toolbar button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (if (and (eq defn 'press-toolbar-button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (vectorp key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (button-press-event-p (aref key (1- (length key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 ;; wait for the button release. We're on shaky ground here ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (let ((event (next-command-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (if (and (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (event-over-toolbar-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (eq 'release-and-activate-toolbar-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (key-binding (vector event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (setq button (event-toolbar-button event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (toolbar-button-callback button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; if anything went wrong, try returning the binding of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 ;; the button-up event, of the original binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (or (key-or-menu-binding (vector event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 ;; no toolbar kludge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (defun describe-key-briefly (key &optional insert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 "Print the name of the function KEY invokes. KEY is a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 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
394 (interactive "kDescribe key briefly: \nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (let ((standard-output (if insert (current-buffer) t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 defn menup)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (setq defn (key-or-menu-binding key 'menup))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (princ (format "%s is undefined" (key-description key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 ;; If it's a keyboard macro which trivially invokes another command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 ;; document that instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (if (or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (setq defn (or (key-binding defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (let ((last-event (and (vectorp key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 (aref key (1- (length key))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 (princ (format (cond (insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 "%s (%s)")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ((or (button-press-event-p last-event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 (button-release-event-p last-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (gettext "%s at that spot runs the command %s"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (gettext "%s runs the command %s")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 ;; This used to say 'This menu item' but it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 ;; could also be a scrollbar event. We can't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 ;; distinguish at the moment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (if menup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (if insert "item" "This item")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (key-description key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (if (symbolp defn) defn (prin1-to-string defn))))))))
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 ;; #### this is a horrible piece of shit function that should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 ;; not exist. In FSF 19.30 this function has gotten three times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 ;; as long and has tons and tons of dumb shit checking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 ;; special-display-buffer-names and such crap. I absolutely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 ;; refuse to insert that Ebolification here. I wanted to delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 ;; this function entirely but Mly bitched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 ;; If your user-land code calls this function, rewrite it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 ;; call with-displaying-help-buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (defun print-help-return-message (&optional function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 "Display or return message saying how to restore windows after help command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 Computes a message and applies the optional argument FUNCTION to it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 If FUNCTION is nil, applies `message' to it, thus printing it."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (and (not (get-buffer-window standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (funcall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (or function 'message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (substitute-command-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (if (one-window-p t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (if pop-up-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (gettext "Type \\[delete-other-windows] to remove help window.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (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
446 (substitute-command-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (gettext " \\[scroll-other-window] to scroll the help."))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (defcustom help-selects-help-window t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 "*If nil, use the \"old Emacs\" behavior for Help buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 This just displays the buffer in another window, rather than selecting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 the window."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (defcustom help-max-help-buffers 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 "*Maximum help buffers to allow before they start getting killed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 If this is a positive integer, before a help buffer is displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 by `with-displaying-help-buffer', any excess help buffers which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 are not being displayed are first killed. Otherwise, if it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 zero or nil, only one help buffer, \"*Help*\" is ever used."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 :type '(choice integer (const :tag "None" nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (defvar help-buffer-list nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 "List of help buffers used by `help-register-and-maybe-prune-excess'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (defun help-register-and-maybe-prune-excess (newbuf)
2030
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
469 "Register help buffer named NEWBUF and possibly kill excess ones."
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
470 ;; don't let client code pass us bogus NEWBUF---if it gets in the list,
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
471 ;; help can become unusable
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
472 (unless (stringp newbuf)
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
473 (error 'wrong-type-argument "help buffer name must be string" newbuf))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 ;; remove new buffer from list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (setq help-buffer-list (remove newbuf help-buffer-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 ;; maybe kill excess help buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (if (and (integerp help-max-help-buffers)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (> (length help-buffer-list) help-max-help-buffers))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (let ((keep-list nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (num-kill (- (length help-buffer-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 help-max-help-buffers)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (while help-buffer-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (let ((buf (car help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (if (and (or (equal buf newbuf) (get-buffer buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (string-match "^*Help" buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (save-excursion (set-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (eq major-mode 'help-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (if (and (>= num-kill (length help-buffer-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (not (get-buffer-window buf t t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (kill-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (setq keep-list (cons buf keep-list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (setq help-buffer-list (cdr help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (setq help-buffer-list (nreverse keep-list))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 ;; push new buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (setq help-buffer-list (cons newbuf help-buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (defvar help-buffer-prefix-string "Help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 "Initial string to use in constructing help buffer names.
2030
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
499 You should never set this directly, only let-bind it.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (defun help-buffer-name (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 "Return a name for a Help buffer using string NAME for context."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (if (and (integerp help-max-help-buffers)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (> help-max-help-buffers 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (stringp name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (if help-buffer-prefix-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (format "*%s: %s*" help-buffer-prefix-string name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (format "*%s*" name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (format "*%s*" help-buffer-prefix-string)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 793
diff changeset
511 ;; with-displaying-help-buffer
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 ;; #### Should really be a macro to eliminate the requirement of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 ;; caller to code a lambda form in THUNK -- mrb
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 ;; #### BEFORE you rush to make this a macro, think about backward
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 ;; compatibility. The right way would be to create a macro with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 ;; 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
519 ;; for a macro) that uses with-displaying-help-buffer internally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521 (defcustom mode-for-help 'help-mode
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 "*Mode that help buffers are put into.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
523
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
524 (defcustom mode-for-temp-buffer 'temp-buffer-mode
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
525 "*Mode that help buffers are put into.")
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
526
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527 (defvar help-sticky-window nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 ;; Window into which help buffers will be displayed, rather than
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
529 ;; 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
530 ;; 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
531 ;; bound, not set.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 (defvar help-window-config nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 (make-variable-buffer-local 'help-window-config)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 (put 'help-window-config 'permanent-local t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
539 (defmacro with-displaying-temp-buffer (name &rest body)
2030
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
540 "Make a help buffer with given NAME and evaluate BODY, sending stdout there.
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
541
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
542 Use this function for displaying information in temporary buffers, where the
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
543 user will typically view the information and then exit using
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
544 \\<temp-buffer-mode-map>\\[help-mode-quit].
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 793
diff changeset
545
2030
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
546 On exit from this form, the buffer is put into the mode specified in
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
547 `mode-for-temp-buffer' and displayed, typically in a popup window. Ie,
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
548 the buffer is a scratchpad which is displayed all at once in formatted
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
549 form.
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
550
488b2f76d852 [xemacs-hg @ 2004-04-19 08:54:47 by stephent]
stephent
parents: 1779
diff changeset
551 N.B. Write to this buffer with functions like `princ', not `insert'."
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
552 `(let* ((winconfig (current-window-configuration))
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
553 (was-one-window (one-window-p))
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
554 (buffer-name ,name)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
555 (help-not-visible
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
556 (not (and (windows-of-buffer buffer-name) ;shortcut
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
557 (memq (selected-frame)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
558 (mapcar 'window-frame
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
559 (windows-of-buffer buffer-name)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (help-register-and-maybe-prune-excess buffer-name)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
561 ;; 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
562 (if (and help-sticky-window (or (not (windowp help-sticky-window))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 (not (window-live-p help-sticky-window))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 (setq help-sticky-window nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565 (prog1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 (let ((temp-buffer-show-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 (if help-sticky-window
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 #'(lambda (buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 (set-window-buffer help-sticky-window buffer))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 temp-buffer-show-function)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 (with-output-to-temp-buffer buffer-name
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
572 (prog1 (progn ,@body)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 (set-buffer standard-output)
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
575 (funcall mode-for-temp-buffer)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (let ((helpwin (get-buffer-window buffer-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (when helpwin
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
578 ;; If the temp buffer is already displayed on this
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 ;; frame, don't override the previous configuration
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 (when help-not-visible
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581 (with-current-buffer (window-buffer helpwin)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 (setq help-window-config winconfig)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (when help-selects-help-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (select-window helpwin))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (cond ((eq helpwin (selected-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (display-message 'command
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
587 (substitute-command-keys "Type \\[help-mode-quit] to remove window, \\[scroll-up] to scroll the text.")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (was-one-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (display-message 'command
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
590 (substitute-command-keys "Type \\[delete-other-windows] to remove window, \\[scroll-other-window] to scroll the text.")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (display-message 'command
1123
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
593 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the text.")))))))))
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
594
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
595 (put 'with-displaying-temp-buffer 'lisp-indent-function 1)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
596
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
597 (defun with-displaying-help-buffer (thunk &optional name)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
598 "Form which makes a help buffer with given NAME and evaluates BODY there.
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
599 The actual name of the buffer is generated by the function `help-buffer-name'.
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
600
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
601 Use this function for displaying help when C-h something is pressed or
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
602 in similar situations. Do *not* use it when you are displaying a help
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
603 message and then prompting for input in the minibuffer -- this macro
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
604 usually selects the help buffer, which is not what you want in those
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
605 situations."
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
606 (let ((mode-for-temp-buffer mode-for-help))
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
607 (with-displaying-temp-buffer (help-buffer-name name)
37bdd24225ef [xemacs-hg @ 2002-11-27 07:15:02 by ben]
ben
parents: 1038
diff changeset
608 (funcall thunk))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 (defun describe-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 "Display documentation of the function invoked by KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 KEY is a string, or vector of events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 When called interactively, KEY may also be a menu selection."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (interactive "kDescribe key: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (let ((defn (key-or-menu-binding key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (key-string (key-description key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (message "%s is undefined" key-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 (princ key-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 (princ " runs ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 (if (symbolp defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 (princ (format "`%s'" defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 (princ defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 (princ "\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 (cond ((or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 (let ((cmd (key-binding defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 (if (not cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 (princ "a keyboard macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 (princ "a keyboard macro which runs the command ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 (princ cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 (princ ":\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (if (documentation cmd) (princ (documentation cmd)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (let ((describe-function-show-arglist nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 (describe-function-1 (car defn))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 ((symbolp defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 (describe-function-1 defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 ((documentation defn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (princ (documentation defn)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (princ "not documented"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 (format "key `%s'" key-string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 (defun describe-mode ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 "Display documentation of current major mode and minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 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
650 \(listed in `minor-mode-alist') must also be a function whose documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 describes the minor mode."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 ;; XEmacs change: print the major-mode documentation before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 ;; the minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 (princ mode-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (princ " mode:\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (princ (documentation major-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 (princ "\n\n----\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (let ((minor-modes minor-mode-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (while minor-modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (let* ((minor-mode (car (car minor-modes)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (indicator (car (cdr (car minor-modes)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 ;; Document a minor mode if it is listed in minor-mode-alist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 ;; bound locally in this buffer, non-nil, and has a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 ;; definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 (if (and (boundp minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (symbol-value minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (fboundp minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (let ((pretty-minor-mode minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (if (string-match "-mode\\'" (symbol-name minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (setq pretty-minor-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (capitalize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (substring (symbol-name minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 0 (match-beginning 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (while (and (consp indicator) (extentp (car indicator)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 (setq indicator (cdr indicator)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (while (and indicator (symbolp indicator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 (setq indicator (symbol-value indicator)))
732
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
681 (princ (format "%s minor mode (%s):\n"
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
682 pretty-minor-mode
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
683 (if indicator
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
684 (format "indicator%s" indicator)
b9b8621c2439 [xemacs-hg @ 2002-01-22 14:16:38 by youngs]
youngs
parents: 622
diff changeset
685 "no indicator")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (princ (documentation minor-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (princ "\n\n----\n\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 (setq minor-modes (cdr minor-modes)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 (format "%s mode" mode-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 ;; So keyboard macro definitions are documented correctly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
694 ;; view a read-only file intelligently
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
695 (defun Help-find-file (file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
696 (if (fboundp 'view-file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
697 (view-file file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
698 (find-file-read-only file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
699 (goto-char (point-min))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
700
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 (defun describe-distribution ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 "Display info on how to obtain the latest version of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 (interactive)
2537
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
704 (save-window-excursion
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
705 (info)
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
706 (Info-find-node "xemacs-faq" "Q1.1.1"))
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
707 (switch-to-buffer "*info*"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 (defun describe-beta ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 "Display info on how to deal with Beta versions of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 (interactive)
2537
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
712 (save-window-excursion
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
713 (info "(beta)Top"))
b7b90f750a78 [xemacs-hg @ 2005-01-31 20:08:32 by ben]
ben
parents: 2275
diff changeset
714 (switch-to-buffer "*info*"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 (defun describe-copying ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 "Display info on how you may redistribute copies of XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 (interactive)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
719 (Help-find-file (locate-data-file "COPYING")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 (defun describe-pointer ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 "Show a list of all defined mouse buttons, and their definitions."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (describe-bindings nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 (defun describe-no-warranty ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 "Display info on all the kinds of warranty XEmacs does NOT have."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 (describe-copying)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (let (case-fold-search)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 (search-forward "NO WARRANTY")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 (recenter 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 (defun describe-bindings (&optional prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 "Show a list of all defined keys, and their definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 The list is put in a buffer, which is displayed.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
737 If optional first argument PREFIX is supplied, only commands
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
738 which start with that sequence of keys are described.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
739 If optional second argument MOUSE-ONLY-P (prefix arg, interactively)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
740 is non-nil then only the mouse bindings are displayed."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 (interactive (list nil current-prefix-arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 (describe-bindings-1 prefix mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 (format "bindings for %s" major-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 (defun describe-bindings-1 (&optional prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 (let ((heading (if mouse-only-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 (gettext "button binding\n------ -------\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 (gettext "key binding\n--- -------\n")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 (buffer (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 (minor minor-mode-map-alist)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
753 (extent-maps (mapcar-extents
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
754 'extent-keymap
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
755 nil (current-buffer) (point) (point) nil 'keymap))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 (local (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (shadow '()))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 (set-buffer standard-output)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
759 (while extent-maps
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
760 (insert "Bindings for Text Region:\n"
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
761 heading)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
762 (describe-bindings-internal
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
763 (car extent-maps) nil shadow prefix mouse-only-p)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
764 (insert "\n")
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
765 (setq shadow (cons (car extent-maps) shadow)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
766 extent-maps (cdr extent-maps)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 (while minor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (let ((sym (car (car minor)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 (map (cdr (car minor))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (if (symbol-value-in-buffer sym buffer nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 (insert (format "Minor Mode Bindings for `%s':\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 (describe-bindings-internal map nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (setq shadow (cons map shadow))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (setq minor (cdr minor))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 (if local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 (insert "Local Bindings:\n" heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 (describe-bindings-internal local nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 (setq shadow (cons local shadow))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
785 (if (console-on-window-system-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
786 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
787 (insert "Global Window-System-Only Bindings:\n" heading)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
788 (describe-bindings-internal global-window-system-map nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
789 shadow prefix mouse-only-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
790 (push global-window-system-map shadow))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
791 (insert "Global TTY-Only Bindings:\n" heading)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
792 (describe-bindings-internal global-tty-map nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
793 shadow prefix mouse-only-p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
794 (push global-tty-map shadow))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 732
diff changeset
795 (insert "\nGlobal Bindings:\n" heading)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 (describe-bindings-internal (current-global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 nil shadow prefix mouse-only-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 (when (and prefix function-key-map (not mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 (insert "\nFunction key map translations:\n" heading)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (describe-bindings-internal function-key-map nil nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 prefix mouse-only-p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 (set-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (defun describe-prefix-bindings ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 "Describe the bindings of the prefix used to reach this command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 The prefix described consists of all but the last event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 of the key sequence that ran this command."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 (let* ((key (this-command-keys))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 (prefix (make-vector (1- (length key)) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 (setq i 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 (while (< i (length prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (aset prefix i (aref key i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 (princ "Key bindings starting with ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (princ (key-description prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 (princ ":\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (describe-bindings-1 prefix nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 (format "%s prefix" (key-description prefix)))))
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 ;; Make C-h after a prefix, when not specifically bound,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 ;; run describe-prefix-bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (setq prefix-help-command 'describe-prefix-bindings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (defun describe-installation ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 "Display a buffer showing information about this XEmacs was compiled."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (interactive)
4246
9fec7fedbf1b [xemacs-hg @ 2007-10-31 11:21:02 by aidan]
aidan
parents: 4103
diff changeset
832 (if (and-boundp 'Installation-string
9fec7fedbf1b [xemacs-hg @ 2007-10-31 11:21:02 by aidan]
aidan
parents: 4103
diff changeset
833 (stringp Installation-string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (lambda ()
4246
9fec7fedbf1b [xemacs-hg @ 2007-10-31 11:21:02 by aidan]
aidan
parents: 4103
diff changeset
836 (princ Installation-string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 "Installation")
4246
9fec7fedbf1b [xemacs-hg @ 2007-10-31 11:21:02 by aidan]
aidan
parents: 4103
diff changeset
838 (error 'unimplemented "No Installation information available.")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 (defun view-emacs-news ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 "Display info on recent changes to XEmacs."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (interactive)
2986
66ad30774567 [xemacs-hg @ 2005-10-10 02:45:31 by youngs]
youngs
parents: 2537
diff changeset
843 (Help-find-file (expand-file-name "NEWS" data-directory)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3074
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
845 (defun view-xemacs-problems ()
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
846 "Display known problems with XEmacs."
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
847 (interactive)
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
848 (Help-find-file (expand-file-name "PROBLEMS" data-directory)))
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
849
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (defun xemacs-www-page ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 "Go to the XEmacs World Wide Web page."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (interactive)
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 771
diff changeset
853 (if-fboundp 'browse-url
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
854 (browse-url "http://www.xemacs.org/")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 (error "xemacs-www-page requires browse-url")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 (defun xemacs-www-faq ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 "View the latest and greatest XEmacs FAQ using the World Wide Web."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (interactive)
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 771
diff changeset
860 (if-fboundp 'browse-url
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
861 (browse-url "http://www.xemacs.org/faq/index.html")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (error "xemacs-www-faq requires browse-url")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 (defun xemacs-local-faq ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 "View the local copy of the XEmacs FAQ.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 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
867 instead, to ensure that you get the most up-to-date information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 (info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 (Info-find-node "xemacs-faq" "Top"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 (switch-to-buffer "*info*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
874 (defun view-sample-init-el ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
875 "Display the sample init.el file."
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
876 (interactive)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
877 (Help-find-file (locate-data-file "sample.init.el")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
878
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 (defcustom view-lossage-key-count 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 "*Number of keys `view-lossage' shows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 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
882 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 (defcustom view-lossage-message-count 100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 "*Number of minibuffer messages `view-lossage' shows."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 :group 'help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (defun print-recent-messages (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 "Print N most recent messages to standard-output, most recent first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 If N is nil, all messages will be printed."
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
893 (clear-message) ;; make sure current message goes into log
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 (let ((buffer (get-buffer-create " *Message-Log*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 oldpoint extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 (goto-char (point-max buffer) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 (while (and (not (bobp buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 (or (null n) (>= (decf n) 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 (setq oldpoint (point buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 (setq extent (extent-at oldpoint buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 'message-multiline nil 'before))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 ;; If the message was multiline, move all the way to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 ;; beginning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 (if extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 (goto-char (extent-start-position extent) buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 (forward-line -1 buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (insert-buffer-substring buffer (point buffer) oldpoint)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
911 (defun view-warnings ()
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
912 "Display warnings issued."
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
913 (interactive)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
914 (with-displaying-help-buffer
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
915 (lambda ()
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
916 (let ((buf (get-buffer "*Warnings*")))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
917 (when buf
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
918 (save-excursion
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
919 (set-buffer standard-output)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
920 (map-extents
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
921 #'(lambda (extent arg)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
922 (goto-char (point-min))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
923 (insert (extent-string extent)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
924 buf)))))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
925 "warnings"))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
926
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
927 (defun view-lossage (&optional no-keys)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 "Display recent input keystrokes and recent minibuffer messages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 The number of keys shown is controlled by `view-lossage-key-count'.
1038
4bc5bb3ea5ad [xemacs-hg @ 2002-10-08 03:36:09 by youngs]
youngs
parents: 863
diff changeset
930 The number of messages shown is controlled by `view-lossage-message-count'.
4bc5bb3ea5ad [xemacs-hg @ 2002-10-08 03:36:09 by youngs]
youngs
parents: 863
diff changeset
931
4bc5bb3ea5ad [xemacs-hg @ 2002-10-08 03:36:09 by youngs]
youngs
parents: 863
diff changeset
932 If optional arg NO-KEYS (prefix arg, interactively) is non-nil,
4bc5bb3ea5ad [xemacs-hg @ 2002-10-08 03:36:09 by youngs]
youngs
parents: 863
diff changeset
933 then recent input keystrokes output is omitted."
4bc5bb3ea5ad [xemacs-hg @ 2002-10-08 03:36:09 by youngs]
youngs
parents: 863
diff changeset
934 (interactive "P")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 (lambda ()
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
937 (unless no-keys
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
938 (princ (key-description (recent-keys view-lossage-key-count)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
939 (save-excursion
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
940 (set-buffer standard-output)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
941 (goto-char (point-min))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
942 (insert "Recent keystrokes:\n\n")
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
943 (while (progn (move-to-column 50) (not (eobp)))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
944 (search-forward " " nil t)
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
945 (insert "\n")))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
946 (princ "\n\n\n"))
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
947 ;; Copy the messages from " *Message-Log*", reversing their order and
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
948 ;; handling multiline messages correctly.
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 776
diff changeset
949 (princ "Recent minibuffer messages (most recent first):\n\n")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 (print-recent-messages view-lossage-message-count))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 "lossage"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 (define-function 'help 'help-for-help)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 (make-help-screen help-for-help
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 "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:"
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
957 (concat
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
958 "Type a Help option:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 \(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
960
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
961 Help on key bindings:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
962
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
963 \\[describe-bindings] Table of all key bindings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
964 \\[describe-key-briefly] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
965 it displays the corresponding command name.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
966 \\[describe-key] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
967 it displays the documentation for the command bound to that key.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
968 (Terser but more up-to-date than what's in the manual.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
969 \\[Info-goto-emacs-key-command-node] Type a key sequence or select a menu item;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
970 it jumps to the full documentation in the XEmacs User's Manual
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
971 for the corresponding command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
972 \\[view-lossage] Recent input keystrokes and minibuffer messages.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
973 \\[describe-mode] Documentation of current major and minor modes.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
974 \\[describe-pointer] Table of all mouse-button bindings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
975 \\[where-is] Type a command name; it displays which keystrokes invoke that command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
976
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
977 Help on functions and variables:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
978
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 \\[hyper-apropos] Type a substring; it shows a hypertext list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 functions and variables that contain that substring.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
981 \\[command-apropos] Older version of apropos; superseded by previous command.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
982 \\[apropos-documentation] Type a substring; it shows a hypertext list of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
983 functions and variables containing that substring anywhere
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
984 in their documentation.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
985 \\[Info-goto-emacs-command-node] Type a command name; it jumps to the full documentation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
986 in the XEmacs User's Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
987 \\[describe-function] Type a command or function name; it shows its documentation.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
988 (Terser but more up-to-date than what's in the manual.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
989 \\[Info-elisp-ref] Type a function name; it jumps to the full documentation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
990 in the XEmacs Lisp Reference Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
991 \\[Info-search-index-in-xemacs-and-lispref] Type a substring; it looks it up in the indices of both
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
992 the XEmacs User's Manual and the XEmacs Lisp Reference Manual.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
993 It jumps to the first match (preferring an exact match); you
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
994 can use `\\<Info-mode-map>\\[Info-index-next]\\<help-map>' to successively visit other matches.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
995 \\[describe-variable] Type a variable name; it displays its documentation and value.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
996
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
997 Miscellaneous:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
998
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
999 "
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1000 (if (string-match "beta" emacs-version)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1001 "\\[describe-beta] Special considerations about running a beta version of XEmacs.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1002 "
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1003 "")
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1004 "
3074
0f411920c8db [xemacs-hg @ 2005-11-16 12:12:57 by malcolmp]
malcolmp
parents: 3065
diff changeset
1005 \\[view-xemacs-problems] Known problems.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 \\[customize] Customize Emacs options.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1007 \\[describe-distribution] How to obtain XEmacs.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1008 \\[describe-last-error] Information about the most recent error.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 \\[xemacs-local-faq] Local copy of the XEmacs FAQ.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 \\[info] Info documentation reader.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 \\[Info-query] Type an Info file name; it displays it in Info reader.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1012 \\[describe-copying] XEmacs copying permission (General Public License).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 \\[view-emacs-news] News of recent XEmacs changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 \\[finder-by-keyword] Type a topic keyword; it finds matching packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 \\[describe-syntax] Contents of syntax table with explanations.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1016 \\[view-sample-init-el] View the sample init.el that comes with XEmacs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 \\[help-with-tutorial] XEmacs learn-by-doing tutorial.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1018 \\[describe-no-warranty] Information on absence of warranty for XEmacs."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1019 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 help-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 (defun function-called-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 "Return the function which is called by the list containing point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 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
1025 If that doesn't give a function, return nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 (or (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 (save-restriction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 (narrow-to-region (max (point-min) (- (point) 1000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 (backward-up-list 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 (forward-char 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 (let (obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 (setq obj (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 (and (symbolp obj) (fboundp obj) obj)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 (skip-chars-forward "`'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 (and (symbolp obj) (fboundp obj) obj)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 (defun function-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 "Return the function whose name is around point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 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
1050 list containing point. If that doesn't give a function, return nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 (or (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 (skip-chars-forward "`'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 (and (symbolp obj) (fboundp obj) obj)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 (save-restriction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 (narrow-to-region (max (point-min) (- (point) 1000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 (backward-up-list 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 (forward-char 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 (let (obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 (setq obj (read (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 (and (symbolp obj) (fboundp obj) obj)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1072 (defun function-at-event (event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1073 "Return the function whose name is around the position of EVENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1074 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
1075 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
1076 \(You cannot use (interactive \"e\"), unfortunately. This returns a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1077 misc-user event.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1078
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1079 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
1080 there is no function around that point, nil is returned."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1081 (if (and event (event-buffer event) (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1082 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1083 (set-buffer (event-buffer event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1084 (goto-char (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1085 (function-at-point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 ;; 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
1088 ;; distinguish hackers from non-hackers automatically!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 (defcustom describe-function-show-arglist t
4695
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1090 "*If non-nil, describe-function will show the function's arglist."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 :group 'help-appearance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1094 (define-obsolete-function-alias
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1095 ;; Moved to using the version in loadhist.el
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1096 'describe-function-find-symbol
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1097 'symbol-file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 'describe-function-find-file
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1101 'symbol-file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 (defun describe-function (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 "Display the full documentation of FUNCTION (a symbol).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 When run interactively, it defaults to any function found by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 `function-at-point'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 (let* ((fn (function-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 (val (let ((enable-recursive-minibuffers t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 (completing-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 (if fn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 (format (gettext "Describe function (default %s): ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 (gettext "Describe function: "))
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1115 obarray 'fboundp t nil 'function-history
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1116 (symbol-name fn)))))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1117 (list (intern val))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 (describe-function-1 function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 ;; Return the text we displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 (buffer-string nil nil standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 (format "function `%s'" function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 (defun function-obsolete-p (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 "Return non-nil if FUNCTION is obsolete."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 (not (null (get function 'byte-obsolete-info))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 (defun function-obsoleteness-doc (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 "If FUNCTION is obsolete, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 (let ((obsolete (get function 'byte-obsolete-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 (if obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 (format "Obsolete; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 (if (stringp (car obsolete))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 (car obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 (format "use `%s' instead." (car obsolete)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 (defun function-compatible-p (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 "Return non-nil if FUNCTION is present for Emacs compatibility."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 (not (null (get function 'byte-compatible-info))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 (defun function-compatibility-doc (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 "If FUNCTION is Emacs compatible, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 (let ((compatible (get function 'byte-compatible-info)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 (if compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 (format "Emacs Compatible; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 (if (stringp (car compatible))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 (car compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 (format "use `%s' instead." (car compatible)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 ;Here are all the possibilities below spelled out, for the benefit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 ;of the I18N3 snarfer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 ;(gettext "a built-in function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 ;(gettext "an interactive built-in function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 ;(gettext "a built-in macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 ;(gettext "an interactive built-in macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 ;(gettext "a compiled Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 ;(gettext "an interactive compiled Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 ;(gettext "a compiled Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 ;(gettext "an interactive compiled Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 ;(gettext "a Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 ;(gettext "an interactive Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 ;(gettext "a Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 ;(gettext "an interactive Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 ;(gettext "an autoloaded Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 ;(gettext "an interactive autoloaded Lisp function")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 ;(gettext "an autoloaded Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 ;(gettext "an interactive autoloaded Lisp macro")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 ;; taken out of `describe-function-1'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 (defun function-arglist (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 "Return a string giving the argument list of FUNCTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 (function-arglist 'function-arglist)
4694
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1177 => \"(function-arglist FUNCTION)\"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 This function is used by `describe-function-1' to list function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 arguments in the standard Lisp style."
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1181 (let* ((fnc (indirect-function function))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1182 (fndef (if (eq (car-safe fnc) 'macro)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1183 (cdr fnc)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1184 fnc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 (arglist
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1186 (cond ((compiled-function-p fndef)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1187 (compiled-function-arglist fndef))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1188 ((eq (car-safe fndef) 'lambda)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1189 (nth 1 fndef))
4695
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1190 ((or (subrp fndef) (eq 'autoload (car-safe fndef)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1191 (let* ((doc (documentation function))
3065
3fa430e1aa35 [xemacs-hg @ 2005-11-13 10:52:47 by ben]
ben
parents: 2986
diff changeset
1192 (args (and doc
3fa430e1aa35 [xemacs-hg @ 2005-11-13 10:52:47 by ben]
ben
parents: 2986
diff changeset
1193 (string-match
4642
48b45a606961 Support #'function-arglist with built-in special forms.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4601
diff changeset
1194 "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'"
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1195 doc)
4642
48b45a606961 Support #'function-arglist with built-in special forms.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4601
diff changeset
1196 (match-string 1 doc)))
48b45a606961 Support #'function-arglist with built-in special forms.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4601
diff changeset
1197 (args (and args (replace-in-string args
4671
e9b88e997479 Deal with arglist newlines better, #'function-arglist, #'function-documentation
Aidan Kehoe <kehoea@parhasard.net>
parents: 4642
diff changeset
1198 "[ ]*\\\\\n[ \t]*"
4642
48b45a606961 Support #'function-arglist with built-in special forms.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4601
diff changeset
1199 " " t))))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1200 ;; If there are no arguments documented for the
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1201 ;; subr, rather don't print anything.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1202 (cond ((null args) t)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1203 ((equal args "") nil)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1204 (args))))
4694
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1205 (t t)))
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1206 (print-gensym nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 (cond ((listp arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 (prin1-to-string
4694
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1209 (cons function (loop
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1210 for arg in arglist
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1211 collect (if (memq arg '(&optional &rest))
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1212 arg
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1213 (make-symbol (upcase (symbol-name
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1214 arg))))))
2ac296807b88 Don't needlessly intern symbols, #'function-arglist, #'cl-function-arglist
Aidan Kehoe <kehoea@parhasard.net>
parents: 4671
diff changeset
1215
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 ((stringp arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 (format "(%s %s)" function arglist)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 (defun function-documentation (function &optional strip-arglist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 "Return a string giving the documentation for FUNCTION, if any.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 If the optional argument STRIP-ARGLIST is non-nil, remove the arglist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 part of the documentation of internal subroutines."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 (let ((doc (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 (or (documentation function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 (gettext "not documented"))
2275
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1227 (void-function "(alias for undefined function)")
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1228 (error "(unexpected error from `documention')"))))
4695
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1229 (when (and strip-arglist
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1230 (string-match "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'" doc))
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1231 (setq doc (substring doc 0 (match-beginning 0)))
fee33ab25966 Add arglist info for autoloaded functions and macros.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4694
diff changeset
1232 (and (zerop (length doc)) (setq doc (gettext "not documented"))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 doc))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1235 ;; replacement for `princ' that puts the text in the specified face,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1236 ;; if possible
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1237 (defun Help-princ-face (object face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1238 (cond ((bufferp standard-output)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1239 (let ((opoint (point standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1240 (princ object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1241 (put-nonduplicable-text-property opoint (point standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1242 'face face standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1243 ((markerp standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1244 (let ((buf (marker-buffer standard-output))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1245 (pos (marker-position standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1246 (princ object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1247 (put-nonduplicable-text-property
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1248 pos (marker-position standard-output) 'face face buf)))
1779
fb556d2c7344 [xemacs-hg @ 2003-11-06 05:11:15 by stephent]
stephent
parents: 1123
diff changeset
1249 (t (princ object))))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1250
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1251 ;; replacement for `prin1' that puts the text in the specified face,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1252 ;; if possible
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1253 (defun Help-prin1-face (object face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1254 (cond ((bufferp standard-output)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1255 (let ((opoint (point standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1256 (prin1 object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1257 (put-nonduplicable-text-property opoint (point standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1258 'face face standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1259 ((markerp standard-output)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1260 (let ((buf (marker-buffer standard-output))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1261 (pos (marker-position standard-output)))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1262 (prin1 object)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1263 (put-nonduplicable-text-property
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1264 pos (marker-position standard-output) 'face face buf)))
1779
fb556d2c7344 [xemacs-hg @ 2003-11-06 05:11:15 by stephent]
stephent
parents: 1123
diff changeset
1265 (t (prin1 object))))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1266
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1267 (defvar help-symbol-regexp
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1268 (let ((sym-char "[+a-zA-Z0-9_:*]")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1269 (sym-char-no-dash "[-+a-zA-Z0-9_:*]"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1270 (concat "\\("
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1271 ;; a symbol with a - in it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272 "\\<\\(" sym-char-no-dash "+\\(-" sym-char-no-dash "+\\)+\\)\\>"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1273 "\\|"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1274 "`\\(" sym-char "+\\)'"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1275 "\\)")))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1276
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1277 (defun help-symbol-run-function-1 (ev ex fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1278 (let ((help-sticky-window
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1279 ;; 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
1280 ;; goes in the same window.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1281 (if (and (event-buffer ev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1282 (symbol-value-in-buffer 'help-window-config
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1283 (event-buffer ev)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1284 (event-window ev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1285 help-sticky-window)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1286 (funcall fun (extent-property ex 'help-symbol))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1287
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1288 (defun help-symbol-run-function (fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1289 (let ((ex (extent-at-event last-popup-menu-event 'help-symbol)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1290 (when ex
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291 (help-symbol-run-function-1 last-popup-menu-event ex fun))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1293 (defvar help-symbol-function-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1294 '(["View %_Documentation" (help-symbol-run-function 'describe-function)]
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1295 ["Find %_Function Source" (help-symbol-run-function 'find-function)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1296 (fboundp #'find-function)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1297 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1298 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1299
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1300 (defvar help-symbol-variable-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1301 '(["View %_Documentation" (help-symbol-run-function 'describe-variable)]
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1302 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1303 (fboundp #'find-variable)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1304 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1305 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1306
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1307 (defvar help-symbol-function-and-variable-context-menu
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1308 '(["View Function %_Documentation" (help-symbol-run-function
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1309 'describe-function)]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1310 ["View Variable D%_ocumentation" (help-symbol-run-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1311 'describe-variable)]
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1312 ["Find %_Function Source" (help-symbol-run-function 'find-function)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1313 (fboundp #'find-function)]
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1314 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1315 (fboundp #'find-variable)]
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1316 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1318
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1319 (defun frob-help-extents (buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1320 ;; Look through BUFFER, starting at the buffer's point and continuing
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1321 ;; till end of file, and find documented functions and variables.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1322 ;; 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
1323 ;; properties:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1324 ;; 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
1325 ;; 2. help-symbol is the name of the symbol.
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1326 ;; 3. face is 'hyper-apropos-hyperlink.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1327 ;; 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
1328 ;; the symbol is a function, variable, or both.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1329 ;; 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
1330 ;; replacing the existing help contents.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1331 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1332 (set-buffer buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1333 (let (b e name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1334 (while (re-search-forward help-symbol-regexp nil t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1335 (setq b (or (match-beginning 2) (match-beginning 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 (setq e (or (match-end 2) (match-end 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337 (setq name (buffer-substring b e))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1338 (let* ((sym (intern-soft name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1339 (var (and sym (boundp sym)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340 (documentation-property sym
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1341 'variable-documentation t)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1342 (fun (and sym (fboundp sym)
2275
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1343 (condition-case nil
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1344 (documentation sym t)
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1345 (void-function "(alias for undefined function)")
445bd1969ed0 [xemacs-hg @ 2004-09-15 08:30:25 by stephent]
stephent
parents: 2137
diff changeset
1346 (error "(unexpected error from `documention')")))))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1347 (when (or var fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1348 (let ((ex (make-extent b e)))
622
11502791fc1c [xemacs-hg @ 2001-06-22 01:49:57 by ben]
ben
parents: 502
diff changeset
1349 (require 'hyper-apropos)
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1350
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1351 (set-extent-property ex 'mouse-face 'highlight)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1352 (set-extent-property ex 'help-symbol sym)
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1353 (set-extent-property ex 'face 'hyper-apropos-hyperlink)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1354 (set-extent-property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1355 ex 'context-menu
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1356 (cond ((and var fun)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1357 help-symbol-function-and-variable-context-menu)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1358 (var help-symbol-variable-context-menu)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1359 (fun help-symbol-function-context-menu)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1360 (set-extent-property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1361 ex 'activate-function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1362 (if fun
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1363 #'(lambda (ev ex)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1364 (help-symbol-run-function-1 ev ex 'describe-function))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1365 #'(lambda (ev ex)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1366 (help-symbol-run-function-1 ev ex 'describe-variable))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1367 ))))))) ;; 11 parentheses!
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 (defun describe-function-1 (function &optional nodoc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 "This function does the work for `describe-function'."
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1371 (princ "`")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1372 ;; (Help-princ-face function 'font-lock-function-name-face) overkill
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1373 (princ function)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1374 (princ "' is ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 (let* ((def function)
4595
a1a8728fec10 Distinguish between special forms and subrs, #'describe-function-1.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4535
diff changeset
1376 aliases file-name kbd-macro-p fndef macrop)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 (while (and (symbolp def) (fboundp def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 (when (not (eq def function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 ;; I18N3 Need gettext due to concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 (concat aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 "\n which is an alias for `%s', "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 (symbol-name def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 (format "an alias for `%s', " (symbol-name def)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 (setq def (symbol-function def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 (if (eq 'macro (car-safe def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 (setq fndef (cdr def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 macrop t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 (setq fndef def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 (if aliases (princ aliases))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 (let ((int #'(lambda (string an-p macro-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 (princ (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 (gettext (concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 (cond ((commandp def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 "an interactive ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 (an-p "an ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 (t "a "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 "%s"
4595
a1a8728fec10 Distinguish between special forms and subrs, #'describe-function-1.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4535
diff changeset
1401 (cond
a1a8728fec10 Distinguish between special forms and subrs, #'describe-function-1.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4535
diff changeset
1402 ((eq 'neither macro-p)
a1a8728fec10 Distinguish between special forms and subrs, #'describe-function-1.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4535
diff changeset
1403 "")
4642
48b45a606961 Support #'function-arglist with built-in special forms.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4601
diff changeset
1404 (macro-p " macro")
4595
a1a8728fec10 Distinguish between special forms and subrs, #'describe-function-1.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4535
diff changeset
1405 (t " function"))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 (cond ((or (stringp def) (vectorp def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 (princ "a keyboard macro.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 (setq kbd-macro-p t))
4905
755ae5b97edb Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4695
diff changeset
1410 ((special-operator-p fndef)
755ae5b97edb Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4695
diff changeset
1411 (funcall int "built-in special operator" nil 'neither))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 ((subrp fndef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 (funcall int "built-in" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 ((compiled-function-p fndef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 (funcall int "compiled Lisp" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 ((eq (car-safe fndef) 'lambda)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 (funcall int "Lisp" nil macrop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 ((eq (car-safe def) 'autoload)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 (funcall int "autoloaded Lisp" t (elt def 4)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 ((and (symbolp def) (not (fboundp def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 (princ "a symbol with a void (unbound) function definition."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 (princ "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 (or file-name
4535
69a1eda3da06 Distinguish vars and functions in #'symbol-file, #'describe-{function,variable}
Aidan Kehoe <kehoea@parhasard.net>
parents: 4506
diff changeset
1426 (setq file-name (symbol-file function 'defun)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1427 (when file-name
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1428 (princ " -- loaded from \"")
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1429 (if (not (bufferp standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1430 (princ file-name)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1431 (let ((opoint (point standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1432 e)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1433 (require 'hyper-apropos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1434 (princ file-name)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1435 (setq e (make-extent opoint (point standard-output)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1436 standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1437 (set-extent-property e 'face 'hyper-apropos-hyperlink)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1438 (set-extent-property e 'mouse-face 'highlight)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1439 (set-extent-property e 'find-function-symbol function)))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1440 (princ "\"\n"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 (if describe-function-show-arglist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 (let ((arglist (function-arglist function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 (when arglist
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1444 (require 'hyper-apropos)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1445 (Help-princ-face arglist 'hyper-apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 (terpri))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 (cond (kbd-macro-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 (princ "These characters are executed:\n\n\t")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 (princ (key-description def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 (cond ((setq def (key-binding def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 (princ (format "\n\nwhich executes the command `%s'.\n\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 def))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 (describe-function-1 def))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 (nodoc nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 ;; tell the user about obsoleteness.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 ;; If the function is obsolete and is aliased, don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 ;; even bother to report the documentation, as a further
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 ;; encouragement to use the new function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 (let ((obsolete (function-obsoleteness-doc function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 (compatible (function-compatibility-doc function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 (when obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 (princ obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 (when compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 (princ compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 (unless (and obsolete aliases)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 (let ((doc (function-documentation function t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 (princ "Documentation:\n")
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1474 (let ((oldp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1475 newp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1476 (princ doc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1477 (setq newp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1478 (goto-char oldp standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1479 (frob-help-extents standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1480 (goto-char newp standard-output))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 (unless (or (equal doc "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 (eq ?\n (aref doc (1- (length doc)))))
4335
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1483 (terpri)))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1484 (when (commandp function)
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1485 (princ "\nInvoked with:\n")
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1486 (let ((global-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1487 (where-is-internal function global-map))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1488 (global-tty-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1489 (where-is-internal function global-tty-map))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1490 (global-window-system-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1491 (where-is-internal function global-window-system-map)))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1492 (if (or global-binding global-tty-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1493 global-window-system-binding)
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1494 (if (and (equal global-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1495 global-tty-binding)
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1496 (equal global-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1497 global-window-system-binding))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1498 (princ
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1499 (substitute-command-keys
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1500 (format "\n\\[%s]" function)))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1501 (when (and global-window-system-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1502 (not (equal global-window-system-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1503 global-binding)))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1504 (princ
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1505 (format
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1506 "\n%s\n -- under window systems\n"
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1507 (mapconcat #'key-description
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1508 global-window-system-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1509 ", "))))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1510 (when (and global-tty-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1511 (not (equal global-tty-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1512 global-binding)))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1513 (princ
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1514 (format
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1515 "\n%s\n -- under TTYs\n"
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1516 (mapconcat #'key-description
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1517 global-tty-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1518 ", "))))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1519 (when global-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1520 (princ
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1521 (format
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1522 "\n%s\n -- generally (that is, unless\
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1523 overridden by TTY- or
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1524 window-system-specific mappings)\n"
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1525 (mapconcat #'key-description
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1526 global-binding
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1527 ", ")))))
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1528 (princ (substitute-command-keys
4ba890988caa Within #'describe-function, say what commands are bound to.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4246
diff changeset
1529 (format "\n\\[%s]" function))))))))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 ;;; are binding this to keys.]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 (defun describe-function-arglist (function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 (interactive (list (or (function-at-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 (error "no function call at point"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 (message nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 (message (function-arglist function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 (defun variable-at-point ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 (ignore-errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 (with-syntax-table emacs-lisp-mode-syntax-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 (or (not (zerop (skip-syntax-backward "_w")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 (eq (char-syntax (char-after (point))) ?w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 (eq (char-syntax (char-after (point))) ?_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 (forward-sexp -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 (skip-chars-forward "'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 (let ((obj (read (current-buffer))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 (and (symbolp obj) (boundp obj) obj))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1551 (defun variable-at-event (event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1552 "Return the variable whose name is around the position of EVENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1553 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
1554 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
1555 \(You cannot use (interactive \"e\"), unfortunately. This returns a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1556 misc-user event.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1557
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1558 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
1559 there is no variable around that point, nil is returned."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1560 (if (and event (event-buffer event) (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1561 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1562 (set-buffer (event-buffer event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1563 (goto-char (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1564 (variable-at-point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1565
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 (defun variable-obsolete-p (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 "Return non-nil if VARIABLE is obsolete."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 (not (null (get variable 'byte-obsolete-variable))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 (defun variable-obsoleteness-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 "If VARIABLE is obsolete, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 (let ((obsolete (get variable 'byte-obsolete-variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 (if obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 (format "Obsolete; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 (if (stringp obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 (format "use `%s' instead." obsolete))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 (defun variable-compatible-p (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 "Return non-nil if VARIABLE is Emacs compatible."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 (not (null (get variable 'byte-compatible-variable))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 (defun variable-compatibility-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 "If VARIABLE is Emacs compatible, return a string describing this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 (let ((compatible (get variable 'byte-compatible-variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 (if compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 (format "Emacs Compatible; %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 (if (stringp compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 (format "use `%s' instead." compatible))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 (defun built-in-variable-doc (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 "Return a string describing whether VARIABLE is built-in."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 (let ((type (built-in-variable-type variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 (case type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 (integer "a built-in integer variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 (const-integer "a built-in constant integer variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 (boolean "a built-in boolean variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 (const-boolean "a built-in constant boolean variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 (object "a simple built-in variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 (const-object "a simple built-in constant variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 (const-specifier "a built-in constant specifier variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 (current-buffer "a built-in buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 (const-current-buffer "a built-in constant buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 (default-buffer "a built-in default buffer-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 (selected-console "a built-in console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 (const-selected-console "a built-in constant console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 (default-console "a built-in default console-local variable")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 (if type "an unknown type of built-in variable?"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 "a variable declared in Lisp")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 (defun describe-variable (variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 "Display the full documentation of VARIABLE (a symbol)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 (let* ((v (variable-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 (val (let ((enable-recursive-minibuffers t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 (completing-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 (if v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 (format "Describe variable (default %s): " v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 (gettext "Describe variable: "))
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1622 obarray 'boundp t nil 'variable-history
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1623 (symbol-name v)))))
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1624 (list (intern val))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 (let ((origvar variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 aliases)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 (let ((print-escape-newlines t))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1630 (princ "`")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1631 ;; (Help-princ-face (symbol-name variable)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 464
diff changeset
1632 ;; 'font-lock-variable-name-face) overkill
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1633 (princ (symbol-name variable))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 456
diff changeset
1634 (princ "' is ")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 (while (variable-alias variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 (let ((newvar (variable-alias variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 ;; I18N3 Need gettext due to concat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 (concat aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 (format "\n which is an alias for `%s',"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 (symbol-name newvar))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 (setq aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 (format "an alias for `%s',"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 (symbol-name newvar))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 (setq variable newvar)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 (if aliases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 (princ (format "%s" aliases)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 (princ (built-in-variable-doc variable))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 (princ ".\n")
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1651 (require 'hyper-apropos)
4535
69a1eda3da06 Distinguish vars and functions in #'symbol-file, #'describe-{function,variable}
Aidan Kehoe <kehoea@parhasard.net>
parents: 4506
diff changeset
1652 (let ((file-name (symbol-file variable 'defvar))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1653 opoint e)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1654 (when file-name
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1655 (princ " -- loaded from \"")
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1656 (if (not (bufferp standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1657 (princ file-name)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1658 (setq opoint (point standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1659 (princ file-name)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1660 (setq e (make-extent opoint (point standard-output)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1661 standard-output))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1662 (set-extent-property e 'face 'hyper-apropos-hyperlink)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1663 (set-extent-property e 'mouse-face 'highlight)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1664 (set-extent-property e 'find-variable-symbol variable))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1665 (princ"\"\n")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 (princ "\nValue: ")
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1667 (if (not (boundp variable))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1668 (Help-princ-face "void\n" 'hyper-apropos-documentation)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1669 (Help-prin1-face (symbol-value variable)
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
1670 'hyper-apropos-documentation)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 (cond ((local-variable-p variable (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 (let* ((void (cons nil nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 (def (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 (default-value variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 (error void))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 (princ "This value is specific to the current buffer.\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 (if (local-variable-p variable nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 (princ "(Its value is local to each buffer.)\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 (if (if (eq def void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 (boundp variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 (not (eq (symbol-value variable) def)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 ;; #### I18N3 doesn't localize properly!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 (progn (princ "Default-value: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 (if (eq def void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 (princ "void\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 (prin1 def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 (terpri)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 ((local-variable-p variable (current-buffer) t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 (princ "Setting it would make its value buffer-local.\n\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 (princ "Documentation:")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 (let ((doc (documentation-property variable 'variable-documentation))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 (obsolete (variable-obsoleteness-doc origvar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 (compatible (variable-compatibility-doc origvar)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 (when obsolete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 (princ obsolete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 (when compatible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 (princ compatible)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 (terpri)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 (terpri))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 ;; don't bother to print anything if variable is obsolete and aliased.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 (when (or (not obsolete) (not aliases))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 (if doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 ;; note: documentation-property calls substitute-command-keys.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1711 (let ((oldp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1712 newp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1713 (princ doc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1714 (setq newp (point standard-output))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1715 (goto-char oldp standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1716 (frob-help-extents standard-output)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1717 (goto-char newp standard-output))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 (princ "not documented as a variable."))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 (terpri)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 (format "variable `%s'" variable)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 (defun sorted-key-descriptions (keys &optional separator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 "Sort and separate the key descriptions for KEYS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 The sorting is done by length (shortest bindings first), and the bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 are separated with SEPARATOR (\", \" by default)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 (mapconcat 'key-description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 (sort keys #'(lambda (x y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 (< (length x) (length y))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 (or separator ", ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 (defun where-is (definition &optional insert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 "Print message listing key sequences that invoke specified command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 Argument is a command definition, usually a symbol with a function definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 When run interactively, it defaults to any function found by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 `function-at-point'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 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
1737 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 (let ((fn (function-at-point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 (enable-recursive-minibuffers t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 (setq val (read-command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 (if fn (format "Where is command (default %s): " fn)
456
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 444
diff changeset
1743 "Where is command: ")
e7ef97881643 Import from CVS: tag r21-2-43
cvs
parents: 444
diff changeset
1744 (and fn (symbol-name fn))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 (list (if (equal (symbol-name val) "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 fn val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 current-prefix-arg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 (let ((keys (where-is-internal definition)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 (if keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 (if insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 (princ (format "%s (%s)" (sorted-key-descriptions keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 definition) (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 (message "%s is on %s" definition (sorted-key-descriptions keys)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 (if insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 (princ (format (if (commandp definition) "M-x %s RET"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 "M-: (%s ...)") definition) (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 (message "%s is not on any keys" definition))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 ;; `locate-library' moved to "packages.el"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 ;; Functions ported from C into Lisp in XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 (defun describe-syntax ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 "Describe the syntax specifications in the syntax table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 The descriptions are inserted in a buffer, which is then displayed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 ;; defined in syntax.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 (describe-syntax-table (syntax-table) standard-output))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 (format "syntax-table for %s" major-mode)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 (defun list-processes ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 "Display a list of all processes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 \(Any processes listed as Exited or Signaled are actually eliminated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 after the listing is made.)"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 (with-output-to-temp-buffer "*Process List*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 (set-buffer standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 (buffer-disable-undo standard-output)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 (make-local-variable 'truncate-lines)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 (setq truncate-lines t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 ;; 00000000001111111111222222222233333333334444444444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 ;; 01234567890123456789012345678901234567890123456789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 ;; rewritten for I18N3. This one should stay rewritten
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 ;; so that the dashes will line up properly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 (let ((tail (process-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 (let* ((p (car tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 (pid (process-id p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 (s (process-status p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 (setq tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 (princ (format "%-13s" (process-name p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 (princ s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 (princ (format " %d" (process-exit-status p))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 (if (memq s '(signal exit closed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 ;; Do delete-exited-processes' work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 (delete-process p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 (indent-to 22 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 (let ((b (process-buffer p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 (cond ((not b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 (princ "(none)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 ((not (buffer-name b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 (princ "(killed)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 (princ (buffer-name b)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 (indent-to 37 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 (let ((tn (process-tty-name p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 (cond ((not tn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 (princ "(none)"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 (princ (format "%s" tn)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 (indent-to 49 1) ;####
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 (if (not (integerp pid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 (princ "network stream connection ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 (princ (car pid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 (princ "@")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 (princ (cdr pid)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 (let ((cmd (process-command p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 (while cmd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 (princ (car cmd))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 (setq cmd (cdr cmd))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 (if cmd (princ " ")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 (terpri))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 430
diff changeset
1831 ;; 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
1832 (defun help-keymap-with-help-key (keymap form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 "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
1834 invoking FORM like help-form. An existing binding is not overridden.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 If FORM is nil then no binding is made."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 (let ((map (copy-keymap keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 (key (if (characterp help-char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 (vector (character-to-event help-char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 help-char)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 (when (and form key (not (lookup-key map key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 (define-key map key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 `(lambda () (interactive) (help-print-help-form ,form))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 (defun help-print-help-form (form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 (let ((string (eval form)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 (if (stringp string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 (with-displaying-help-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 (insert string)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1851 (defun help-find-source-or-scroll-up (&optional pos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1852 "Follow any cross reference to source code; if none, scroll up. "
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1853 (interactive "d")
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1854 (let ((e (extent-at pos nil 'find-function-symbol)))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1855 (if (and-fboundp #'find-function e)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1856 (with-fboundp #'find-function
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1857 (find-function (extent-property e 'find-function-symbol)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1858 (setq e (extent-at pos nil 'find-variable-symbol))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1859 (if (and-fboundp #'find-variable e)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1860 (with-fboundp #'find-variable
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1861 (find-variable (extent-property e 'find-variable-symbol)))
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1862 (scroll-up 1)))))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1863
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1864 (defun help-mouse-find-source-or-track (event)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1865 "Follow any cross reference to source code under the mouse;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1866 if none, call mouse-track. "
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1867 (interactive "e")
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1868 (mouse-set-point event)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1869 (let ((e (extent-at (point) nil 'find-function-symbol)))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1870 (if (and-fboundp #'find-function e)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1871 (with-fboundp #'find-function
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1872 (find-function (extent-property e 'find-function-symbol)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1873 (setq e (extent-at (point) nil 'find-variable-symbol))
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1874 (if (and-fboundp #'find-variable e)
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1875 (with-fboundp #'find-variable
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3368
diff changeset
1876 (find-variable (extent-property e 'find-variable-symbol)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1877 (mouse-track event)))))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3074
diff changeset
1878
4506
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1879 (define-minor-mode temp-buffer-resize-mode
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1880 "Toggle the mode which makes windows smaller for temporary buffers.
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1881 With prefix argument ARG, turn the resizing of windows displaying temporary
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1882 buffers on if ARG is positive or off otherwise.
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1883 This makes the window the right height for its contents, but never
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1884 less than `window-min-height' nor a higher proportion of its frame than
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1885 `temp-buffer-max-height'. (Note the differing semantics of the latter
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1886 versus GNU Emacs, where `temp-buffer-max-height' is an integer number of
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1887 lines.)
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1888 This applies to `help', `apropos' and `completion' buffers, and some others."
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1889 :global t :group 'help
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1890 ;; XEmacs; our implementation of this is very different.
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1891 (setq temp-buffer-shrink-to-fit temp-buffer-resize-mode))
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1892
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1893 ;; GNU name for this function.
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1894 (defalias 'resize-temp-buffer-window 'shrink-window-if-larger-than-buffer)
bd28481bb0e1 Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4443
diff changeset
1895
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 ;;; help.el ends here