annotate lisp/packages/hyper-apropos.el @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents 34a5b81f86ba
children 43dd3413c7c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; hyper-apropos.el --- Hypertext emacs lisp documentation interface.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Sun Microsystems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Maintainer: Jonathan Stigelman <Stig@hackvan.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: lisp, tools, help, docs, matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; along with XEmacs; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; based upon emacs-apropos.el by Frank C. Guida <fcg@philabs.philips.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Rather than run apropos and print all the documentation at once,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; I find it easier to view a "table of contents" first, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; get the details for symbols as you need them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; This version of apropos prints two lists of symbols matching the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; given regexp: functions/macros and variables/constants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; The user can then do the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; - add an additional regexp to narrow the search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; - display documentation for the current symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; - find the tag for the current symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; - show any keybindings if the current symbol is a command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; - invoke functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; - set variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; An additional feature is the ability to search the current tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; table, allowing you to interrogate functions not yet loaded (this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; isn't available with the standard package).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Mouse bindings and menus are provided for XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; additions by Ben Wing <wing@666.com> July 1995:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; added support for function aliases, made programmer's apropos be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; default, various other hacking.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
57 ;; Massive changes by Christoph Wedler <wedler@fmi.uni-passau.de>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (or (fboundp 'pprint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (progn (autoload 'pp "pp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (fset 'pprint 'pp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;(require 'tags "etags")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
66 (defgroup hyper-apropos nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
67 "Hypertext emacs lisp documentation interface."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
68 :prefix "hypropos-"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
69 :group 'docs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
71 ;;;###autoload
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
72 (defcustom hypropos-show-brief-docs t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
73 "*If non-nil, `hyper-apropos' will display some documentation in the
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
74 \"*Hyper Apropos*\" buffer. Setting this to nil will speed up searches."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
75 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
76 :group 'hyper-apropos)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
77
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
78 (defcustom hypropos-shrink-window nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
79 "*If non-nil, shrink *Hyper Help* buffer if possible."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
80 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
81 :group 'hyper-apropos)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
82
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
83 (defcustom hypropos-prettyprint-long-values t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
84 "*If non-nil, then try to beautify the printing of very long values."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
85 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
86 :group 'hyper-apropos)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; I changed this to true because I think it's more useful this way. --ben
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
90 (defcustom hypropos-programming-apropos t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "*If non-nil, then `hyper-apropos' takes a bit longer and generates more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 output. If nil, then only functions that are interactive and variables that
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
93 are user variables are found by `hyper-apropos'."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
94 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 116
diff changeset
95 :group 'hyper-apropos)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
97 (defvar hypropos-ref-buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defvar hypropos-prev-wconfig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; #### - move this to subr.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (or (fboundp 'event-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defun event-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Returns the buffer associated with event, or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (let ((win (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (and win (window-buffer win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defmacro eval-in-buffer (buffer &rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Evaluate FORMS in BUFFER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (` (let ((_unwind_buf_ (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (progn (set-buffer (, buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (,@ forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (set-buffer _unwind_buf_)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (put 'eval-in-buffer 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; #### - move to faces.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defmacro init-face (face &rest init-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "Make a FACE if it doesn't already exist. Then if it does not differ from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 the default face, execute INIT-FORMS to initialize the face. While the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 init-forms are executing, the symbol `this' is bound to the face-object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 being initialized."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (` (let ((this (make-face (, face)))) ; harmless if the face is already there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (or (face-differs-from-default-p this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (, (cons 'progn init-forms))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (put 'init-face 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (init-face 'hyperlink
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;(set-face-underline-p this nil) -- dog slow and ugly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (set-face-foreground this "blue")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (init-face 'documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let* ((ff-instance (face-font-instance 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (ff (and ff-instance (font-instance-name ff-instance))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (cond ((and ff (string-match "courier" ff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; too wide unless you shrink it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; (copy-face 'italic this) fugly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; (make-face-smaller this) fugly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (set-face-foreground this "firebrick")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (error (copy-face 'italic this)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; mucking with the sizes of fonts (perhaps with the exception of courier or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; misc) is a generally losing thing to do. Changing the size of 'clean'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; really loses, for instance...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (init-face 'major-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (make-face-larger this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (make-face-larger this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (init-face 'section-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (make-face-larger this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (init-face 'heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (copy-face 'bold this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (init-face 'standout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (copy-face 'italic this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (init-face 'warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (and (eq (device-type) 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (eq (device-class) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (set-face-foreground this "red")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defvar hypropos-help-map (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (suppress-keymap map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (set-keymap-name map 'hypropos-help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (define-key map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (define-key map "b" 'scroll-down)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
173 (define-key map [delete] 'scroll-down)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
174 (define-key map [backspace] 'scroll-down)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (define-key map "/" 'isearch-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (define-key map "?" 'isearch-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; follow links
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (define-key map "\r" 'hypropos-get-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (define-key map "s" 'hypropos-set-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (define-key map "t" 'hypropos-find-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (define-key map "l" 'hypropos-last-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (define-key map [button2] 'hypropos-mouse-get-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (define-key map [button3] 'hypropos-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; for the totally hardcore...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (define-key map "D" 'hypropos-disassemble)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; administrativa
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (define-key map "a" 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (define-key map "n" 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (define-key map "q" 'hypropos-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Keybindings for both the *Hyper Help* buffer and the *Hyper Apropos* buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defvar hypropos-map (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (set-keymap-name map 'hypropos-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (set-keymap-parents map (list hypropos-help-map))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
197 ;; slightly different scrolling...
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (define-key map " " 'hypropos-scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (define-key map "b" 'hypropos-scroll-down)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
200 (define-key map [delete] 'hypropos-scroll-down)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
201 (define-key map [backspace] 'hypropos-scroll-down)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; act on the current line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (define-key map "w" 'hypropos-where-is)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (define-key map "i" 'hypropos-invoke-fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (define-key map "s" 'hypropos-set-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; more administrativa...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (define-key map "P" 'hypropos-toggle-programming-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (define-key map "k" 'hypropos-add-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (define-key map "e" 'hypropos-eliminate-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Keybindings for the *Hyper Apropos* buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 This map inherits from `hypropos-help-map.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defvar hyper-apropos-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "*User function run after hyper-apropos mode initialization. Usage:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 \(setq hyper-apropos-mode-hook '(lambda () ... your init forms ...)).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defconst hypropos-junk-regexp "^Apropos\\|^Functions\\|^Variables\\|^$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar hypropos-currently-showing nil) ; symbol documented in help buffer now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defvar hypropos-help-history nil) ; chain of symbols followed as links in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ; help buffer
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
226 (defvar hypropos-face-history nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
227 ;;;(defvar hypropos-variable-history nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
228 ;;;(defvar hypropos-function-history nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
229 (defvar hypropos-regexp-history nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defvar hypropos-last-regexp nil) ; regex used for last apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defconst hypropos-apropos-buf "*Hyper Apropos*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defconst hypropos-help-buf "*Hyper Help*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defun hyper-apropos (regexp toggle-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 "Display lists of functions and variables matching REGEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 in buffer \"*Hyper Apropos*\". If optional prefix arg is given, then the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 of `hypropos-programming-apropos' is toggled for this search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 See also `hyper-apropos-mode'."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
240 (interactive (list (read-from-minibuffer "List symbols matching regexp: "
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
241 nil nil nil 'hypropos-regexp-history)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
242 current-prefix-arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq hypropos-prev-wconfig (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (string= "" regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if (get-buffer hypropos-apropos-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (if toggle-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (hypropos-toggle-programming-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (message "Using last search results"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (error "Be more specific..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (let (flist vlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (set-buffer (get-buffer-create hypropos-apropos-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (if toggle-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (set (make-local-variable 'hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (not (default-value 'hypropos-programming-apropos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (if (not hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq flist (apropos-internal regexp 'commandp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 vlist (apropos-internal regexp 'user-variable-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; #### - add obsolete functions/variables here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; #### - 'variables' may be unbound !!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq flist (apropos-internal regexp 'fboundp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 vlist (apropos-internal regexp 'boundp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (insert-face (format "Apropos search for: %S\n\n" regexp) 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (insert-face "* = command (M-x) or user-variable.\n" 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (insert-face "a = autoloaded, b = byte-compiled, i = internal, l = lambda, m = macro.\n\n" 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (insert-face "Functions and Macros:\n\n" 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (hypropos-grok-functions flist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (insert-face "\n\nVariables and Constants:\n\n" 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (hypropos-grok-variables vlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (switch-to-buffer hypropos-apropos-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (hyper-apropos-mode regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun hypropos-toggle-programming-flag ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (eval-in-buffer hypropos-apropos-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (set (make-local-variable 'hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (not hypropos-programming-apropos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (message "Re-running apropos...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (hyper-apropos hypropos-last-regexp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defun hypropos-grok-functions (fns)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
286 (let (fn bind doc type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while (setq fn (car fns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq bind (symbol-function fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 type (cond ((subrp bind) ?i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ((compiled-function-p bind) ?b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ((consp bind) (or (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (assq (car bind) '((autoload . ?a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (lambda . ?l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (macro . ?m))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ??))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (t ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert type (if (commandp fn) "* " " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (insert-face (format "%-30S" fn) 'hyperlink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (and hypropos-show-brief-docs
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
300 (setq doc (documentation fn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
301 (insert-face (if doc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
302 (concat " - "
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
303 (substring doc 0 (string-match "\n" doc)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
304 " Not documented.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
305 'documentation))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq fns (cdr fns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defun hypropos-grok-variables (vars)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
311 (let (var doc userp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (while (setq var (car vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq userp (user-variable-p var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 vars (cdr vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (insert (if userp " * " " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (insert-face (format "%-30S" var) 'hyperlink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (and hypropos-show-brief-docs
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
318 (setq doc (documentation-property var 'variable-documentation))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
319 (insert-face (if doc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
320 (concat " - " (substring doc (if userp 1 0)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
321 (string-match "\n" doc)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
322 " - Not documented.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
323 'documentation))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defun hyper-apropos-mode (regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 "Improved apropos mode for displaying Emacs documentation. Function and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 variable names are displayed in the buffer \"*Hyper Apropos*\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Functions are preceded by a single character to indicates their types:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 a = autoloaded, b = byte-compiled, i = internal, l = lambda, m = macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 Interactive functions are also preceded by an asterisk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Variables are preceded by an asterisk if they are user variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 General Commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 SPC - scroll documentation or apropos window forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 b - scroll documentation or apropos window backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 k - eliminate all hits that don't contain keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 n - new search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 / - isearch-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 q - quit and restore previous window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 Operations for Symbol on Current Line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 RET - toggle display of symbol's documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (also on button2 in xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 w - show the keybinding if symbol is a command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 i - invoke function on current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 s - set value of variable on current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 t - display the C or lisp source (find-tag)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (setq mode-name "Hyper-Apropos"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 major-mode 'hyper-apropos-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 truncate-lines t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 hypropos-last-regexp regexp
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
361 modeline-buffer-identification
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
362 (list (cons modeline-buffer-id-left-extent "Hyper Apropos: ")
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
363 (cons modeline-buffer-id-right-extent (concat "\"" regexp "\""))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq mode-motion-hook 'mode-motion-highlight-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (use-local-map hypropos-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (run-hooks 'hyper-apropos-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
370 ;; similar to `describe-key-briefly', copied from prim/help.el by CW
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
371
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;;;###autoload
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
373 (defun hyper-describe-key (key)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
374 (interactive "kDescribe key: ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
375 (hyper-describe-key-briefly key t))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
376
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
377 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
378 (defun hyper-describe-key-briefly (key &optional show)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
379 (interactive "kDescribe key briefly: \nP")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
380 (let (menup defn interm final msg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
381 (setq defn (key-or-menu-binding key 'menup))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
382 (if (or (null defn) (integerp defn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
383 (or (numberp show) (message "%s is undefined" (key-description key)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
384 (cond ((stringp defn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
385 (setq interm defn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
386 final (key-binding defn)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
387 ((vectorp defn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
388 (setq interm (append defn nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
389 (while (and interm
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
390 (member (key-binding (vector (car interm)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
391 '(universal-argument digit-argument)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
392 (setq interm (cdr interm)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
393 (while (and interm
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
394 (not (setq final (key-binding (vconcat interm)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
395 (setq interm (butlast interm)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
396 (if final
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
397 (setq interm (vconcat interm))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
398 (setq interm defn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
399 final (key-binding defn)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
400 (setq msg (format
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
401 "%s runs %s%s%s"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
402 ;; This used to say 'This menu item' but it could also
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
403 ;; be a scrollbar event. We can't distinguish at the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
404 ;; moment.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
405 (if menup "This item" (key-description key))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
406 ;;(if (symbolp defn) defn (key-description defn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
407 (if (symbolp defn) defn (prin1-to-string defn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
408 (if final (concat ", " (key-description interm) " runs ") "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
409 (if final
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
410 (if (symbolp final) final (prin1-to-string final))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
411 "")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
412 (if (numberp show)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
413 (or (not (symbolp defn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
414 (memq (symbol-function defn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
415 '(zkey-init-kbd-macro zkey-init-kbd-fn))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
416 (progn (princ msg) (princ "\n")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
417 (message "%s" msg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
418 (if final (setq defn final))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
419 (if (and (or (symbolp defn) (symbolp (setq defn (car-safe defn))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
420 defn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
421 show)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
422 (hypropos-get-doc defn t))))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
423
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
424 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
425 (defun hyper-describe-face (symbol &optional this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
426 "Describe face..
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
427 See also `hyper-apropos' and `hyper-describe-function'."
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
428 ;; #### - perhaps a prefix arg should suppress the prompt...
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
429 (interactive
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
430 (let (v val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
431 (setq v (hypropos-this-symbol)) ; symbol under point
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
432 (or (find-face v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
433 (setq v (variable-at-point)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
434 (setq val (let ((enable-recursive-minibuffers t))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
435 (completing-read
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
436 (concat (if (hypropos-follow-ref-buffer current-prefix-arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
437 "Follow face"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
438 "Describe face")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
439 (if v
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
440 (format " (default %s): " v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
441 ": "))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
442 (mapcar (function (lambda (x) (list (symbol-name x))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
443 (face-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
444 nil t nil 'hypropos-face-history)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
445 (list (if (string= val "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
446 (progn (push (symbol-name v) hypropos-face-history) v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
447 (intern-soft val))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
448 current-prefix-arg)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (if (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (message "Sorry, nothing to describe.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq hypropos-prev-wconfig (current-window-configuration)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
453 (hypropos-get-doc symbol t nil this-ref-buffer)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
454
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
455 ;;;###autoload
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
456 (defun hyper-describe-variable (symbol &optional this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
457 "Hypertext drop-in replacement for `describe-variable'.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
458 See also `hyper-apropos' and `hyper-describe-function'."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
459 ;; #### - perhaps a prefix arg should suppress the prompt...
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
460 (interactive (list (hypropos-read-variable-symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
461 (if (hypropos-follow-ref-buffer current-prefix-arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
462 "Follow variable"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
463 "Describe variable"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
464 current-prefix-arg))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
465 (if (null symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
466 (message "Sorry, nothing to describe.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
467 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
468 (setq hypropos-prev-wconfig (current-window-configuration)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
469 (hypropos-get-doc symbol t nil this-ref-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
470
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
471 (defun hyper-where-is (symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
472 "Print message listing key sequences that invoke specified command."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
473 (interactive (list (hypropos-read-function-symbol "Where is function")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
474 (if (null symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
475 (message "Sorry, nothing to describe.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
476 (where-is symbol)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
477
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
478 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
479 (defun hyper-describe-function (symbol &optional this-ref-buffer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
480 "Hypertext replacement for `describe-function'. Unlike `describe-function'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
481 in that the symbol under the cursor is the default if it is a function.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
482 See also `hyper-apropos' and `hyper-describe-variable'."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
483 ;; #### - perhaps a prefix arg should suppress the prompt...
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
484 (interactive (list (hypropos-read-function-symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
485 (if (hypropos-follow-ref-buffer current-prefix-arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
486 "Follow function"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
487 "Describe function"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
488 current-prefix-arg))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
489 (if (null symbol)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
490 (message "Sorry, nothing to describe.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
491 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
492 (setq hypropos-prev-wconfig (current-window-configuration)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
493 (hypropos-get-doc symbol t nil this-ref-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
494
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
495 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
496 (defun hypropos-read-variable-symbol (prompt &optional predicate)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
497 "Hypertext drop-in replacement for `describe-variable'.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
498 See also `hyper-apropos' and `hyper-describe-function'."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
499 ;; #### - perhaps a prefix arg should suppress the prompt...
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
500 (or predicate (setq predicate 'boundp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
501 (let (v val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
502 (setq v (hypropos-this-symbol)) ; symbol under point
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
503 (or (funcall predicate v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
504 (setq v (variable-at-point)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
505 (or (funcall predicate v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
506 (setq v nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
507 (setq val (let ((enable-recursive-minibuffers t))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
508 (completing-read
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
509 (concat prompt
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
510 (if v
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
511 (format " (default %s): " v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
512 ": "))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
513 obarray predicate t nil 'variable-history)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
514 (if (string= val "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
515 (progn (push (symbol-name v) variable-history) v)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
516 (intern-soft val))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
517
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
518 (defun hypropos-read-function-symbol (prompt)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
519 "Read function symbol from minibuffer."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
520 (let ((fn (hypropos-this-symbol))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
521 val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
522 (or (fboundp fn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
523 (setq fn (function-called-at-point)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
524 (setq val (let ((enable-recursive-minibuffers t))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
525 (completing-read (if fn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
526 (format "%s (default %s): " prompt fn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
527 (format "%s: " prompt))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
528 obarray 'fboundp t nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
529 'function-history)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
530 (if (equal val "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
531 (progn (push (symbol-name fn) function-history) fn)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
532 (intern-soft val))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defun hypropos-last-help (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Go back to the last symbol documented in the *Hyper Help* buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (interactive "P")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
537 (let ((win (get-buffer-window hypropos-help-buf)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
538 (or arg (setq arg (if win 1 0)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
539 (cond ((= arg 0))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
540 ((<= (length hypropos-help-history) arg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; go back as far as we can...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (setcdr (nreverse hypropos-help-history) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (t
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
544 (setq hypropos-help-history (nthcdr arg hypropos-help-history))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
545 (if (or win (> arg 0))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
546 (hypropos-get-doc (car hypropos-help-history) t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
547 (display-buffer hypropos-help-buf))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
548
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
549 (defun hypropos-insert-face (string &optional face)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
550 "Insert STRING and fontify some parts with face `hyperlink'."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
551 (let ((beg (point)) end)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
552 (insert-face string (or face 'documentation))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
553 (setq end (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
554 (goto-char beg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
555 (while (re-search-forward
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
556 "`\\([-a-zA-Z0-9_][-a-zA-Z0-9_][-a-zA-Z0-9_.]+\\)'"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
557 end 'limit)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
558 (set-extent-face (make-extent (match-beginning 1) (match-end 1))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
559 'hyperlink))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
560 (goto-char beg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
561 (while (re-search-forward
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
562 "M-x \\([-a-zA-Z0-9_][-a-zA-Z0-9_][-a-zA-Z0-9_.]+\\)"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
563 end 'limit)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
564 (set-extent-face (make-extent (match-beginning 1) (match-end 1))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
565 'hyperlink))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
566
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
567 (defun hypropos-insert-keybinding (keys string)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
568 (if keys
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
569 (insert " (" string " bound to \""
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
570 (mapconcat 'key-description
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
571 (sort keys #'(lambda (x y)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
572 (< (length x) (length y))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
573 "\", \"")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
574 "\")\n")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
576 (defun hypropos-insert-section-heading (alias-desc &optional desc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
577 (or desc (setq desc alias-desc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
578 alias-desc nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
579 (if alias-desc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
580 (setq desc (concat alias-desc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
581 (if (memq (aref desc 0)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
582 '(?a ?e ?i ?o ?u))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
583 ", an " ", a ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
584 desc)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
585 (aset desc 0 (upcase (aref desc 0))) ; capitalize
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
586 (goto-char (point-max))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
587 (newline 3) (delete-blank-lines) (newline 2)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
588 (hypropos-insert-face desc 'section-heading))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
589
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
590 (defun hypropos-insert-value (string symbol val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
591 (insert-face string 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
592 (insert (if (symbol-value symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
593 (if (or (null val) (eq val t) (integerp val))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
594 (prog1
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
595 (symbol-value symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
596 (set symbol nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
597 "see below")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
598 "is void")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
599
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
600 (defun hypropos-follow-ref-buffer (this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
601 (and (not this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
602 (eq major-mode 'hyper-help-mode)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
603 hypropos-ref-buffer
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
604 (buffer-live-p hypropos-ref-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
605
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
606 (defun hypropos-get-alias (symbol alias-p next-symbol &optional use)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
607 "Return (TERMINAL-SYMBOL . ALIAS-DESC)."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
608 (let (aliases)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
609 (while (funcall alias-p symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
610 (setq aliases (cons (if use (funcall use symbol) symbol) aliases))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
611 (setq symbol (funcall next-symbol symbol)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
612 (cons symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
613 (and aliases
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
614 (concat "an alias for `"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
615 (mapconcat 'symbol-name
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
616 (nreverse aliases)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
617 "',\nwhich is an alias for `")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
618 "'")))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
619
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
620 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
621 (defun hypropos-get-doc (&optional symbol force type this-ref-buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; #### - update this docstring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "Toggle display of documentation for the symbol on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; SYMBOL is the symbol to document. FORCE, if non-nil, means to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; regenerate the documentation even if it already seems to be there. And
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; TYPE, if present, forces the generation of only variable documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; or only function documentation. Normally, if both are present, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; both will be generated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; TYPES TO IMPLEMENT: obsolete face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (or symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (setq symbol (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (or type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq type '(function variable face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if (and (eq hypropos-currently-showing symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (get-buffer hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (get-buffer-window hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (not force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; we're already displaying this help, so toggle its display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (delete-windows-on hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; OK, we've got to refresh and display it...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (or (eq symbol (car hypropos-help-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq hypropos-help-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (if (eq major-mode 'hyper-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; if we're following a link in the help buffer, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; record that in the help history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (cons symbol hypropos-help-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; otherwise clear the history because it's a new search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (list symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (save-excursion
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
653 (if (hypropos-follow-ref-buffer this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
654 (set-buffer hypropos-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
655 (setq hypropos-ref-buffer (current-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
656 (let (standard-output
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
657 ok beg
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
658 newsym symtype doc obsolete
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
659 (local mode-name)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
660 global local-str global-str
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
661 font fore back undl
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
662 aliases alias-desc desc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
663 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
664 (set-buffer (get-buffer-create hypropos-help-buf))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
665 ;;(setq standard-output (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
666 (setq buffer-read-only nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
667 (erase-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
668 (insert-face (format "`%s'" symbol) 'major-heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
669 (insert (format " (buffer: %s, mode: %s)\n"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
670 (buffer-name hypropos-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
671 local)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
672 ;; function ----------------------------------------------------------
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (and (memq 'function type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (fboundp symbol)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
675 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
676 (setq ok t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
677 (setq aliases (hypropos-get-alias (symbol-function symbol)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
678 'symbolp
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
679 'symbol-function)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
680 newsym (car aliases)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
681 alias-desc (cdr aliases))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
682 (if (eq 'macro (car-safe newsym))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
683 (setq desc "macro"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
684 newsym (cdr newsym))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
685 (setq desc "function"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
686 (setq symtype (cond ((subrp newsym) 'subr)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
687 ((compiled-function-p newsym) 'bytecode)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
688 ((eq (car-safe newsym) 'autoload) 'autoload)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
689 ((eq (car-safe newsym) 'lambda) 'lambda))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 desc (concat (if (commandp symbol) "interactive ")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
691 (cdr (assq symtype
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 '((subr . "built-in ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (bytecode . "compiled Lisp ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (autoload . "autoloaded Lisp ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (lambda . "Lisp "))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
696 desc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
697 local (current-local-map)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
698 global (current-global-map)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
699 obsolete (get symbol 'byte-obsolete-info)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 doc (or (documentation symbol) "function not documented"))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
701 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
702 (set-buffer hypropos-help-buf)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
703 (goto-char (point-max))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
704 (setq standard-output (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
705 (hypropos-insert-section-heading alias-desc desc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
706 (and (eq symtype 'autoload)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
707 (insert (format ", (autoloaded from \"%s\")"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
708 (nth 1 newsym))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
709 (insert ":\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
710 (if local
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
711 (hypropos-insert-keybinding
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
712 (where-is-internal symbol (list local) nil nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
713 "locally"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
714 (hypropos-insert-keybinding
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
715 (where-is-internal symbol (list global) nil nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
716 "globally")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
717 (insert "\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
718 (if obsolete
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
719 (hypropos-insert-face
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
720 (format "%s is an obsolete function; %s\n\n" symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
721 (if (stringp (car obsolete))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
722 (car obsolete)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
723 (format "use `%s' instead." (car obsolete))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
724 'warning))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
725 (setq beg (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
726 (insert-face "arguments: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
727 (cond ((eq symtype 'lambda)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
728 (princ (or (nth 1 newsym) "()")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
729 ((eq symtype 'bytecode)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
730 (princ (or (aref newsym 0) "()")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
731 ((and (eq symtype 'subr)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
732 (string-match
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
733 "[\n\t ]*\narguments: ?\\((.*)\\)\n?\\'"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
734 doc))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
735 (insert (substring doc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
736 (match-beginning 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
737 (match-end 1)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
738 (setq doc (substring doc 0 (match-beginning 0))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
739 ((and (eq symtype 'subr)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
740 (string-match
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
741 "[\n\t ]*([^\n\t )]+[\t ]*\\([^\n)]+\\)?)\\(:[\t ]*\\|\n?\\'\\)"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
742 doc))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
743 (insert "("
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
744 (if (match-end 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
745 (substring doc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
746 (match-beginning 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
747 (match-end 1)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
748 ")")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
749 (setq doc (substring doc (match-end 0))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
750 (t (princ "[not available]")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
751 (insert "\n\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
752 (hypropos-insert-face doc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
753 (insert "\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
754 (indent-rigidly beg (point) 2))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
755 ;; variable ----------------------------------------------------------
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (and (memq 'variable type)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
757 (or (boundp symbol) (default-boundp symbol))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (setq ok t)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
760 (setq aliases (hypropos-get-alias symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
761 'variable-alias
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
762 'variable-alias
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
763 'variable-alias)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
764 newsym (car aliases)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
765 alias-desc (cdr aliases))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
766 (setq symtype (or (local-variable-p newsym (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
767 (and (local-variable-p newsym
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
768 (current-buffer) t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
769 'auto-local))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
770 desc (concat (if (user-variable-p newsym)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
771 "user variable"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
772 "variable")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
773 (cond ((eq symtype t) ", buffer-local")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
774 ((eq symtype 'auto-local)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
775 ", local when set")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
776 local (and (boundp newsym)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
777 (symbol-value newsym))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
778 local-str (and (boundp newsym)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
779 (prin1-to-string local))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
780 global (and (eq symtype t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
781 (default-boundp newsym)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
782 (default-value newsym))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
783 global-str (and (eq symtype t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
784 (default-boundp newsym)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
785 (prin1-to-string global))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
786 obsolete (get symbol 'byte-obsolete-variable)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
787 doc (or (documentation-property symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
788 'variable-documentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 "variable not documented"))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
790 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
791 (set-buffer hypropos-help-buf)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
792 (goto-char (point-max))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
793 (setq standard-output (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
794 (hypropos-insert-section-heading alias-desc desc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
795 (insert ":\n\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
796 (setq beg (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
797 (if obsolete
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
798 (hypropos-insert-face
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
799 (format "%s is an obsolete function; %s\n\n" symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
800 (if (stringp obsolete)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
801 obsolete
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
802 (format "use `%s' instead." obsolete)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
803 'warning))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
804 ;; generally, the value of the variable is short and the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
805 ;; documentation of the variable long, so it's desirable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
806 ;; to see all of the value and the start of the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
807 ;; documentation. Some variables, though, have huge and
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
808 ;; nearly meaningless values that force you to page
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
809 ;; forward just to find the doc string. That is
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
810 ;; undesirable.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
811 (if (and (or (null local-str) (< (length local-str) 69))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
812 (or (null global-str) (< (length global-str) 69)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
813 ; 80 cols. docstrings assume this.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
814 (progn (insert-face "value: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
815 (insert (or local-str "is void"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
816 (if (eq symtype t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
817 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
818 (insert "\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
819 (insert-face "default value: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
820 (insert (or global-str "is void"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
821 (insert "\n\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
822 (hypropos-insert-face doc))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
823 (hypropos-insert-value "value: " 'local-str local)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
824 (if (eq symtype t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
825 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
826 (insert ", ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
827 (hypropos-insert-value "default-value: "
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
828 'global-str global)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
829 (insert "\n\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
830 (hypropos-insert-face doc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
831 (if local-str
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
832 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
833 (newline 3) (delete-blank-lines) (newline 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
834 (insert-face "value: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
835 (if hypropos-prettyprint-long-values
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
836 (condition-case nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
837 (let ((pp-print-readably nil)) (pprint local))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
838 (error (insert local-str)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
839 (insert local-str))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
840 (if global-str
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
841 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
842 (newline 3) (delete-blank-lines) (newline 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
843 (insert-face "default value: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
844 (if hypropos-prettyprint-long-values
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
845 (condition-case nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
846 (let ((pp-print-readably nil)) (pprint global))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
847 (error (insert global-str)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
848 (insert global-str)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
849 (indent-rigidly beg (point) 2))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
850 ;; face --------------------------------------------------------------
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (and (memq 'face type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (find-face symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (setq ok t)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
855 (copy-face symbol 'hypropos-temp-face 'global)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
856 (mapcar (function
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
857 (lambda (property)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
858 (setq symtype (face-property-instance symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
859 property))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
860 (if symtype
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
861 (set-face-property 'hypropos-temp-face
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
862 property
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
863 symtype))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
864 built-in-face-specifiers)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
865 (setq font (cons (face-property-instance symbol 'font nil 0 t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
866 (face-property-instance symbol 'font))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
867 fore (cons (face-foreground-instance symbol nil 0 t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
868 (face-foreground-instance symbol))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
869 back (cons (face-background-instance symbol nil 0 t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
870 (face-background-instance symbol))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
871 undl (cons (face-underline-p symbol nil 0 t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
872 (face-underline-p symbol))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
873 doc (face-doc-string symbol))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; #### - add some code here
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
875 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
876 (set-buffer hypropos-help-buf)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
877 (setq standard-output (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
878 (hypropos-insert-section-heading "Face:\n\n ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
879 (insert-face "ABCDEFHIJKLMNOPQRSTUVWXYZ abcdefhijklmnopqrstuvwxyz 0123456789"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
880 'hypropos-temp-face)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
881 (newline 2)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
882 (insert-face " Font: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
883 (insert (format (if (numberp (car font)) "(%s)\n" "%s\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
884 (and (cdr font)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
885 (font-instance-name (cdr font)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
886 (insert-face " Foreground: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
887 (insert (format (if (numberp (car fore)) "(%s)\n" "%s\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
888 (and (cdr fore)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
889 (color-instance-name (cdr fore)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
890 (insert-face " Background: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
891 (insert (format (if (numberp (car back)) "(%s)\n" "%s\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
892 (and (cdr back)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
893 (color-instance-name (cdr back)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
894 (insert-face " Underline: " 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
895 (insert (format (if (numberp (car undl)) "(%s)\n" "%s\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
896 (cdr undl)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
897 (if doc
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
898 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
899 (newline)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
900 (setq beg (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
901 (insert doc)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
902 (indent-rigidly beg (point) 2))))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
903 ;; not bound & property list -----------------------------------------
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
904 (or ok
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
905 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
906 (set-buffer hypropos-help-buf)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
907 (hypropos-insert-section-heading
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
908 "symbol is not currently bound\n")))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
909 (if (and (setq symtype (symbol-plist symbol))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
910 (or (> (length symtype) 2)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
911 (not (memq 'variable-documentation symtype))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
912 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
913 (set-buffer hypropos-help-buf)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
914 (goto-char (point-max))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
915 (setq standard-output (current-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
916 (hypropos-insert-section-heading "property-list:\n\n")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
917 (while symtype
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
918 (if (memq (car symtype)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
919 '(variable-documentation byte-obsolete-info))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
920 (setq symtype (cdr symtype))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
921 (insert-face (concat " " (symbol-name (car symtype))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
922 ": ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
923 'heading)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
924 (setq symtype (cdr symtype))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
925 (indent-to 32)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
926 (insert (prin1-to-string (car symtype)) "\n"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
927 (setq symtype (cdr symtype)))))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
928 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
929 (set-buffer hypropos-help-buf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; pop up window and shrink it if it's wasting space
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
932 (if hypropos-shrink-window
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
933 (shrink-window-if-larger-than-buffer
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
934 (display-buffer (current-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
935 (display-buffer (current-buffer)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
936 (hyper-help-mode))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
937 (setq hypropos-currently-showing symbol)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ; -----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (defun hyper-help-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 "Major mode for hypertext XEmacs help. In this mode, you can quickly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 follow links between back and forth between the documentation strings for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 different variables and functions. Common commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 \\{hypropos-help-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (setq mode-motion-hook 'hypropos-highlight-lisp-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 major-mode 'hyper-help-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 mode-name "Hyper-Help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (set-syntax-table emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (use-local-map hypropos-help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (defun hypropos-highlight-lisp-symbol (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; mostly copied from mode-motion-highlight-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (let* ((window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (buffer (and window (window-buffer window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (point (and buffer (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 st en sym highlight-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (if point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (setq st (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (skip-syntax-backward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (skip-chars-forward "`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 en (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (goto-char st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (skip-syntax-forward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (skip-chars-backward ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 sym (and (not (eq st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (intern-soft (buffer-substring st en)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 highlight-p (and sym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (or (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (fboundp sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (if highlight-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (if mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (set-extent-endpoints mode-motion-extent st en)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (setq mode-motion-extent (make-extent st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (set-extent-property mode-motion-extent 'highlight t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (progn (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (setq mode-motion-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; not over text; zero the extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (if (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (not (eq (extent-start-position mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (extent-end-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (set-extent-endpoints mode-motion-extent 1 1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (defun hypropos-scroll-up ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 "Scroll up the \"*Hyper Help*\" buffer if it's visible, or scroll this window up."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (let ((win (get-buffer-window hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (owin (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (if win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (scroll-up nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (error (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (select-window owin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (scroll-up nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (defun hypropos-scroll-down ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 "Scroll down the \"*Hyper Help*\" buffer if it's visible, or scroll this window down."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (let ((win (get-buffer-window hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (owin (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (if win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (scroll-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (error (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (select-window owin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (scroll-down nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (defun hypropos-mouse-get-doc (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 "Get the documentation for the symbol the mouse is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (let ((symbol (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (if symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (hypropos-get-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (error "Click on a symbol")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (defun hypropos-add-keyword (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 "Use additional keyword to narrow regexp match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 Deletes lines which don't match PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (interactive "sAdditional Keyword: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (keep-lines (concat pattern "\\|" hypropos-junk-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defun hypropos-eliminate-keyword (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 "Use additional keyword to eliminate uninteresting matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 Deletes lines which match PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (interactive "sKeyword to eliminate: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (flush-lines pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (defun hypropos-this-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (cond ((eq major-mode 'hyper-apropos-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if (looking-at hypropos-junk-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (forward-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (read (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (let* ((st (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (skip-syntax-backward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ;; !@(*$^%%# stupid backquote implementation!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (skip-chars-forward "`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (en (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (skip-syntax-forward "w_")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1078 (skip-chars-backward ".':") ; : for Local Variables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (and (not (eq st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (intern-soft (buffer-substring st en))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (defun hypropos-where-is (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 "Find keybinding for symbol on current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (where-is symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (defun hypropos-invoke-fn (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 "Interactively invoke the function on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (cond ((not (fboundp fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (error "%S is not a function" fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (t (call-interactively fn))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 ;;;###autoload
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1096 (defun hyper-set-variable (var val &optional this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1097 (interactive
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1098 (let ((var (hypropos-read-variable-symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1099 (if (hypropos-follow-ref-buffer current-prefix-arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1100 "In ref buffer, set user option"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1101 "Set user option")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1102 'user-variable-p)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1103 (list var (hypropos-read-variable-value var) current-prefix-arg)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1104 (hypropos-set-variable var val this-ref-buffer))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1105
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1106 ;;;###autoload
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1107 (defun hypropos-set-variable (var val &optional this-ref-buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 "Interactively set the variable on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (interactive
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1110 (let ((var (hypropos-this-symbol)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1111 (or (and var (boundp var))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1112 (and (setq var (and (eq major-mode 'hyper-help-mode)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1113 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1114 (goto-char (point-min))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1115 (hypropos-this-symbol))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1116 (boundp var))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1117 (setq var nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1118 (list var (hypropos-read-variable-value var))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1119 (and var
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1120 (boundp var)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1121 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1122 (if (hypropos-follow-ref-buffer this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1123 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1124 (set-buffer hypropos-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1125 (set var val))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1126 (set var val))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1127 (hypropos-get-doc var t '(variable) this-ref-buffer))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1128
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1129 (defun hypropos-read-variable-value (var &optional this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1130 (and var
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1131 (boundp var)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1132 (let ((prop (get var 'variable-interactive))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1133 (print-readably t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1134 val str)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1135 (hypropos-get-doc var t '(variable) current-prefix-arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1136 (if prop
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1137 (call-interactively (list 'lambda '(arg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1138 (list 'interactive prop)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1139 'arg))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1140 (setq val (if (hypropos-follow-ref-buffer this-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1141 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1142 (set-buffer hypropos-ref-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1143 (symbol-value var))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1144 (symbol-value var))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1145 str (prin1-to-string val))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1146 (eval-minibuffer
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1147 (format "Set %s `%s' to value (evaluated): "
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1148 (if (user-variable-p var) "user option" "Variable")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1149 var)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1150 (condition-case nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1151 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1152 (read str)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1153 (format (if (or (consp val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1154 (and (symbolp val)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1155 (not (memq val '(t nil)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1156 "'%s" "%s")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1157 str))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
1158 (error nil)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (defun hypropos-find-tag (&optional tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 "Find the tag for the symbol on the current line in other window. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 order for this to work properly, the variable `tag-table-alist' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 `tags-file-name' must be set so that a TAGS file with tags for the emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 source is found for the \"*Hyper Apropos*\" buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; there ought to be a default tags file for this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (or tag-name (setq tag-name (symbol-name (hypropos-this-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (find-tag-other-window (list tag-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (defun hypropos-disassemble (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 "Disassemble FUN if it is byte-coded. If it's a lambda, prettyprint it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (let ((fun sym) (trail nil) macrop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (while (and (symbolp fun) (not (memq fun trail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (setq trail (cons fun trail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 fun (symbol-function fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (and (symbolp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (error "Loop detected in function binding of `%s'" fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (setq macrop (and (consp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (eq 'macro (car fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (cond ((compiled-function-p (if macrop (cdr fun) fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (disassemble fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (set-buffer "*Disassemble*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (forward-sexp 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (insert (format " for function `%S'" sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ((consp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (with-output-to-temp-buffer "*Disassemble*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (pprint (if macrop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (cons 'defmacro (cons sym (cdr (cdr fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (cons 'defun (cons sym (cdr fun))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (set-buffer "*Disassemble*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (emacs-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ((or (vectorp fun) (stringp fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; #### - do something fancy here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (with-output-to-temp-buffer "*Disassemble*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (princ (format "%s is a keyboard macro:\n\n\t" sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (prin1 fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (error "Sorry, cannot disassemble `%s'" sym)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defun hypropos-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 "Quit Hyper Apropos and restore original window config."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (let ((buf (get-buffer hypropos-apropos-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (and buf (bury-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (set-window-configuration hypropos-prev-wconfig))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (defun hypropos-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (let* ((sym (hypropos-this-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (notjunk (not (null sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (command-p (commandp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (variable-p (and sym (boundp sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (function-p (fboundp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (apropos-p (eq 'hyper-apropos-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (save-excursion (set-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 major-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (name (if sym (symbol-name sym) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (hypropos-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (list (concat "Hyper-Help: " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (vector "Display documentation" 'hypropos-get-doc notjunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (vector "Set variable" 'hypropos-set-variable variable-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (vector "Show keys for" 'hypropos-where-is command-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (vector "Invoke command" 'hypropos-invoke-fn command-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (vector "Find tag" 'hypropos-find-tag notjunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (and apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ["Add keyword..." hypropos-add-keyword t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (and apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ["Eliminate keyword..." hypropos-eliminate-keyword t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (if apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ["Programmers' Apropos" hypropos-toggle-programming-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 :style toggle :selected hypropos-programming-apropos]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ["Programmers' Help" hypropos-toggle-programming-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 :style toggle :selected hypropos-programming-apropos])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (and hypropos-programming-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (vector "Disassemble function"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 'hypropos-disassemble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 function-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ["Help" describe-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ["Quit" hypropos-quit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (popup-menu hypropos-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (provide 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;; end of hyper-apropos.el