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