comparison lisp/help.el @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents 1d62742628b6
children 6240c7796c7a
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
254 (interactive) 254 (interactive)
255 nil) 255 nil)
256 256
257 ;; This is a grody hack of the same genotype as `advertised-undo'; if the 257 ;; This is a grody hack of the same genotype as `advertised-undo'; if the
258 ;; bindings of Backspace and C-h are the same, we want the menubar to claim 258 ;; bindings of Backspace and C-h are the same, we want the menubar to claim
259 ;; that `info' is invoked with `C-h i', not `BS i'. 259 ;; that `info' in invoked with `C-h i', not `BS i'.
260 260
261 (defun deprecated-help-command () 261 (defun deprecated-help-command ()
262 (interactive) 262 (interactive)
263 (if (eq 'help-command (key-binding "\C-h")) 263 (if (eq 'help-command (key-binding "\C-h"))
264 (setq unread-command-event (character-to-event ?\C-h)) 264 (setq unread-command-event (character-to-event ?\C-h))
304 (defun key-or-menu-binding (key &optional menu-flag) 304 (defun key-or-menu-binding (key &optional menu-flag)
305 "Return the command invoked by KEY. 305 "Return the command invoked by KEY.
306 Like `key-binding', but handles menu events and toolbar presses correctly. 306 Like `key-binding', but handles menu events and toolbar presses correctly.
307 KEY is any value returned by `next-command-event'. 307 KEY is any value returned by `next-command-event'.
308 MENU-FLAG is a symbol that should be set to T if KEY is a menu event, 308 MENU-FLAG is a symbol that should be set to T if KEY is a menu event,
309 or nil otherwise" 309 or NIL otherwise"
310 (let (defn) 310 (let (defn)
311 (and menu-flag (set menu-flag nil)) 311 (and menu-flag (set menu-flag nil))
312 ;; If the key typed was really a menu selection, grab the form out 312 ;; If the key typed was really a menu selection, grab the form out
313 ;; of the event object and intuit the function that would be called, 313 ;; of the event object and intuit the function that would be called,
314 ;; and describe that instead. 314 ;; and describe that instead.
1414 (princ (car cmd)) 1414 (princ (car cmd))
1415 (setq cmd (cdr cmd)) 1415 (setq cmd (cdr cmd))
1416 (if cmd (princ " "))))) 1416 (if cmd (princ " ")))))
1417 (terpri)))))) 1417 (terpri))))))
1418 1418
1419 ;; Stop gap for 21.0 untill we do help-char etc properly.
1420 (defun help-keymap-with-help-key (keymap form)
1421 "Return a copy of KEYMAP with an help-key binding according to help-char
1422 invoking FORM like help-form. An existing binding is not overridden.
1423 If FORM is nil then no binding is made."
1424 (let ((map (copy-keymap keymap))
1425 (key (if (characterp help-char)
1426 (vector (character-to-event help-char))
1427 help-char)))
1428 (when (and form key (not (lookup-key map key)))
1429 (define-key map key
1430 `(lambda () (interactive) (help-print-help-form ,form))))
1431 map))
1432
1433 (defun help-print-help-form (form)
1434 (let ((string (eval form)))
1435 (if (stringp string)
1436 (with-displaying-help-buffer
1437 (insert string)))))
1438
1439
1440 ;;; help.el ends here 1419 ;;; help.el ends here