changeset 36700:00977877718a

(string-key-binding): Renamed from mode-line-key-binding. Handle any event on a string. Check for `keymap' properties as well as `local-map' properties.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 09 Mar 2001 16:24:10 +0000
parents fd6df4c5c815
children 5f1861d1affa
files lisp/help.el
diffstat 1 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/help.el	Fri Mar 09 14:51:34 2001 +0000
+++ b/lisp/help.el	Fri Mar 09 16:24:10 2001 +0000
@@ -206,17 +206,24 @@
       (goto-char (point-min))
       (set-buffer-modified-p nil))))
 
-(defun mode-line-key-binding (key)
-  "Value is the binding of KEY in the mode line or nil if none."
-  (let (string-info defn)
-    (when (and (eq 'mode-line (aref key 0))
-	       (consp (setq string-info (nth 4 (event-start (aref key 1))))))
-    (let* ((string (car string-info))
-	   (pos (cdr string-info))
-	   (local-map (and (> pos 0)
-			   (< pos (length string))
-			   (get-text-property pos 'local-map string))))
-      (setq defn (and local-map (lookup-key local-map key)))))
+(defun string-key-binding (key)
+  "Value is the binding of KEY in a string.
+If KEY is an event on a string, and that string has a `local-map'
+or `keymap' property, return the binding of KEY in the string's keymap."
+  (let* ((defn nil)
+	 (start (when (vectorp key)
+		  (if (memq (aref key 0) '(mode-line header-line))
+		      (event-start (aref key 1))
+		    (event-start (aref key 0)))))
+	 (string-info (and (consp start) (nth 4 start))))
+    (when string-info
+      (let* ((string (car string-info))
+	     (pos (cdr string-info))
+	     (local-map (and (> pos 0)
+			     (< pos (length string))
+			     (or (get-text-property pos 'local-map string)
+				 (get-text-property pos 'keymap string)))))
+	(setq defn (and local-map (lookup-key local-map key)))))
     defn))
 
 (defun describe-key-briefly (key &optional insert)
@@ -239,7 +246,7 @@
 	    (set-buffer (window-buffer window))
 	    (goto-char position)))
       ;; Ok, now look up the key and name the command.
-      (let ((defn (or (mode-line-key-binding key)
+      (let ((defn (or (string-key-binding key)
 		      (key-binding key)))
 	    (key-desc (key-description key)))
 	(if (or (null defn) (integerp defn))
@@ -324,7 +331,7 @@
 	  (progn
 	    (set-buffer (window-buffer window))
 	    (goto-char position)))
-      (let ((defn (or (mode-line-key-binding key) (key-binding key))))
+      (let ((defn (or (string-key-binding key) (key-binding key))))
 	(if (or (null defn) (integerp defn))
 	    (message "%s is undefined" (key-description key))
 	  (with-output-to-temp-buffer "*Help*"