From: Gerd Moellmann Date: Fri, 9 Mar 2001 16:24:53 +0000 (+0000) Subject: (string-key-binding): Renamed from X-Git-Tag: emacs-pretest-21.0.100~91 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c085b77c3f1b6fbeef408628eb86a980f4aacc58;p=emacs.git (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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a121cc8ed57..9be4546aa82 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2001-03-09 Gerd Moellmann + * help.el (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. + * comint.el (comint-insert-clicked-input): Use the last key from this-command-keys to lookup the global key definition. diff --git a/lisp/help.el b/lisp/help.el index 84f3f52824e..83d8a65a9c9 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -206,17 +206,24 @@ With arg, you are asked to choose which language." (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 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer." (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 @@ If FUNCTION is nil, applies `message' to it, thus printing it." (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*"