Mercurial > emacs
comparison lisp/help-macro.el @ 5679:90ba98c692b5
(three-step-help): New option.
(make-help-screen): Implement that option.
Handle delete function key like DEL.
Don't include the option list in the prompt when displaying
a full window of options.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 26 Jan 1994 20:12:33 +0000 |
parents | f0f285e628d0 |
children | ea9f55ec6ee9 |
comparison
equal
deleted
inserted
replaced
5678:3824222fed2e | 5679:90ba98c692b5 |
---|---|
69 ;;; Code: | 69 ;;; Code: |
70 | 70 |
71 (provide 'help-macro) | 71 (provide 'help-macro) |
72 (require 'backquote) | 72 (require 'backquote) |
73 | 73 |
74 ;;;###autoload | |
75 (defvar three-step-help nil | |
76 "*Non-nil means give more info about Help command in three steps. | |
77 The three steps are simple prompt, prompt with all options, | |
78 and window listing and describing the options. | |
79 A value of nil means skip the middle step, so that | |
80 \\[help-command] \\[help-command] gives the window that lists the options.") | |
81 | |
74 (defmacro make-help-screen (fname help-line help-text helped-map) | 82 (defmacro make-help-screen (fname help-line help-text helped-map) |
75 "Construct help-menu function name FNAME. | 83 "Construct help-menu function name FNAME. |
76 When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP. | 84 When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP. |
77 If the command is the help character is requested, FNAME displays HELP-TEXT | 85 If the command is the help character is requested, FNAME displays HELP-TEXT |
78 and continues trying to read a command using HELPED-MAP. | 86 and continues trying to read a command using HELPED-MAP. |
81 (` (defun (, fname) () | 89 (` (defun (, fname) () |
82 (, help-text) | 90 (, help-text) |
83 (interactive) | 91 (interactive) |
84 (let ((line-prompt | 92 (let ((line-prompt |
85 (substitute-command-keys (, help-line)))) | 93 (substitute-command-keys (, help-line)))) |
86 (message line-prompt) | 94 (if three-step-help |
95 (message line-prompt)) | |
87 (let* ((overriding-local-map (make-sparse-keymap)) | 96 (let* ((overriding-local-map (make-sparse-keymap)) |
88 (minor-mode-map-alist nil) | 97 (minor-mode-map-alist nil) |
89 config key char help-screen) | 98 config key char help-screen) |
90 (unwind-protect | 99 (unwind-protect |
91 (progn | 100 (progn |
92 (setcdr overriding-local-map (, helped-map)) | 101 (setcdr overriding-local-map (, helped-map)) |
93 (define-key overriding-local-map [t] 'undefined) | 102 (define-key overriding-local-map [t] 'undefined) |
94 (setq help-screen (documentation (quote (, fname)))) | 103 (setq help-screen (documentation (quote (, fname)))) |
95 (setq key (read-key-sequence nil)) | 104 (if three-step-help |
96 (setq char (aref key 0)) | 105 (setq key (read-key-sequence nil) |
106 char (aref key 0)) | |
107 (setq char ??)) | |
97 (if (or (eq char ??) (eq char help-char)) | 108 (if (or (eq char ??) (eq char help-char)) |
98 (progn | 109 (progn |
99 (setq config (current-window-configuration)) | 110 (setq config (current-window-configuration)) |
100 (switch-to-buffer-other-window "*Help*") | 111 (switch-to-buffer-other-window "*Help*") |
101 (erase-buffer) | 112 (erase-buffer) |
102 (insert help-screen) | 113 (insert help-screen) |
103 (goto-char (point-min)) | 114 (goto-char (point-min)) |
104 (while (or (memq char (cons help-char '(?? ?\C-v ?\ ?\177 ?\M-v))) | 115 (while (or (memq char (cons help-char '(?? ?\C-v ?\ ?\177 delete ?\M-v))) |
105 (equal key "\M-v")) | 116 (equal key "\M-v")) |
106 (setq list (cons key list)) | 117 (setq list (cons key list)) |
107 (condition-case nil | 118 (condition-case nil |
108 (progn | 119 (progn |
109 (if (memq char '(?\C-v ?\ )) | 120 (if (memq char '(?\C-v ?\ )) |
110 (scroll-up)) | 121 (scroll-up)) |
111 (if (or (memq char '(?\177 ?\M-v)) | 122 (if (or (memq char '(?\177 ?\M-v delete)) |
112 (equal key "\M-v")) | 123 (equal key "\M-v")) |
113 (scroll-down))) | 124 (scroll-down))) |
114 (error nil)) | 125 (error nil)) |
115 (message "%s%s: " | |
116 line-prompt | |
117 (if (pos-visible-in-window-p (point-max)) | |
118 "" " or Space to scroll")) | |
119 (let ((cursor-in-echo-area t)) | 126 (let ((cursor-in-echo-area t)) |
120 (setq key (read-key-sequence nil) | 127 (setq key (read-key-sequence |
128 (format "Type one of the options listed%s: " | |
129 (if (pos-visible-in-window-p | |
130 (point-max)) | |
131 "" " or Space to scroll"))) | |
121 char (aref key 0)))) | 132 char (aref key 0)))) |
122 (setq list (cons key list)))) | 133 (setq list (cons key list)))) |
123 ;; Mouse clicks are not part of the help feature, | 134 ;; Mouse clicks are not part of the help feature, |
124 ;; so reexecute them in the standard environment. | 135 ;; so reexecute them in the standard environment. |
125 (if (listp char) | 136 (if (listp char) |