Mercurial > emacs
comparison lisp/ehelp.el @ 99750:f5057049058b
* ehelp.el (electric-help-map, ehelp-map): Define within defvar.
(with-electric-help): Fix typo and reflow docstring.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Thu, 20 Nov 2008 16:57:30 +0000 |
parents | ee5932bf781d |
children | a9dc0e7c3f2b |
comparison
equal
deleted
inserted
replaced
99749:b491431b74c8 | 99750:f5057049058b |
---|---|
36 ;; (define-key global-map [f1] 'ehelp-command) | 36 ;; (define-key global-map [f1] 'ehelp-command) |
37 | 37 |
38 ;;; Code: | 38 ;;; Code: |
39 | 39 |
40 (require 'electric) | 40 (require 'electric) |
41 (defvar electric-help-map () | |
42 "Keymap defining commands available in `electric-help-mode'.") | |
43 | 41 |
44 (defvar electric-help-form-to-execute nil) | 42 (defvar electric-help-form-to-execute nil) |
45 | 43 |
46 (defgroup electric-help () | 44 (defgroup electric-help () |
47 "Electric help facility." | 45 "Electric help facility." |
57 "Hook run by `with-electric-help' after initializing the buffer." | 55 "Hook run by `with-electric-help' after initializing the buffer." |
58 :type 'hook | 56 :type 'hook |
59 :group 'electric-help) | 57 :group 'electric-help) |
60 | 58 |
61 (put 'electric-help-undefined 'suppress-keymap t) | 59 (put 'electric-help-undefined 'suppress-keymap t) |
62 (if electric-help-map | 60 |
63 () | 61 (defvar electric-help-map |
64 (let ((map (make-keymap))) | 62 (let ((map (make-keymap))) |
65 ;; allow all non-self-inserting keys - search, scroll, etc, but | 63 ;; allow all non-self-inserting keys - search, scroll, etc, but |
66 ;; let M-x and C-x exit ehelp mode and retain buffer: | 64 ;; let M-x and C-x exit ehelp mode and retain buffer: |
67 (suppress-keymap map) | 65 (suppress-keymap map) |
68 (define-key map "\C-u" 'electric-help-undefined) | 66 (define-key map "\C-u" 'electric-help-undefined) |
89 ;;a better key than this? | 87 ;;a better key than this? |
90 (define-key map "R" 'electric-help-retain) | 88 (define-key map "R" 'electric-help-retain) |
91 (define-key map "r" 'electric-help-retain) | 89 (define-key map "r" 'electric-help-retain) |
92 (define-key map "\ex" 'electric-help-execute-extended) | 90 (define-key map "\ex" 'electric-help-execute-extended) |
93 (define-key map "\C-x" 'electric-help-ctrl-x-prefix) | 91 (define-key map "\C-x" 'electric-help-ctrl-x-prefix) |
94 | 92 map) |
95 (setq electric-help-map map))) | 93 "Keymap defining commands available in `electric-help-mode'.") |
96 | 94 |
97 (defun electric-help-mode () | 95 (defun electric-help-mode () |
98 "`with-electric-help' temporarily places its buffer in this mode. | 96 "`with-electric-help' temporarily places its buffer in this mode. |
99 \(On exit from `with-electric-help', the buffer is put in `default-major-mode'.)" | 97 \(On exit from `with-electric-help', the buffer is put in `default-major-mode'.)" |
100 (setq buffer-read-only t) | 98 (setq buffer-read-only t) |
115 contents of BUFFER. BUFFER defaults to `*Help*'. BUFFER will be | 113 contents of BUFFER. BUFFER defaults to `*Help*'. BUFFER will be |
116 erased before THUNK is called unless NOERASE is non-nil. THUNK will | 114 erased before THUNK is called unless NOERASE is non-nil. THUNK will |
117 be called while BUFFER is current and with `standard-output' bound to | 115 be called while BUFFER is current and with `standard-output' bound to |
118 the buffer specified by BUFFER. | 116 the buffer specified by BUFFER. |
119 | 117 |
120 If THUNK returns nil, we display BUFFER starting at the top, and | 118 If THUNK returns nil, we display BUFFER starting at the top, and shrink |
121 shrink the window to fit. If THUNK returns non-nil, we don't do those things. | 119 the window to fit. If THUNK returns non-nil, we don't do those things. |
122 | 120 |
123 After THUNK has been called, this function \"electrically\" pops up a window | 121 After THUNK has been called, this function \"electrically\" pops up a |
124 in which BUFFER is displayed and allows the user to scroll through that buffer | 122 window in which BUFFER is displayed and allows the user to scroll |
125 in `electric-help-mode'. The window's height will be at least MINHEIGHT if | 123 through that buffer in `electric-help-mode'. The window's height will |
126 this value is non-nil. | 124 be at least MINHEIGHT if this value is non-nil. |
127 | 125 |
128 If THUNK returns nil, we display BUFFER starting at the top, and | 126 If THUNK returns nil, we display BUFFER starting at the top, and |
129 shrink the window to fit if `electric-help-shrink-window' is non-nil. | 127 shrink the window to fit if `electric-help-shrink-window' is non-nil. |
130 If THUNK returns non-nil, we don't do those things. | 128 If THUNK returns non-nil, we don't do those things. |
131 | 129 |
400 (electric-helpify 'apropos)) | 398 (electric-helpify 'apropos)) |
401 | 399 |
402 | 400 |
403 ;;;; ehelp-map | 401 ;;;; ehelp-map |
404 | 402 |
405 (defvar ehelp-map ()) | 403 (defvar ehelp-map |
406 (if ehelp-map | |
407 nil | |
408 (let ((map (copy-keymap help-map))) | 404 (let ((map (copy-keymap help-map))) |
409 (substitute-key-definition 'apropos 'electric-apropos map) | 405 (substitute-key-definition 'apropos 'electric-apropos map) |
410 (substitute-key-definition 'command-apropos 'electric-command-apropos map) | 406 (substitute-key-definition 'command-apropos 'electric-command-apropos map) |
411 (substitute-key-definition 'describe-key 'electric-describe-key map) | 407 (substitute-key-definition 'describe-key 'electric-describe-key map) |
412 (substitute-key-definition 'describe-mode 'electric-describe-mode map) | 408 (substitute-key-definition 'describe-mode 'electric-describe-mode map) |
413 (substitute-key-definition 'view-lossage 'electric-view-lossage map) | 409 (substitute-key-definition 'view-lossage 'electric-view-lossage map) |
414 (substitute-key-definition 'describe-function 'electric-describe-function map) | 410 (substitute-key-definition 'describe-function 'electric-describe-function map) |
415 (substitute-key-definition 'describe-variable 'electric-describe-variable map) | 411 (substitute-key-definition 'describe-variable 'electric-describe-variable map) |
416 (substitute-key-definition 'describe-bindings 'electric-describe-bindings map) | 412 (substitute-key-definition 'describe-bindings 'electric-describe-bindings map) |
417 (substitute-key-definition 'describe-syntax 'electric-describe-syntax map) | 413 (substitute-key-definition 'describe-syntax 'electric-describe-syntax map) |
418 | 414 map)) |
419 (setq ehelp-map map))) | |
420 | 415 |
421 ;;;###(autoload 'ehelp-command "ehelp" "Prefix command for ehelp." t 'keymap) | 416 ;;;###(autoload 'ehelp-command "ehelp" "Prefix command for ehelp." t 'keymap) |
422 (defalias 'ehelp-command ehelp-map) | 417 (defalias 'ehelp-command ehelp-map) |
423 (put 'ehelp-command 'documentation "Prefix command for ehelp.") | 418 (put 'ehelp-command 'documentation "Prefix command for ehelp.") |
424 | 419 |