comparison lisp/ehelp.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents 37645a051842
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; ehelp.el --- bindings for electric-help mode 1 ;;; ehelp.el --- bindings for electric-help mode
2 2
3 ;; Copyright (C) 1986, 1995, 2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1986, 1995, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
4 5
5 ;; Maintainer: FSF 6 ;; Maintainer: FSF
6 ;; Keywords: help, extensions 7 ;; Keywords: help, extensions
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
19 20
20 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02110-1301, USA.
24 25
25 ;;; Commentary: 26 ;;; Commentary:
26 27
27 ;; This package provides a pre-packaged `Electric Help Mode' for 28 ;; This package provides a pre-packaged `Electric Help Mode' for
28 ;; browsing on-line help screens. There is one entry point, 29 ;; browsing on-line help screens. There is one entry point,
83 (define-key map "\^?" 'scroll-down) 84 (define-key map "\^?" 'scroll-down)
84 (define-key map "." 'beginning-of-buffer) 85 (define-key map "." 'beginning-of-buffer)
85 (define-key map "<" 'beginning-of-buffer) 86 (define-key map "<" 'beginning-of-buffer)
86 (define-key map ">" 'end-of-buffer) 87 (define-key map ">" 'end-of-buffer)
87 ;(define-key map "\C-g" 'electric-help-exit) 88 ;(define-key map "\C-g" 'electric-help-exit)
89 (define-key map "Q" 'electric-help-exit)
88 (define-key map "q" 'electric-help-exit) 90 (define-key map "q" 'electric-help-exit)
89 (define-key map "Q" 'electric-help-exit)
90 ;;a better key than this? 91 ;;a better key than this?
92 (define-key map "R" 'electric-help-retain)
91 (define-key map "r" 'electric-help-retain) 93 (define-key map "r" 'electric-help-retain)
92 (define-key map "R" 'electric-help-retain)
93 (define-key map "\ex" 'electric-help-execute-extended) 94 (define-key map "\ex" 'electric-help-execute-extended)
94 (define-key map "\C-x" 'electric-help-ctrl-x-prefix) 95 (define-key map "\C-x" 'electric-help-ctrl-x-prefix)
95 96
96 (setq electric-help-map map))) 97 (setq electric-help-map map)))
97 98
198 (if (equal (setq unread-command-events (list (read-event))) 199 (if (equal (setq unread-command-events (list (read-event)))
199 '(?\ )) 200 '(?\ ))
200 (progn (setq unread-command-events nil) 201 (progn (setq unread-command-events nil)
201 (throw 'exit t))))) 202 (throw 'exit t)))))
202 (let (up down both neither 203 (let (up down both neither
203 (standard (and (eq (key-binding " ") 204 (standard (and (eq (key-binding " " nil t)
204 'scroll-up) 205 'scroll-up)
205 (eq (key-binding "\^?") 206 (eq (key-binding "\^?" nil t)
206 'scroll-down) 207 'scroll-down)
207 (eq (key-binding "q") 208 (eq (key-binding "q" nil t)
208 'electric-help-exit) 209 'electric-help-exit)
209 (eq (key-binding "r") 210 (eq (key-binding "r" nil t)
210 'electric-help-retain)))) 211 'electric-help-retain))))
211 (Electric-command-loop 212 (Electric-command-loop
212 'exit 213 'exit
213 (function (lambda () 214 (function (lambda ()
214 (sit-for 0) ;necessary if last command was end-of-buffer or 215 (sit-for 0) ;necessary if last command was end-of-buffer or
215 ;beginning-of-buffer - otherwise pos-visible-in-window-p 216 ;beginning-of-buffer - otherwise pos-visible-in-window-p
216 ;will yield a wrong result. 217 ;will yield a wrong result.
217 (let ((min (pos-visible-in-window-p (point-min))) 218 (let ((min (pos-visible-in-window-p (point-min)))
218 (max (pos-visible-in-window-p (point-max)))) 219 (max (pos-visible-in-window-p (1- (point-max)))))
219 (cond (isearch-mode 'noprompt) 220 (cond (isearch-mode 'noprompt)
220 ((and min max) 221 ((and min max)
221 (cond (standard "Press q to exit, r to retain ") 222 (cond (standard "Press q to exit, r to retain ")
222 (neither) 223 (neither)
223 (t (setq neither (substitute-command-keys "Press \\[electric-help-exit] to exit, \\[electric-help-retain] to retain "))))) 224 (t (setq neither (substitute-command-keys "Press \\[electric-help-exit] to exit, \\[electric-help-retain] to retain ")))))
270 271
271 (defun electric-help-undefined () 272 (defun electric-help-undefined ()
272 (interactive) 273 (interactive)
273 (error "%s is undefined -- Press %s to exit" 274 (error "%s is undefined -- Press %s to exit"
274 (mapconcat 'single-key-description (this-command-keys) " ") 275 (mapconcat 'single-key-description (this-command-keys) " ")
275 (if (eq (key-binding "q") 'electric-help-exit) 276 (if (eq (key-binding "q" nil t) 'electric-help-exit)
276 "q" 277 "q"
277 (substitute-command-keys "\\[electric-help-exit]")))) 278 (substitute-command-keys "\\[electric-help-exit]"))))
278 279
279 280
280 ;>>> this needs to be hairified (recursive help, anybody?) 281 ;>>> this needs to be hairified (recursive help, anybody?)
281 (defun electric-help-help () 282 (defun electric-help-help ()
282 (interactive) 283 (interactive)
283 (if (and (eq (key-binding "q") 'electric-help-exit) 284 (if (and (eq (key-binding "q" nil t) 'electric-help-exit)
284 (eq (key-binding " ") 'scroll-up) 285 (eq (key-binding " " nil t) 'scroll-up)
285 (eq (key-binding "\^?") 'scroll-down) 286 (eq (key-binding "\^?" nil t) 'scroll-down)
286 (eq (key-binding "r") 'electric-help-retain)) 287 (eq (key-binding "r" nil t) 'electric-help-retain))
287 (message "SPC scrolls up, DEL scrolls down, q exits burying help buffer, r exits") 288 (message "SPC scrolls up, DEL scrolls down, q exits burying help buffer, r exits")
288 (message "%s" (substitute-command-keys "\\[scroll-up] scrolls up, \\[scroll-down] scrolls down, \\[electric-help-exit] exits burying help buffer, \\[electric-help-retain] exits"))) 289 (message "%s" (substitute-command-keys "\\[scroll-up] scrolls up, \\[scroll-down] scrolls down, \\[electric-help-exit] exits burying help buffer, \\[electric-help-retain] exits")))
289 (sit-for 2)) 290 (sit-for 2))
290 291
291 292
416 (substitute-key-definition 'describe-function 'electric-describe-function map) 417 (substitute-key-definition 'describe-function 'electric-describe-function map)
417 (substitute-key-definition 'describe-variable 'electric-describe-variable map) 418 (substitute-key-definition 'describe-variable 'electric-describe-variable map)
418 (substitute-key-definition 'describe-bindings 'electric-describe-bindings map) 419 (substitute-key-definition 'describe-bindings 'electric-describe-bindings map)
419 (substitute-key-definition 'describe-syntax 'electric-describe-syntax map) 420 (substitute-key-definition 'describe-syntax 'electric-describe-syntax map)
420 421
421 (setq ehelp-map map) 422 (setq ehelp-map map)))
422 (fset 'ehelp-command map))) 423
424 ;;;###(autoload 'ehelp-command "ehelp" "Prefix command for ehelp." t 'keymap)
425 (defalias 'ehelp-command ehelp-map)
426 (put 'ehelp-command 'documentation "Prefix command for ehelp.")
423 427
424 (provide 'ehelp) 428 (provide 'ehelp)
425 429
430 ;;; arch-tag: e0e3037f-42c0-433e-ba18-322c5d951f46
426 ;;; ehelp.el ends here 431 ;;; ehelp.el ends here