annotate lisp/packages/hyper-apropos.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
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.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (or (fboundp 'pprint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (progn (autoload 'pp "pp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (fset 'pprint 'pp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;(require 'tags "etags")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvar hypropos-show-brief-docs t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "*If non-nil, `hyper-apropos' will display some documentation in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 \"*Hyper Apropos*\" buffer. Setting this to nil will speed up searches.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defvar hypropos-prettyprint-long-values t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "*If non-nil, then try to beautify the printing of very long values.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; 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
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvar hypropos-programming-apropos t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "*If non-nil, then `hyper-apropos' takes a bit longer and generates more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 output. If nil, then only functions that are interactive and variables that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 are user variables are found by `hyper-apropos'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defvar hypropos-prev-wconfig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; #### - move this to subr.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (or (fboundp 'event-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun event-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "Returns the buffer associated with event, or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((win (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (and win (window-buffer win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defmacro eval-in-buffer (buffer &rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "Evaluate FORMS in BUFFER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (` (let ((_unwind_buf_ (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (progn (set-buffer (, buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (,@ forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (set-buffer _unwind_buf_)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (put 'eval-in-buffer 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; #### - move to faces.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defmacro init-face (face &rest init-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "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
101 the default face, execute INIT-FORMS to initialize the face. While the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 init-forms are executing, the symbol `this' is bound to the face-object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 being initialized."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (` (let ((this (make-face (, face)))) ; harmless if the face is already there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (or (face-differs-from-default-p this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (, (cons 'progn init-forms))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (put 'init-face 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (init-face 'hyperlink
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;(set-face-underline-p this nil) -- dog slow and ugly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (set-face-foreground this "blue")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (init-face 'documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (let* ((ff-instance (face-font-instance 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (ff (and ff-instance (font-instance-name ff-instance))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (cond ((and ff (string-match "courier" ff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; too wide unless you shrink it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; (copy-face 'italic this) fugly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; (make-face-smaller this) fugly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (set-face-foreground this "firebrick")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (error (copy-face 'italic this)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; mucking with the sizes of fonts (perhaps with the exception of courier or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; misc) is a generally losing thing to do. Changing the size of 'clean'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; really loses, for instance...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (init-face 'major-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (make-face-larger this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (make-face-larger this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (init-face 'section-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (copy-face 'bold this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (make-face-larger this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (init-face 'heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (copy-face 'bold this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (init-face 'standout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (copy-face 'italic this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (init-face 'warning
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 (and (eq (device-type) 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (eq (device-class) 'color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (set-face-foreground this "red")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defvar hypropos-help-map (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (suppress-keymap map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (set-keymap-name map 'hypropos-help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (define-key map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (define-key map "b" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (define-key map "/" 'isearch-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (define-key map "?" 'isearch-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; follow links
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (define-key map "\r" 'hypropos-get-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (define-key map "s" 'hypropos-set-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (define-key map "t" 'hypropos-find-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (define-key map "l" 'hypropos-last-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (define-key map [button2] 'hypropos-mouse-get-doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (define-key map [button3] 'hypropos-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; for the totally hardcore...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (define-key map "D" 'hypropos-disassemble)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; administrativa
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (define-key map "a" 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (define-key map "n" 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (define-key map "q" 'hypropos-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "Keybindings for both the *Hyper Help* buffer and the *Hyper Apropos* buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defvar hypropos-map (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (set-keymap-name map 'hypropos-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (set-keymap-parents map (list hypropos-help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; slightly differrent scrolling...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (define-key map " " 'hypropos-scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (define-key map "b" 'hypropos-scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; act on the current line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (define-key map "w" 'hypropos-where-is)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (define-key map "i" 'hypropos-invoke-fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (define-key map "s" 'hypropos-set-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; more administrativa...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (define-key map "P" 'hypropos-toggle-programming-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (define-key map "k" 'hypropos-add-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (define-key map "e" 'hypropos-eliminate-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Keybindings for the *Hyper Apropos* buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 This map inherits from `hypropos-help-map.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defvar hyper-apropos-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "*User function run after hyper-apropos mode initialization. Usage:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 \(setq hyper-apropos-mode-hook '(lambda () ... your init forms ...)).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (defconst hypropos-junk-regexp "^Apropos\\|^Functions\\|^Variables\\|^$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defvar hypropos-currently-showing nil) ; symbol documented in help buffer now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defvar hypropos-help-history nil) ; chain of symbols followed as links in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ; help buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defvar hypropos-last-regexp nil) ; regex used for last apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defconst hypropos-apropos-buf "*Hyper Apropos*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defconst hypropos-help-buf "*Hyper Help*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun hyper-apropos (regexp toggle-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Display lists of functions and variables matching REGEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 in buffer \"*Hyper Apropos*\". If optional prefix arg is given, then the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 of `hypropos-programming-apropos' is toggled for this search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 See also `hyper-apropos-mode'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (interactive "sList symbols matching regexp: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (setq hypropos-prev-wconfig (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (if (string= "" regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (get-buffer hypropos-apropos-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if toggle-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (hypropos-toggle-programming-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (message "Using last search results"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (error "Be more specific..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let (flist vlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (set-buffer (get-buffer-create hypropos-apropos-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if toggle-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (set (make-local-variable 'hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (not (default-value 'hypropos-programming-apropos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (not hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq flist (apropos-internal regexp 'commandp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 vlist (apropos-internal regexp 'user-variable-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; #### - add obsolete functions/variables here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; #### - 'variables' may be unbound !!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq flist (apropos-internal regexp 'fboundp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 vlist (apropos-internal regexp 'boundp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (insert-face (format "Apropos search for: %S\n\n" regexp) 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (insert-face "* = command (M-x) or user-variable.\n" 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (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
240 (insert-face "Functions and Macros:\n\n" 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (hypropos-grok-functions flist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (insert-face "\n\nVariables and Constants:\n\n" 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (hypropos-grok-variables vlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (switch-to-buffer hypropos-apropos-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (hyper-apropos-mode regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun hypropos-toggle-programming-flag ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (eval-in-buffer hypropos-apropos-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (set (make-local-variable 'hypropos-programming-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (not hypropos-programming-apropos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (message "Re-running apropos...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (hyper-apropos hypropos-last-regexp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun hypropos-grok-functions (fns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let (fn bind type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (while (setq fn (car fns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (setq bind (symbol-function fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 type (cond ((subrp bind) ?i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ((compiled-function-p bind) ?b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ((consp bind) (or (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (assq (car bind) '((autoload . ?a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (lambda . ?l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (macro . ?m))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ??))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (t ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (insert type (if (commandp fn) "* " " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (insert-face (format "%-30S" fn) 'hyperlink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (and hypropos-show-brief-docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (function-obsolete-p fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (insert-face " - Obsolete." 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (let ((doc (documentation fn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (not doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (insert-face " - Not documented." 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (insert-face (concat " - "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (substring doc 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (string-match "\n" doc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 'documentation)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq fns (cdr fns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defun hypropos-grok-variables (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (let (var userp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while (setq var (car vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq userp (user-variable-p var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 vars (cdr vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (insert (if userp " * " " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (insert-face (format "%-30S" var) 'hyperlink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (and hypropos-show-brief-docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (variable-obsolete-p var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (insert-face " - Obsolete." 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (let ((doc (documentation-property var 'variable-documentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if (not doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert-face " - Not documented." 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (insert-face (concat " - "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (substring doc (if userp 1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (string-match "\n" doc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 'documentation)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defun hyper-apropos-mode (regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Improved apropos mode for displaying Emacs documentation. Function and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 variable names are displayed in the buffer \"*Hyper Apropos*\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 Functions are preceded by a single character to indicates their types:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 a = autoloaded, b = byte-compiled, i = internal, l = lambda, m = macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 Interactive functions are also preceded by an asterisk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Variables are preceded by an asterisk if they are user variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 General Commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 SPC - scroll documentation or apropos window forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 b - scroll documentation or apropos window backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 k - eliminate all hits that don't contain keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 n - new search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 / - isearch-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 q - quit and restore previous window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 Operations for Symbol on Current Line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 RET - toggle display of symbol's documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (also on button2 in xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 w - show the keybinding if symbol is a command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 i - invoke function on current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 s - set value of variable on current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 t - display the C or lisp source (find-tag)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq mode-name "Hyper-Apropos"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 major-mode 'hyper-apropos-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 truncate-lines t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 hypropos-last-regexp regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 modeline-buffer-identification (concat "Hyper Apropos: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "\"" regexp "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (setq mode-motion-hook 'mode-motion-highlight-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (use-local-map hypropos-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (run-hooks 'hyper-apropos-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defun hyper-describe-variable (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "Hypertext drop-in replacement for `describe-variable'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 See also `hyper-apropos' and `hyper-describe-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; #### - perhaps a prefix arg should suppress the prompt...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (let* ((v (variable-at-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (val (let ((enable-recursive-minibuffers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (format "Describe variable (default %s): " v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "Describe variable: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 obarray 'boundp t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (list (if (string= val "") v (intern-soft val)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (message "Sorry, nothing to describe.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq hypropos-prev-wconfig (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (hypropos-get-doc symbol t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun hyper-describe-function (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "Hypertext replacement for `describe-function'. Unlike `describe-function'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 in that the symbol under the cursor is the default if it is a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 See also `hyper-apropos' and `hyper-describe-variable'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; #### - perhaps a prefix arg should suppress the prompt...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (let (fn val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq fn (hypropos-this-symbol)) ; symbol under point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (or (fboundp fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (setq fn (function-called-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq val (let ((enable-recursive-minibuffers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (if fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (format "Describe function (default %s): " fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "Describe function: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 obarray 'fboundp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (list (if (equal val "") fn (intern-soft val)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (null symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (message "Sorry, nothing to describe.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (or (memq major-mode '(hyper-apropos-mode hyper-help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setq hypropos-prev-wconfig (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (hypropos-get-doc symbol t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defun hypropos-last-help (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "Go back to the last symbol documented in the *Hyper Help* buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (let ((win (get-buffer-window hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (n (prefix-numeric-value arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (cond ((and (not win) (not arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; don't alter the help-history, just redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ((<= (length hypropos-help-history) n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; go back as far as we can...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setcdr (nreverse hypropos-help-history) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq hypropos-help-history (nthcdr n hypropos-help-history))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (hypropos-get-doc (car hypropos-help-history) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defun hypropos-get-doc (&optional symbol force type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; #### - update this docstring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "Toggle display of documentation for the symbol on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; SYMBOL is the symbol to document. FORCE, if non-nil, means to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; regenerate the documentation even if it already seems to be there. And
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; TYPE, if present, forces the generation of only variable documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; or only function documentation. Normally, if both are present, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; both will be generated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; TYPES TO IMPLEMENT: obsolete face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (or symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq symbol (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (or type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (setq type '(function variable face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if (and (eq hypropos-currently-showing symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (get-buffer hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (get-buffer-window hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (not force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; we're already displaying this help, so toggle its display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (delete-windows-on hypropos-help-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; OK, we've got to refresh and display it...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (or (eq symbol (car hypropos-help-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq hypropos-help-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (if (eq major-mode 'hyper-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; if we're following a link in the help buffer, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; record that in the help history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (cons symbol hypropos-help-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; otherwise clear the history because it's a new search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (list symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (set-buffer (get-buffer-create hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (let ((standard-output (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ok beg desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ftype macrop fndef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 keys val doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 obsolete aliases alias-desc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (insert-face (format "`%s'\n\n" symbol) 'major-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (and (memq 'function type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (fboundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (setq ok t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 fndef (symbol-function symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (while (symbolp fndef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (setq aliases (cons fndef aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq fndef (symbol-function fndef)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (if (eq 'macro (car-safe fndef))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq macrop t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 fndef (cdr fndef)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (setq aliases (nreverse aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; #### - the gods of internationalization shall strike me down!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (while aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if alias-desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq alias-desc (concat alias-desc ",\nwhich is ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq alias-desc (concat alias-desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (format "an alias for `%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (car aliases))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq aliases (cdr aliases)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (setq ftype (cond ((subrp fndef) 'subr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ((compiled-function-p fndef) 'bytecode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ((eq (car-safe fndef) 'autoload) 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ((eq (car-safe fndef) 'lambda) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 desc (concat (if (commandp symbol) "interactive ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (cdr (assq ftype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 '((subr . "built-in ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (bytecode . "compiled Lisp ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (autoload . "autoloaded Lisp ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (lambda . "Lisp "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if macrop "macro" "function")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (if alias-desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq desc (concat alias-desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (if (memq (aref desc 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 '(?a ?e ?i ?o ?u))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ", an " ", a ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 desc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (aset desc 0 (upcase (aref desc 0))) ; capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (insert-face desc 'section-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (and (eq ftype 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (insert (format ", (autoloaded from \"%s\")"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (nth 1 fndef))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; #### - should also show local binding in some other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; buffer so that this function can be used in place of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; describe-function and describe-variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (if (setq keys (where-is-internal symbol (current-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 nil nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (insert (format ", (globally bound to %s)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (format "\"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (key-description x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (sort keys #'(lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (< (length x) (length y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ", "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (insert ":\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setq beg (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 doc (or (documentation symbol) "function not documented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (insert-face "arguments: " 'heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (cond ((eq ftype 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (princ (or (nth 1 fndef) "()")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ((eq ftype 'bytecode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (princ (or (if (fboundp 'compiled-function-arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (compiled-function-arglist fndef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (aref fndef 0)) "()")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ((and (eq ftype 'subr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "[\n\t ]*\narguments: ?\\((.*)\\)\n?\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (insert (substring doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (setq doc (substring doc 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (t (princ "[not available]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (let ((new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; cookbook from bytecomp.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (get symbol 'byte-obsolete-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (and new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (insert-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (format "%s is an obsolete function; %s\n\n" symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (if (stringp (car new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (car new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (format "use %s instead." (car new))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 'warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (insert-face doc 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (indent-rigidly beg (point) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (insert"\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (and (memq 'variable type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (boundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq ok t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (insert-face (if (user-variable-p symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 "User variable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "Variable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 'section-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (and (local-variable-p symbol nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (insert ", local when set"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (insert ":\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq beg (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 val (prin1-to-string (symbol-value symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 doc (or (documentation-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 symbol 'variable-documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 "variable not documented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (let ((ob (get symbol 'byte-obsolete-variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq obsolete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (and ob (format "%s is an obsolete variable; %s\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (if (stringp ob)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (format "use %s instead." ob))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;; generally, the value of the variable is short and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; documentation of the variable long, so it's desirable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;; to see all of the value and the start of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; documentation. Some variables, though, have huge and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; nearly meaningless values that force you to page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;; forward just to find the doc string. That is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; undesirable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if (< (length val) 69) ; 80 cols. docstrings assume this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (progn (insert-face "value: " 'heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (insert (format "%s\n\n" val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (and obsolete (insert-face obsolete 'warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (insert-face doc 'documentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (insert "(see below for value)\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (and obsolete (insert-face obsolete 'warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (insert-face doc 'documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (insert-face "value: " 'heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (if hypropos-prettyprint-long-values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (let ((pp-print-readably nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (pprint (symbol-value symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (insert val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (indent-rigidly beg (point) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (and (memq 'face type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (find-face symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (setq ok t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; #### - add some code here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (insert "Face documentation is \"To be implemented.\"\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (or ok (insert-face "symbol is not currently bound" 'heading)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; pop up window and shrink it if it's wasting space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (shrink-window-if-larger-than-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (display-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (hyper-help-mode)) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (setq hypropos-currently-showing symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ; -----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defun hyper-help-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 "Major mode for hypertext XEmacs help. In this mode, you can quickly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 follow links between back and forth between the documentation strings for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 different variables and functions. Common commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 \\{hypropos-help-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq mode-motion-hook 'hypropos-highlight-lisp-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 buffer-read-only t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 major-mode 'hyper-help-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 mode-name "Hyper-Help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (set-syntax-table emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (use-local-map hypropos-help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (defun hypropos-highlight-lisp-symbol (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; mostly copied from mode-motion-highlight-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (let* ((window (event-window event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (buffer (and window (window-buffer window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (point (and buffer (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 st en sym highlight-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (if point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq st (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (skip-syntax-backward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (skip-chars-forward "`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 en (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (goto-char st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (skip-syntax-forward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (skip-chars-backward ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 sym (and (not (eq st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (intern-soft (buffer-substring st en)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 highlight-p (and sym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (or (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (fboundp sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (if highlight-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (if mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (set-extent-endpoints mode-motion-extent st en)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (setq mode-motion-extent (make-extent st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (set-extent-property mode-motion-extent 'highlight t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (progn (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setq mode-motion-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; not over text; zero the extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (not (eq (extent-start-position mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (extent-end-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (set-extent-endpoints mode-motion-extent 1 1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defun hypropos-scroll-up ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "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
661 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (let ((win (get-buffer-window hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (owin (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (scroll-up nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (error (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (select-window owin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (scroll-up nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (defun hypropos-scroll-down ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 "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
675 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (let ((win (get-buffer-window hypropos-help-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (owin (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (if win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (scroll-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (error (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (select-window owin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (scroll-down nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (defun hypropos-mouse-get-doc (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 "Get the documentation for the symbol the mouse is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (let ((symbol (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (if symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (hypropos-get-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (error "Click on a symbol")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (defun hypropos-add-keyword (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 "Use additional keyword to narrow regexp match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 Deletes lines which don't match PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (interactive "sAdditional Keyword: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (keep-lines (concat pattern "\\|" hypropos-junk-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (defun hypropos-eliminate-keyword (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 "Use additional keyword to eliminate uninteresting matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Deletes lines which match PATTERN."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (interactive "sKeyword to eliminate: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (flush-lines pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (defun hypropos-this-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (cond ((eq major-mode 'hyper-apropos-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (if (looking-at hypropos-junk-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (forward-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (read (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (let* ((st (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (skip-syntax-backward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; !@(*$^%%# stupid backquote implementation!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (skip-chars-forward "`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (en (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (skip-syntax-forward "w_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (skip-chars-backward ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (and (not (eq st en))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (intern-soft (buffer-substring st en))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (defun hypropos-where-is (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 "Find keybinding for symbol on current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (where-is symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun hypropos-invoke-fn (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 "Interactively invoke the function on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (cond ((not (fboundp fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (error "%S is not a function" fn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (t (call-interactively fn))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (defun hypropos-set-variable (var val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 "Interactively set the variable on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (let ((var (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (and (eq major-mode 'hypropos-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (hypropos-this-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (or (boundp var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (setq var (completing-read "Set variable: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 obarray 'boundp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (hypropos-get-doc var t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (list var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (let ((prop (get var 'variable-interactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (print-readably t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (val (symbol-value var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (if prop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (call-interactively (list 'lambda '(arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (list 'interactive prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 'arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (eval-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (format "Set `%s' to value (evaluated): " var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (format (if (or (consp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (and (symbolp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (not (memq val '(t nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 "'%s" "%s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (prin1-to-string val))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (set var val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (hypropos-get-doc var t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (defun hypropos-find-tag (&optional tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 "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
791 order for this to work properly, the variable `tag-table-alist' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 `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
793 source is found for the \"*Hyper Apropos*\" buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; there ought to be a default tags file for this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (or tag-name (setq tag-name (symbol-name (hypropos-this-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (find-tag-other-window (list tag-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun hypropos-disassemble (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "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
803 (interactive (list (hypropos-this-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (let ((fun sym) (trail nil) macrop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (while (and (symbolp fun) (not (memq fun trail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (setq trail (cons fun trail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 fun (symbol-function fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (and (symbolp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (error "Loop detected in function binding of `%s'" fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (setq macrop (and (consp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (eq 'macro (car fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (cond ((compiled-function-p (if macrop (cdr fun) fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (disassemble fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (set-buffer "*Disassemble*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (forward-sexp 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (insert (format " for function `%S'" sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ((consp fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (with-output-to-temp-buffer "*Disassemble*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (pprint (if macrop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (cons 'defmacro (cons sym (cdr (cdr fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (cons 'defun (cons sym (cdr fun))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (set-buffer "*Disassemble*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (emacs-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ((or (vectorp fun) (stringp fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; #### - do something fancy here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (with-output-to-temp-buffer "*Disassemble*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (princ (format "%s is a keyboard macro:\n\n\t" sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (prin1 fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (error "Sorry, cannot disassemble `%s'" sym)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (defun hypropos-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 "Quit Hyper Apropos and restore original window config."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (let ((buf (get-buffer hypropos-apropos-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (and buf (bury-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (set-window-configuration hypropos-prev-wconfig))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ;; ---------------------------------------------------------------------- ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (defun hypropos-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (let* ((sym (hypropos-this-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (notjunk (not (null sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (command-p (commandp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (variable-p (and sym (boundp sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (function-p (fboundp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (apropos-p (eq 'hyper-apropos-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (save-excursion (set-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 major-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (name (if sym (symbol-name sym) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (hypropos-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (list (concat "Hyper-Help: " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (vector "Display documentation" 'hypropos-get-doc notjunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (vector "Set variable" 'hypropos-set-variable variable-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (vector "Show keys for" 'hypropos-where-is command-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (vector "Invoke command" 'hypropos-invoke-fn command-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (vector "Find tag" 'hypropos-find-tag notjunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (and apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ["Add keyword..." hypropos-add-keyword t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (and apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ["Eliminate keyword..." hypropos-eliminate-keyword t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (if apropos-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ["Programmers' Apropos" hypropos-toggle-programming-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 :style toggle :selected hypropos-programming-apropos]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ["Programmers' Help" hypropos-toggle-programming-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 :style toggle :selected hypropos-programming-apropos])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (and hypropos-programming-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (vector "Disassemble function"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 'hypropos-disassemble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 function-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ["Help" describe-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ["Quit" hypropos-quit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (popup-menu hypropos-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (provide 'hyper-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ;; end of hyper-apropos.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888