(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 "Ɖljȉ
!" [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 "!!΋U
! !\"Z

! \"# \"\"\"b*\\!!*" [buffer one t two nil pop-up-windows buffer-read-only noerase standard-output thunk tem get-buffer-create "*Help*" one-window-p ((byte-code "
 !b!)͎q ʼn& )!6łHq!ebH !)q! 		!=u ! ! !`$	yʼn	))" [one pop-up-windows t buffer buffer-read-only nil noerase standard-output thunk two window-start selected-window pop-to-buffer ((byte-code "!q‰Ə" [buffer buffer-read-only nil message "" (byte-code "!" [default-major-mode funcall fundamental-mode] 2) ((error (byte-code "" [nil] 1)))] 4)) electric-help-mode erase-buffer funcall set-buffer-modified-p shrink-window-if-larger-than-buffer run-hooks electric-help-mode-hook electric-help-command-loop car-safe retain vector window-height window-hscroll] 23)) pop-to-buffer window-height selected-window elt 0 shrink-window set-window-start 1 set-window-hscroll 2 3 replace-buffer-in-windows bury-buffer] 17))

(defun electric-help-command-loop nil (byte-code "" [exit (byte-code "d!!rUˉ\"!=<!=<!=<!=#-" [unread-command-char t up down both neither standard pos-visible-in-window-p message "<<< Press Space to bury the help buffer >>>" 32 -1 throw exit nil key-binding " " scroll-up "" scroll-down "Q" electric-help-exit "q" Electric-command-loop (lambda nil (byte-code "e!d!
9!i	V
^Ђii!*" [min max standard neither t up down both pos-visible-in-window-p "Press Q to exit " substitute-command-keys "Press \\[scroll-up] to exit " "Press SPC to scroll, Q to exit " "Press \\[scroll-up] to scroll; \\[electric-help-exit] to exit " "Press DEL to scroll back, Q to exit " "Press \\[scroll-down] to scroll back, \\[scroll-up] to exit " "Press SPC to scroll, DEL to scroll back, Q to exit " "Press \\[scroll-up] to scroll, \\[scroll-down] to scroll back, \\[electric-help-exit] to exit "] 8))] 13)] 2))

(defun electric-help-exit nil "\
>>>Doc" (interactive) (byte-code "\"" [t nil throw exit] 3))

(defun electric-help-retain nil "\
Exit electric-help, retaining the current window/buffer conifiguration.
(The *Help* buffer will not be selected, but \\[switch-to-buffer-other-window] RET
will select it.)" (interactive) (byte-code "\"" [nil throw exit (retain)] 3))

(defun electric-help-undefined nil (interactive) (byte-code " #!=Ȃ!#" [nil error "%s is undefined -- Press %s to exit" mapconcat single-key-description this-command-keys " " key-binding "Q" electric-help-exit substitute-command-keys "\\[electric-help-exit]"] 8))

(defun electric-help-help nil (interactive) (byte-code "!=!=!= !*!!\"!" [nil key-binding "Q" electric-help-exit " " scroll-up "" scroll-down message "SPC scrolls forward, DEL scrolls back, Q exits and burys help buffer" "Help..." "%s" substitute-command-keys "\\[scroll-up] scrolls forward, \\[scroll-down] scrolls back, \\[electric-help-exit] exits." sit-for 2] 9))

(defun electric-helpify (fun) (byte-code "ȋ#)" [name p b m nil fun t "*Help*" ((byte-code "K
!	!		!?ĉˎ
!!\"	1	q!)M
!!Z	?Z	
!=?Z	!?)+" [p b name m nil fun t print-help-return-message get-buffer buffer-modified-p get-buffer-window ((byte-code "M		!	q
!)" [p b m print-help-return-message buffer-name set-buffer-modified-p] 3)) message "%s..." capitalize symbol-name set-buffer-modified-p ignore call-interactively] 14)) with-electric-help ignore] 4))

(defun electric-describe-key nil (interactive) (byte-code "!" [nil electric-helpify describe-key] 2))

(defun electric-describe-mode nil (interactive) (byte-code "!" [nil electric-helpify describe-mode] 2))

(defun electric-view-lossage nil (interactive) (byte-code "!" [nil electric-helpify view-lossage] 2))

(defun electric-describe-function nil (interactive) (byte-code "!" [nil electric-helpify describe-function] 2))

(defun electric-describe-variable nil (interactive) (byte-code "!" [nil electric-helpify describe-variable] 2))

(defun electric-describe-bindings nil (interactive) (byte-code "!" [nil electric-helpify describe-bindings] 2))

(defun electric-describe-syntax nil (interactive) (byte-code "!" [nil electric-helpify describe-syntax] 2))

(defun electric-command-apropos nil (interactive) (byte-code "!" [nil electric-helpify command-apropos] 2))

(defvar ehelp-map nil)

(if ehelp-map nil (let ((map (copy-keymap help-map))) (substitute-key-definition (quote describe-key) (quote electric-describe-key) map) (substitute-key-definition (quote describe-mode) (quote electric-describe-mode) map) (substitute-key-definition (quote view-lossage) (quote electric-view-lossage) map) (substitute-key-definition (quote describe-function) (quote electric-describe-function) map) (substitute-key-definition (quote describe-variable) (quote electric-describe-variable) map) (substitute-key-definition (quote describe-bindings) (quote electric-describe-bindings) map) (substitute-key-definition (quote describe-syntax) (quote electric-describe-syntax) map) (setq ehelp-map map) (fset (quote ehelp-command) map)))