annotate lisp/packages/hyper-apropos.el @ 116:9f59509498e1 r20-1b10

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