Mercurial > emacs
annotate lisp/emacs-lisp/helper.el @ 13595:2af9ec0bc9cc
(cal-tex-version): Deleted.
(cal-tex-cursor-year-landscape): Doc fix.
(cal-tex-cursor-filofax-week): Renamed from cal-tex-cursor-week6.
(cal-tex-cursor-filofax-2week): Renamed from cal-tex-cursor-week5.
(cal-tex-cursor-week-monday): Renamed from cal-tex-cursor-week4.
(cal-tex-cursor-week-iso): Renamed from cal-tex-cursor-week3.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 19 Nov 1995 21:27:12 +0000 |
parents | eb208ec6d216 |
children | 83f275dcd93a |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; helper.el --- utility help package supporting help in electric modes |
36 | 2 |
845 | 3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
4 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
5 ;; Author: K. Shane Hartman |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
6 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: help |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
8 |
36 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
25 ;;; Code: |
36 | 26 |
584 | 27 ; hey, here's a helping hand. |
36 | 28 |
29 ;; Bind this to a string for <blank> in "... Other keys <blank>". | |
30 ;; Helper-help uses this to construct help string when scrolling. | |
31 ;; Defaults to "return" | |
32 (defvar Helper-return-blurb nil) | |
33 | |
34 ;; Keymap implementation doesn't work too well for non-standard loops. | |
35 ;; But define it anyway for those who can use it. Non-standard loops | |
36 ;; will probably have to use Helper-help. You can't autoload the | |
37 ;; keymap either. | |
38 | |
39 | |
40 (defvar Helper-help-map nil) | |
41 (if Helper-help-map | |
42 nil | |
43 (setq Helper-help-map (make-keymap)) | |
44 ;(fillarray Helper-help-map 'undefined) | |
45 (define-key Helper-help-map "m" 'Helper-describe-mode) | |
46 (define-key Helper-help-map "b" 'Helper-describe-bindings) | |
47 (define-key Helper-help-map "c" 'Helper-describe-key-briefly) | |
48 (define-key Helper-help-map "k" 'Helper-describe-key) | |
49 ;(define-key Helper-help-map "f" 'Helper-describe-function) | |
50 ;(define-key Helper-help-map "v" 'Helper-describe-variable) | |
51 (define-key Helper-help-map "?" 'Helper-help-options) | |
52 (define-key Helper-help-map (char-to-string help-char) 'Helper-help-options) | |
53 (fset 'Helper-help-map Helper-help-map)) | |
54 | |
55 (defun Helper-help-scroller () | |
56 (let ((blurb (or (and (boundp 'Helper-return-blurb) | |
57 Helper-return-blurb) | |
58 "return"))) | |
59 (save-window-excursion | |
60 (goto-char (window-start (selected-window))) | |
61 (if (get-buffer-window "*Help*") | |
62 (pop-to-buffer "*Help*") | |
63 (switch-to-buffer "*Help*")) | |
64 (goto-char (point-min)) | |
65 (let ((continue t) state) | |
66 (while continue | |
67 (setq state (+ (* 2 (if (pos-visible-in-window-p (point-max)) 1 0)) | |
68 (if (pos-visible-in-window-p (point-min)) 1 0))) | |
69 (message | |
70 (nth state | |
71 '("Space forward, Delete back. Other keys %s" | |
72 "Space scrolls forward. Other keys %s" | |
73 "Delete scrolls back. Other keys %s" | |
74 "Type anything to %s")) | |
75 blurb) | |
76 (setq continue (read-char)) | |
77 (cond ((and (memq continue '(?\ ?\C-v)) (< state 2)) | |
78 (scroll-up)) | |
79 ((= continue ?\C-l) | |
80 (recenter)) | |
81 ((and (= continue ?\177) (zerop (% state 2))) | |
82 (scroll-down)) | |
83 (t (setq continue nil)))))))) | |
84 | |
85 (defun Helper-help-options () | |
86 "Describe help options." | |
87 (interactive) | |
88 (message "c (key briefly), m (mode), k (key), b (bindings)") | |
89 ;(message "c (key briefly), m (mode), k (key), v (variable), f (function)") | |
90 (sit-for 4)) | |
91 | |
92 (defun Helper-describe-key-briefly (key) | |
208 | 93 "Briefly describe binding of KEY." |
36 | 94 (interactive "kDescribe key briefly: ") |
95 (describe-key-briefly key) | |
96 (sit-for 4)) | |
97 | |
98 (defun Helper-describe-key (key) | |
208 | 99 "Describe binding of KEY." |
36 | 100 (interactive "kDescribe key: ") |
101 (save-window-excursion (describe-key key)) | |
102 (Helper-help-scroller)) | |
103 | |
104 (defun Helper-describe-function () | |
105 "Describe a function. Name read interactively." | |
106 (interactive) | |
107 (save-window-excursion (call-interactively 'describe-function)) | |
108 (Helper-help-scroller)) | |
109 | |
110 (defun Helper-describe-variable () | |
111 "Describe a variable. Name read interactively." | |
112 (interactive) | |
113 (save-window-excursion (call-interactively 'describe-variable)) | |
114 (Helper-help-scroller)) | |
115 | |
116 (defun Helper-describe-mode () | |
117 "Describe the current mode." | |
118 (interactive) | |
119 (let ((name mode-name) | |
120 (documentation (documentation major-mode))) | |
121 (save-excursion | |
122 (set-buffer (get-buffer-create "*Help*")) | |
123 (erase-buffer) | |
9853
2018a5a1da69
(Helper-describe-mode): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
124 (insert name " Mode\n" documentation) |
2018a5a1da69
(Helper-describe-mode): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
125 (help-mode))) |
36 | 126 (Helper-help-scroller)) |
127 | |
258 | 128 ;;;###autoload |
36 | 129 (defun Helper-describe-bindings () |
130 "Describe local key bindings of current mode." | |
131 (interactive) | |
132 (message "Making binding list...") | |
133 (save-window-excursion (describe-bindings)) | |
134 (Helper-help-scroller)) | |
135 | |
258 | 136 ;;;###autoload |
36 | 137 (defun Helper-help () |
138 "Provide help for current mode." | |
139 (interactive) | |
140 (let ((continue t) c) | |
141 (while continue | |
142 (message "Help (Type ? for further options)") | |
11758
eb208ec6d216
(Helper-help): Use read-key-sequence.
Richard M. Stallman <rms@gnu.org>
parents:
9853
diff
changeset
|
143 (setq c (read-key-sequence nil)) |
36 | 144 (setq c (lookup-key Helper-help-map c)) |
145 (cond ((eq c 'Helper-help-options) | |
146 (Helper-help-options)) | |
147 ((commandp c) | |
148 (call-interactively c) | |
149 (setq continue nil)) | |
150 (t | |
151 (ding) | |
152 (setq continue nil)))))) | |
153 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
154 (provide 'helper) |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
155 |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
156 ;;; helper.el ends here |