diff lisp/help.el @ 318:afd57c14dfc8 r21-0b57

Import from CVS: tag r21-0b57
author cvs
date Mon, 13 Aug 2007 10:45:36 +0200
parents 70ad99077275
children 8e84bee8ddd0
line wrap: on
line diff
--- a/lisp/help.el	Mon Aug 13 10:44:47 2007 +0200
+++ b/lisp/help.el	Mon Aug 13 10:45:36 2007 +0200
@@ -1416,4 +1416,25 @@
 		(if cmd (princ " ")))))
 	  (terpri))))))
 
+;; Stop gap for 21.0 untill we do help-char etc properly.
+(defun help-keymap-with-help-key (keymap form)
+  "Return a copy of KEYMAP with an help-key binding according to help-char
+ invoking FORM like help-form.  An existing binding is not overridden.
+ If FORM is nil then no binding is made."
+  (let ((map (copy-keymap keymap))
+	(key (if (characterp help-char)
+		 (vector (character-to-event help-char))
+	       help-char)))
+    (when (and form key (not (lookup-key map key)))
+      (define-key map key
+	`(lambda () (interactive) (help-print-help-form ,form))))
+    map))
+
+(defun help-print-help-form (form)
+  (let ((string (eval form)))
+    (if (stringp string)
+	(with-displaying-help-buffer
+	 (insert string)))))
+
+
 ;;; help.el ends here