Mercurial > emacs
comparison lisp/ehelp.el @ 200:74504bd76aaa
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 28 Feb 1991 21:40:18 +0000 |
parents | 84efc09a36b4 |
children | 4cd7543be581 |
comparison
equal
deleted
inserted
replaced
199:b3710ab30435 | 200:74504bd76aaa |
---|---|
18 | 18 |
19 (require 'electric) | 19 (require 'electric) |
20 (provide 'ehelp) | 20 (provide 'ehelp) |
21 | 21 |
22 (defvar electric-help-map () | 22 (defvar electric-help-map () |
23 "Keymap defining commands available whilst scrolling | 23 "Keymap defining commands available in `electric-help-mode'.") |
24 through a buffer in electric-help-mode") | |
25 | 24 |
26 (put 'electric-help-undefined 'suppress-keymap t) | 25 (put 'electric-help-undefined 'suppress-keymap t) |
27 (if electric-help-map | 26 (if electric-help-map |
28 () | 27 () |
29 (let ((map (make-keymap))) | 28 (let ((map (make-keymap))) |
43 (define-key map "r" 'electric-help-retain) | 42 (define-key map "r" 'electric-help-retain) |
44 | 43 |
45 (setq electric-help-map map))) | 44 (setq electric-help-map map))) |
46 | 45 |
47 (defun electric-help-mode () | 46 (defun electric-help-mode () |
48 "with-electric-help temporarily places its buffer in this mode | 47 "`with-electric-help' temporarily places its buffer in this mode. |
49 \(On exit from with-electric-help, the buffer is put in default-major-mode)" | 48 \(On exit from `with-electric-help', the buffer is put in `default-major-mode'.)" |
50 (setq buffer-read-only t) | 49 (setq buffer-read-only t) |
51 (setq mode-name "Help") | 50 (setq mode-name "Help") |
52 (setq major-mode 'help) | 51 (setq major-mode 'help) |
53 (setq mode-line-buffer-identification '(" Help: %b")) | 52 (setq mode-line-buffer-identification '(" Help: %b")) |
54 (use-local-map electric-help-map) | 53 (use-local-map electric-help-map) |
55 ;; this is done below in with-electric-help | 54 ;; this is done below in with-electric-help |
56 ;(run-hooks 'electric-help-mode-hook) | 55 ;(run-hooks 'electric-help-mode-hook) |
57 ) | 56 ) |
58 | 57 |
59 (defun with-electric-help (thunk &optional buffer noerase) | 58 (defun with-electric-help (thunk &optional buffer noerase) |
60 "Arguments are THUNK &optional BUFFER NOERASE. | 59 "Arguments are THUNK &optional BUFFER NOERASE. BUFFER defaults to \"*Help*\" |
61 BUFFER defaults to \"*Help*\" | 60 THUNK is a function of no arguments which is called to initialize |
62 THUNK is a function of no arguments which is called to initialise | 61 the contents of BUFFER. BUFFER will be erased before THUNK is called unless |
63 the contents of BUFFER. BUFFER will be erased before THUNK is called unless | 62 NOERASE is non-nil. THUNK will be called with `standard-output' bound to |
64 NOERASE is non-nil. THUNK will be called with standard-output bound to | 63 the buffer specified by BUFFER |
65 the buffer specified by BUFFER | |
66 | 64 |
67 After THUNK has been called, this function \"electrically\" pops up a window | 65 After THUNK has been called, this function \"electrically\" pops up a window |
68 in which BUFFER is displayed and allows the user to scroll through that buffer | 66 in which BUFFER is displayed and allows the user to scroll through that buffer |
69 in electric-help-mode. | 67 in electric-help-mode. |
70 When the user exits (with electric-help-exit, or otherwise) the help | 68 When the user exits (with `electric-help-exit', or otherwise) the help |
71 buffer's window disappears (ie we use save-window-excursion) | 69 buffer's window disappears (i.e., we use `save-window-excursion') |
72 BUFFER is put into default-major-mode (or fundamental-mode) when we exit" | 70 BUFFER is put into `default-major-mode' (or `fundamental-mode') when we exit" |
73 (setq buffer (get-buffer-create (or buffer "*Help*"))) | 71 (setq buffer (get-buffer-create (or buffer "*Help*"))) |
74 (let ((one (one-window-p t)) | 72 (let ((one (one-window-p t)) |
75 (config (current-window-configuration)) | 73 (config (current-window-configuration)) |
76 (bury nil)) | 74 (bury nil)) |
77 (unwind-protect | 75 (unwind-protect |
164 ">>>Doc" | 162 ">>>Doc" |
165 (interactive) | 163 (interactive) |
166 (throw 'exit t)) | 164 (throw 'exit t)) |
167 | 165 |
168 (defun electric-help-retain () | 166 (defun electric-help-retain () |
169 "Exit electric-help, retaining the current window/buffer conifiguration. | 167 "Exit `electric-help', retaining the current window/buffer configuration. |
170 \(The *Help* buffer will not be selected, but \\[switch-to-buffer-other-window] RET | 168 \(The *Help* buffer will not be selected, but \\[switch-to-buffer-other-window] RET |
171 will select it.)" | 169 will select it.)" |
172 (interactive) | 170 (interactive) |
173 (throw 'exit '(retain))) | 171 (throw 'exit '(retain))) |
174 | 172 |
175 | |
176 ;(defun electric-help-undefined () | |
177 ; (interactive) | |
178 ; (let* ((keys (this-command-keys)) | |
179 ; (n (length keys))) | |
180 ; (if (or (= n 1) | |
181 ; (and (= n 2) | |
182 ; meta-flag | |
183 ; (eq (aref keys 0) meta-prefix-char))) | |
184 ; (setq unread-command-char last-input-char | |
185 ; current-prefix-arg prefix-arg) | |
186 ; ;;>>> I don't care. | |
187 ; ;;>>> The emacs command-loop is too much pure pain to | |
188 ; ;;>>> duplicate | |
189 ; )) | |
190 ; (throw 'exit t)) | |
191 | 173 |
192 (defun electric-help-undefined () | 174 (defun electric-help-undefined () |
193 (interactive) | 175 (interactive) |
194 (error "%s is undefined -- Press %s to exit" | 176 (error "%s is undefined -- Press %s to exit" |
195 (mapconcat 'single-key-description (this-command-keys) " ") | 177 (mapconcat 'single-key-description (this-command-keys) " ") |
302 (electric-helpify 'command-apropos)) | 284 (electric-helpify 'command-apropos)) |
303 | 285 |
304 ;(define-key help-map "a" 'electric-command-apropos) | 286 ;(define-key help-map "a" 'electric-command-apropos) |
305 | 287 |
306 | 288 |
307 | |
308 | 289 |
309 ;;;; ehelp-map | 290 ;;;; ehelp-map |
310 | 291 |
311 (defvar ehelp-map ()) | 292 (defvar ehelp-map ()) |
312 (if ehelp-map | 293 (if ehelp-map |
322 | 303 |
323 (setq ehelp-map map) | 304 (setq ehelp-map map) |
324 (fset 'ehelp-command map))) | 305 (fset 'ehelp-command map))) |
325 | 306 |
326 ;; Do (define-key global-map "\C-h" 'ehelp-command) if you want to win | 307 ;; Do (define-key global-map "\C-h" 'ehelp-command) if you want to win |
327 |