(describe-key-briefly, where-is): Prefix arg means
insert help text into current buffer.
This commit is contained in:
parent
2b1df7a941
commit
e88a2c5911
1 changed files with 29 additions and 17 deletions
46
lisp/help.el
46
lisp/help.el
|
@ -168,9 +168,10 @@ With arg, users are asked to select language."
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(set-buffer-modified-p nil))))
|
(set-buffer-modified-p nil))))
|
||||||
|
|
||||||
(defun describe-key-briefly (key)
|
(defun describe-key-briefly (key &optional insert)
|
||||||
"Print the name of the function KEY invokes. KEY is a string."
|
"Print the name of the function KEY invokes. KEY is a string.
|
||||||
(interactive "kDescribe key briefly: ")
|
If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
|
||||||
|
(interactive "kDescribe key briefly: \nP")
|
||||||
;; If this key seq ends with a down event, discard the
|
;; If this key seq ends with a down event, discard the
|
||||||
;; following click or drag event. Otherwise that would
|
;; following click or drag event. Otherwise that would
|
||||||
;; erase the message.
|
;; erase the message.
|
||||||
|
@ -181,6 +182,7 @@ With arg, users are asked to select language."
|
||||||
(read-event)))
|
(read-event)))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((modifiers (event-modifiers (aref key 0)))
|
(let ((modifiers (event-modifiers (aref key 0)))
|
||||||
|
(standard-output (if insert (current-buffer) t))
|
||||||
window position)
|
window position)
|
||||||
;; For a mouse button event, go to the button it applies to
|
;; For a mouse button event, go to the button it applies to
|
||||||
;; to get the right key bindings. And go to the right place
|
;; to get the right key bindings. And go to the right place
|
||||||
|
@ -194,14 +196,17 @@ With arg, users are asked to select language."
|
||||||
(set-buffer (window-buffer window))
|
(set-buffer (window-buffer window))
|
||||||
(goto-char position)))
|
(goto-char position)))
|
||||||
;; Ok, now look up the key and name the command.
|
;; Ok, now look up the key and name the command.
|
||||||
(let ((defn (key-binding key)))
|
(let ((defn (key-binding key))
|
||||||
|
(key-desc (key-description key)))
|
||||||
(if (or (null defn) (integerp defn))
|
(if (or (null defn) (integerp defn))
|
||||||
(message "%s is undefined" (key-description key))
|
(princ (format "%s is undefined" key-desc))
|
||||||
(message (if (windowp window)
|
(princ (format (if insert
|
||||||
"%s at that spot runs the command %s"
|
"%s (%s)"
|
||||||
"%s runs the command %s")
|
(if (windowp window)
|
||||||
(key-description key)
|
"%s at that spot runs the command %s"
|
||||||
(if (symbolp defn) defn (prin1-to-string defn))))))))
|
"%s runs the command %s"))
|
||||||
|
key-desc
|
||||||
|
(if (symbolp defn) defn (prin1-to-string defn)))))))))
|
||||||
|
|
||||||
(defun print-help-return-message (&optional function)
|
(defun print-help-return-message (&optional function)
|
||||||
"Display or return message saying how to restore windows after help command.
|
"Display or return message saying how to restore windows after help command.
|
||||||
|
@ -646,9 +651,10 @@ Returns the documentation as a string, also."
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
(message "You did not specify a variable")))
|
(message "You did not specify a variable")))
|
||||||
|
|
||||||
(defun where-is (definition)
|
(defun where-is (definition &optional insert)
|
||||||
"Print message listing key sequences that invoke specified command.
|
"Print message listing key sequences that invoke specified command.
|
||||||
Argument is a command definition, usually a symbol with a function definition."
|
Argument is a command definition, usually a symbol with a function definition.
|
||||||
|
If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
|
||||||
(interactive
|
(interactive
|
||||||
(let ((fn (function-called-at-point))
|
(let ((fn (function-called-at-point))
|
||||||
(enable-recursive-minibuffers t)
|
(enable-recursive-minibuffers t)
|
||||||
|
@ -658,12 +664,18 @@ Argument is a command definition, usually a symbol with a function definition."
|
||||||
"Where is command: ")
|
"Where is command: ")
|
||||||
obarray 'fboundp t))
|
obarray 'fboundp t))
|
||||||
(list (if (equal val "")
|
(list (if (equal val "")
|
||||||
fn (intern val)))))
|
fn (intern val))
|
||||||
|
current-prefix-arg)))
|
||||||
(let* ((keys (where-is-internal definition overriding-local-map nil nil))
|
(let* ((keys (where-is-internal definition overriding-local-map nil nil))
|
||||||
(keys1 (mapconcat 'key-description keys ", ")))
|
(keys1 (mapconcat 'key-description keys ", "))
|
||||||
(if (> (length keys1) 0)
|
(standard-output (if insert (current-buffer) t)))
|
||||||
(message "%s is on %s" definition keys1)
|
(if insert
|
||||||
(message "%s is not on any key" definition)))
|
(if (> (length keys1) 0)
|
||||||
|
(princ (format "%s (%s)" keys1 definition))
|
||||||
|
(princ (format "M-x %s RET" definition)))
|
||||||
|
(if (> (length keys1) 0)
|
||||||
|
(princ (format "%s is on %s" definition keys1))
|
||||||
|
(princ (format "%s is not on any key" definition)))))
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defun locate-library (library &optional nosuffix path interactive-call)
|
(defun locate-library (library &optional nosuffix path interactive-call)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue