annotate lisp/electric/ehelp.el @ 90:99da576a67e7 xemacs-20-0

Import from CVS: tag xemacs-20-0
author cvs
date Mon, 13 Aug 2007 09:10:46 +0200
parents b9518feda344
children 0d2f883870bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; ehelp.el --- bindings for electric-help mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1986, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Richard Mlynarik <mly@ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: help, extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
24 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
26 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; This package provides a pre-packaged `Electric Help Mode' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; browsing on-line help screens. There is one entry point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; `with-electric-help'; all you have to give it is a no-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; function that generates the actual text of the help into the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; To make this the default, you must do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; (require 'ehelp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; (define-key global-map "\C-h" 'ehelp-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; (define-key global-map [help] 'ehelp-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; (define-key global-map [f1] 'ehelp-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (require 'electric)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
45 (defvar electric-help-map ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
46 "Keymap defining commands available in `electric-help-mode'.")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
47
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
48 (defvar electric-help-form-to-execute nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (put 'electric-help-undefined 'suppress-keymap t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (if electric-help-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; allow all non-self-inserting keys - search, scroll, etc, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; let M-x and C-x exit ehelp mode and retain buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (suppress-keymap map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (define-key map "\C-u" 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (define-key map [(control ?0)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (define-key map [(control ?1)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (define-key map [(control ?2)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (define-key map [(control ?3)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (define-key map [(control ?4)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (define-key map [(control ?5)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (define-key map [(control ?6)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (define-key map [(control ?7)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (define-key map [(control ?8)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (define-key map [(control ?9)] 'electric-help-undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (define-key map (char-to-string help-char) 'electric-help-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (define-key map "?" 'electric-help-help)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
70 ;; XEmacs addition
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key map 'help 'electric-help-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key map "\^?" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key map "." 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key map "<" 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key map ">" 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;(define-key map "\C-g" 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key map "q" 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map "Q" 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;a better key than this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key map "r" 'electric-help-retain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key map "R" 'electric-help-retain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "\ex" 'electric-help-execute-extended)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key map "\C-x" 'electric-help-ctrl-x-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq electric-help-map map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun electric-help-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "`with-electric-help' temporarily places its buffer in this mode.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
90 \(On exit from `with-electric-help', the buffer is put in `default-major-mode'.)"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq mode-name "Help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (setq major-mode 'help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (setq modeline-buffer-identification '(" Help: %b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (use-local-map electric-help-map)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
96 (add-hook 'mouse-leave-buffer-hook 'electric-help-retain)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
97 (view-mode -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; this is done below in with-electric-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;(run-hooks 'electric-help-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun with-electric-help (thunk &optional buffer noerase minheight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "Pop up an \"electric\" help buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 The arguments are THUNK &optional BUFFER NOERASE MINHEIGHT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 THUNK is a function of no arguments which is called to initialize the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 contents of BUFFER. BUFFER defaults to `*Help*'. BUFFER will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 erased before THUNK is called unless NOERASE is non-nil. THUNK will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 be called while BUFFER is current and with `standard-output' bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 the buffer specified by BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 If THUNK returns nil, we display BUFFER starting at the top, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 shrink the window to fit. If THUNK returns non-nil, we don't do those things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 After THUNK has been called, this function \"electrically\" pops up a window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 in which BUFFER is displayed and allows the user to scroll through that buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 in electric-help-mode. The window's height will be at least MINHEIGHT if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 this value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 If THUNK returns nil, we display BUFFER starting at the top, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 shrink the window to fit. If THUNK returns non-nil, we don't do those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 When the user exits (with `electric-help-exit', or otherwise) the help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 buffer's window disappears (i.e., we use `save-window-excursion')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 BUFFER is put into `default-major-mode' (or `fundamental-mode') when we exit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (setq buffer (get-buffer-create (or buffer "*Help*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (let ((one (one-window-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (bury nil)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
131 (electric-help-form-to-execute nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (if one (goto-char (window-start (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((pop-up-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if (and minheight (< (window-height) minheight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (enlarge-window (- minheight (window-height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (electric-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (setq buffer-read-only nil)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
143 (or noerase
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
144 (erase-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (let ((standard-output buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (not (funcall thunk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if one (shrink-window-if-larger-than-buffer (selected-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (run-hooks 'electric-help-mode-hook)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
154 (setq buffer-read-only t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (eq (car-safe
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
156 ;; XEmacs: Don't be screwed by minor-modes (view-minor-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let ((overriding-local-map electric-help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (electric-help-command-loop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 'retain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq bury t)))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
162 (message "")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (funcall (or default-major-mode 'fundamental-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (set-window-configuration config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if bury
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;>> Perhaps this shouldn't be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; so that when we say "Press space to bury" we mean it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (replace-buffer-in-windows buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; must do this outside of save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (bury-buffer buffer)))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
176 (eval electric-help-form-to-execute))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun electric-help-command-loop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (catch 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (if (pos-visible-in-window-p (point-max))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
181 (progn (message "%s" (substitute-command-keys "<<< Press Space to bury the help buffer, Press \\[electric-help-retain] to retain it >>>"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
182 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (if (equal (setq unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (list (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 '(?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (progn (setq unread-command-events nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (throw 'exit t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (let (up down both neither
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (standard (and (eq (key-binding " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (eq (key-binding "\^?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (eq (key-binding "q")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (eq (key-binding "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 'electric-help-retain))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (Electric-command-loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (sit-for 0) ;necessary if last command was end-of-buffer or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;beginning-of-buffer - otherwise pos-visible-in-window-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;will yield a wrong result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let ((min (pos-visible-in-window-p (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (max (pos-visible-in-window-p (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (cond (isearch-mode 'noprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ((and min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (cond (standard "Press q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (neither)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (t (setq neither (substitute-command-keys "Press \\[electric-help-exit] to exit, \\[electric-help-retain] to retain ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (min
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (cond (standard "Press SPC to scroll, q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (t (setq up (substitute-command-keys "Press \\[scroll-up] to scroll, \\[electric-help-exit] to exit, \\[electric-help-retain] to retain ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cond (standard "Press DEL to scroll back, q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (t (setq down (substitute-command-keys "Press \\[scroll-down] to scroll back, \\[electric-help-exit] to exit, \\[electric-help-retain] to retain ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (cond (standard "Press SPC to scroll, DEL to scroll back, q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (both)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (t (setq both (substitute-command-keys "Press \\[scroll-up] to scroll, \\[scroll-down] to scroll back, \\[electric-help-exit] to exit, \\[electric-help-retain] to retain ")))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;(defun electric-help-scroll-up (arg)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
227 ; ">>>Doc"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ; (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ; (if (and (null arg) (pos-visible-in-window-p (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ; (electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ; (scroll-up arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defun electric-help-exit ()
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
234 ">>>Doc"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (throw 'exit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun electric-help-retain ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Exit `electric-help', retaining the current window/buffer configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 \(The *Help* buffer will not be selected, but \\[switch-to-buffer-other-window] RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 will select it.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; Make sure that we don't throw twice, even if two events cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; calling this function:
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
245 (if (memq 'electric-help-retain mouse-leave-buffer-hook)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
246 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
247 (remove-hook 'mouse-leave-buffer-hook 'electric-help-retain)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
248 (throw 'exit '(retain)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun electric-help-undefined ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (error "%s is undefined -- Press %s to exit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (mapconcat 'single-key-description (this-command-keys) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (if (eq (key-binding "q") 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "q"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (substitute-command-keys "\\[electric-help-exit]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
260 ;>>> this needs to be hairified (recursive help, anybody?)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun electric-help-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (and (eq (key-binding "q") 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (eq (key-binding " ") 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (eq (key-binding "\^?") 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (eq (key-binding "r") 'electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (message "SPC scrolls up, DEL scrolls down, q exits burying help buffer, r exits")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (message "%s" (substitute-command-keys "\\[scroll-up] scrolls up, \\[scroll-down] scrolls down, \\[electric-help-exit] exits burying help buffer, \\[electric-help-retain] exits")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (sit-for 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;;###autoload
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
273 (defun electric-helpify (fun &optional name)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
274 (let ((name (or name "*Help*")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
275 (if (save-window-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
276 ;; kludge-o-rama
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
277 (let* ((p (symbol-function 'print-help-return-message))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
278 (b (get-buffer name))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
279 (m (buffer-modified-p b)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
280 (and b (not (get-buffer-window b))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
281 (setq b nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
282 (unwind-protect
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
283 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
284 (message "%s..." (capitalize (symbol-name fun)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
285 ;; with-output-to-temp-buffer marks the buffer as unmodified.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
286 ;; kludging excessively and relying on that as some sort
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
287 ;; of indication leads to the following abomination...
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
288 ;;>> This would be doable without such icky kludges if either
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
289 ;;>> (a) there were a function to read the interactive
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
290 ;;>> args for a command and return a list of those args.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
291 ;;>> (To which one would then just apply the command)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
292 ;;>> (The only problem with this is that interactive-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
293 ;;>> would break, but that is such a misfeature in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
294 ;;>> any case that I don't care)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
295 ;;>> It is easy to do this for emacs-lisp functions;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
296 ;;>> the only problem is getting the interactive spec
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
297 ;;>> for subrs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
298 ;;>> (b) there were a function which returned a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
299 ;;>> modification-tick for a buffer. One could tell
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
300 ;;>> whether a buffer had changed by whether the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
301 ;;>> modification-tick were different.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
302 ;;>> (Presumably there would have to be a way to either
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
303 ;;>> restore the tick to some previous value, or to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
304 ;;>> suspend updating of the tick in order to allow
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
305 ;;>> things like momentary-string-display)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
306 (and b
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
307 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
308 (set-buffer b)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
309 (set-buffer-modified-p t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
310 (fset 'print-help-return-message 'ignore)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
311 (call-interactively fun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
312 (and (get-buffer name)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
313 (get-buffer-window (get-buffer name))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
314 (or (not b)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
315 (not (eq b (get-buffer name)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
316 (not (buffer-modified-p b)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
317 (fset 'print-help-return-message p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
318 (and b (buffer-name b)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
319 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
320 (set-buffer b)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
321 (set-buffer-modified-p m))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
322 (with-electric-help 'ignore name t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; This is to be bound to M-x in ehelp mode. Retains ehelp buffer and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; continues with execute-extended-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun electric-help-execute-extended (prefixarg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (interactive "p")
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
330 (setq electric-help-form-to-execute '(execute-extended-command nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; This is to be buond to C-x in ehelp mode. Retains ehelp buffer and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; continues with ctrl-x prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (defun electric-help-ctrl-x-prefix (prefixarg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (interactive "p")
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
337 (setq electric-help-form-to-execute '(progn (message nil) (setq unread-command-char ?\C-x)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun electric-describe-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (electric-helpify 'describe-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun electric-describe-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (electric-helpify 'describe-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defun electric-view-lossage ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (electric-helpify 'view-lossage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;(defun electric-help-for-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ; "See help-for-help"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun electric-describe-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (electric-helpify 'describe-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun electric-describe-variable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (electric-helpify 'describe-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defun electric-describe-bindings ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (electric-helpify 'describe-bindings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun electric-describe-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (electric-helpify 'describe-syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun electric-command-apropos ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (interactive)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
376 (electric-helpify 'command-apropos "*Apropos*"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;(define-key help-map "a" 'electric-command-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun electric-apropos ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (electric-helpify 'apropos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;;;; ehelp-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
387 (defvar ehelp-map ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if ehelp-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; #### WTF? Why don't we just use substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; like FSF does?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (let ((shadow '((apropos . electric-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (command-apropos . electric-command-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (describe-key . electric-describe-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (describe-mode . electric-describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (view-lossage . electric-view-lossage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (describe-function . electric-describe-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (describe-variable . electric-describe-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (describe-bindings . electric-describe-bindings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (describe-syntax . electric-describe-syntax)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (set-keymap-name map 'ehelp-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (set-keymap-parents map (list help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; Shadow bindings which would be inherited from help-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;#### This doesn't descend into sub-keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (map-keymap (function (lambda (key binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (let ((tem (assq binding shadow)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if tem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (define-key map key (cdr tem))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (setq ehelp-map map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (fset 'ehelp-command map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; Do (define-key global-map "\C-h" 'ehelp-command) if you want to win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (provide 'ehelp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;; ehelp.el ends here