annotate lisp/electric/ehelp.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: help, extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.30.
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)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvar electric-help-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Keymap defining commands available in `electric-help-mode'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (put 'electric-help-undefined 'suppress-keymap t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if electric-help-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (set-keymap-name map 'electric-help-map)
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)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (define-key map 'help 'electric-help-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key map " " 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key map "\^?" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key map "." 'beginning-of-buffer)
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 ">" 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;(define-key map "\C-g" 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key map "q" '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 ;;a better key than this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key map "r" 'electric-help-retain)
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 "\ex" 'electric-help-execute-extended)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "\C-x" 'electric-help-ctrl-x-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq electric-help-map map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defun electric-help-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "`with-electric-help' temporarily places its buffer in this mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 \(On exit from `with-electric-help', the buffer is put in `default-major-mode'.\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq mode-name "Help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq major-mode 'help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (setq modeline-buffer-identification '(" Help: %b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (use-local-map electric-help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq mouse-leave-buffer-hook '(electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; this is done below in with-electric-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;(run-hooks 'electric-help-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun with-electric-help (thunk &optional buffer noerase minheight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Pop up an \"electric\" help buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 The arguments are THUNK &optional BUFFER NOERASE MINHEIGHT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 THUNK is a function of no arguments which is called to initialize the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 contents of BUFFER. BUFFER defaults to `*Help*'. BUFFER will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 erased before THUNK is called unless NOERASE is non-nil. THUNK will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 be called while BUFFER is current and with `standard-output' bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 the buffer specified by BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 If THUNK returns nil, we display BUFFER starting at the top, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 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
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 After THUNK has been called, this function \"electrically\" pops up a window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 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
115 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
116 this value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 If THUNK returns nil, we display BUFFER starting at the top, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 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
120 things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 When the user exits (with `electric-help-exit', or otherwise) the help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 buffer's window disappears (i.e., we use `save-window-excursion')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 BUFFER is put into `default-major-mode' (or `fundamental-mode') when we exit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq buffer (get-buffer-create (or buffer "*Help*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((one (one-window-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (bury nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (to-be-executed nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if one (goto-char (window-start (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let ((pop-up-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if (and minheight (< (window-height) minheight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (enlarge-window (- minheight (window-height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (electric-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (or noerase (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let ((standard-output buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (if (not (funcall thunk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if one (shrink-window-if-larger-than-buffer (selected-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (run-hooks 'electric-help-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if (eq (car-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; Don't be screwed by minor-modes (view-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (let ((overriding-local-map electric-help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (electric-help-command-loop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 'retain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq bury t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (funcall (or default-major-mode 'fundamental-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (set-window-configuration config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if bury
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;>> Perhaps this shouldn't be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; so that when we say "Press space to bury" we mean it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (replace-buffer-in-windows buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; must do this outside of save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (bury-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (eval to-be-executed))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defun electric-help-command-loop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (catch 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (progn (message (substitute-command-keys "<<< Press Space to bury the help buffer, Press \\[electric-help-retain] to retain it >>>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (if (equal (setq unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (list (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 '(?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (progn (setq unread-command-events nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (throw 'exit t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (let (up down both neither
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (standard (and (eq (key-binding " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (eq (key-binding "\^?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (eq (key-binding "q")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (eq (key-binding "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 'electric-help-retain))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (Electric-command-loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (sit-for 0) ;necessary if last command was end-of-buffer or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;beginning-of-buffer - otherwise pos-visible-in-window-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;will yield a wrong result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((min (pos-visible-in-window-p (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (max (pos-visible-in-window-p (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (cond (isearch-mode 'noprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ((and min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (cond (standard "Press q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (neither)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (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
205 (min
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (cond (standard "Press SPC to scroll, q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (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
209 (max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (cond (standard "Press DEL to scroll back, q to exit, r to retain ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (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
213 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (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
215 (both)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (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
217 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;(defun electric-help-scroll-up (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ; "####Doc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ; (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ; (if (and (null arg) (pos-visible-in-window-p (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ; (electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ; (scroll-up arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (defun electric-help-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "####Doc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (throw 'exit t))
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-retain ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "Exit `electric-help', retaining the current window/buffer configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 \(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
236 will select it.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; Make sure that we don't throw twice, even if two events cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; calling this function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if mouse-leave-buffer-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setq mouse-leave-buffer-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (throw 'exit '(retain)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;(defun electric-help-undefined ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ; (let* ((keys (this-command-keys))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ; (n (length keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ; (if (or (= n 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ; (and (= n 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ; meta-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ; (eq (aref keys 0) meta-prefix-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ; (setq unread-command-char last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ; current-prefix-arg prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ; ;;#### I don't care.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ; ;;#### The emacs command-loop is too much pure pain to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ; ;;#### duplicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ; (throw 'exit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defun electric-help-undefined ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (error "%s is undefined -- Press %s to exit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (mapconcat 'single-key-description (this-command-keys) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if (eq (key-binding "q") 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "q"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (substitute-command-keys "\\[electric-help-exit]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;#### this needs to be hairified (recursive help, anybody?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun electric-help-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (and (eq (key-binding "q") 'electric-help-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (eq (key-binding " ") 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (eq (key-binding "\^?") 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (eq (key-binding "r") 'electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (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
279 (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
280 (sit-for 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun electric-helpify (fun &optional buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (or buffer-name (setq buffer-name "*Help*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (let* ((p (symbol-function 'print-help-return-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (b (get-buffer buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (tick (and b (buffer-modified-tick b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (and b (not (get-buffer-window b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq b nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (message "%s..." (capitalize (symbol-name fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; kludge-o-rama
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (fset 'print-help-return-message 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (let ((a (call-interactively fun 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let ((temp-buffer-show-function 'ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (apply fun a)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Was a non-empty help buffer created/modified?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((r (get-buffer buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (and r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;(get-buffer-window r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (or (not b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (not (eq b r))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (not (eql tick (buffer-modified-tick b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (set-buffer r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (> (buffer-size) 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (fset 'print-help-return-message p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (with-electric-help 'ignore buffer-name t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; 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
317 ;; continues with execute-extended-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun electric-help-execute-extended (prefixarg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (setq to-be-executed '(execute-extended-command nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; 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
324 ;; continues with ctrl-x prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun electric-help-ctrl-x-prefix (prefixarg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq to-be-executed '(progn (message nil) (setq unread-command-char ?\C-x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (electric-help-retain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defun electric-describe-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (electric-helpify 'describe-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (defun electric-describe-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (electric-helpify 'describe-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (defun electric-view-lossage ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (electric-helpify 'view-lossage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;(defun electric-help-for-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ; "See help-for-help"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defun electric-describe-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (electric-helpify 'describe-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun electric-describe-variable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (electric-helpify 'describe-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defun electric-describe-bindings ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (electric-helpify 'describe-bindings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defun electric-describe-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (electric-helpify 'describe-syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun electric-command-apropos ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (electric-helpify 'command-apropos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;(define-key help-map "a" 'electric-command-apropos)
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-apropos ()
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 'apropos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;;;; ehelp-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defvar ehelp-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if ehelp-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; #### WTF? Why don't we just use substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; like FSF does?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let ((shadow '((apropos . electric-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (command-apropos . electric-command-apropos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (describe-key . electric-describe-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (describe-mode . electric-describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (view-lossage . electric-view-lossage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (describe-function . electric-describe-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (describe-variable . electric-describe-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (describe-bindings . electric-describe-bindings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (describe-syntax . electric-describe-syntax)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (set-keymap-name map 'ehelp-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (set-keymap-parents map (list help-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; Shadow bindings which would be inherited from help-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;#### This doesn't descend into sub-keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (map-keymap (function (lambda (key binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (let ((tem (assq binding shadow)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (if tem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (define-key map key (cdr tem))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (setq ehelp-map map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (fset 'ehelp-command map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; 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
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (provide 'ehelp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;;; ehelp.el ends here