annotate lisp/packages/hyper-apropos.el @ 30:ec9a17fef872 r19-15b98

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