mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
81 lines
7.2 KiB
Text
81 lines
7.2 KiB
Text
|
||
(require (quote electric))
|
||
|
||
(provide (quote ehelp))
|
||
|
||
(defvar electric-help-map nil "\
|
||
Keymap defining commands available whilst scrolling
|
||
through a buffer in electric-help-mode")
|
||
|
||
(put (quote electric-help-undefined) (quote suppress-keymap) t)
|
||
|
||
(if electric-help-map nil (let ((map (make-keymap))) (fillarray map (quote electric-help-undefined)) (define-key map (char-to-string meta-prefix-char) (copy-keymap map)) (define-key map (char-to-string help-char) (quote electric-help-help)) (define-key map "?" (quote electric-help-help)) (define-key map " " (quote scroll-up)) (define-key map "" (quote scroll-down)) (define-key map "." (quote beginning-of-buffer)) (define-key map "<" (quote beginning-of-buffer)) (define-key map ">" (quote end-of-buffer)) (define-key map "q" (quote electric-help-exit)) (define-key map "Q" (quote electric-help-exit)) (define-key map "r" (quote electric-help-retain)) (setq electric-help-map map)))
|
||
|
||
(defun electric-help-mode nil "\
|
||
with-electric-help temporarily places its buffer in this mode
|
||
(On exit from with-electric-help, the buffer is put in default-major-mode)" (byte-code "Á‰ˆÆ‰ˆÇ‰ˆÈ‰ˆÉ
|
||
!‡" [buffer-read-only t mode-name major-mode mode-line-buffer-identification electric-help-map "Help" help (" Help: %b") use-local-map] 2))
|
||
|
||
(defun with-electric-help (thunk &optional buffer noerase) "\
|
||
Arguments are THUNK &optional BUFFER NOERASE.
|
||
BUFFER defaults to \"*Help*\"
|
||
THUNK is a function of no arguments which is called to initialise
|
||
the contents of BUFFER. BUFFER will be erased before THUNK is called unless
|
||
NOERASE is non-nil. THUNK will be called with standard-output bound to
|
||
the buffer specified by BUFFER
|
||
|
||
After THUNK has been called, this function \"electrically\" pops up a window
|
||
in which BUFFER is displayed and allows the user to scroll through that buffer
|
||
in electric-help-mode.
|
||
When the user exits (with electric-help-exit, or otherwise) the help
|
||
buffer's window disappears (ie we use save-window-excursion)
|
||
BUFFER is put into default-major-mode (or fundamental-mode) when we exit" (byte-code "ˆ |