mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-05 19:59:38 +00:00
* lisp/help.el (help--analyze-key): Add new arg BUFFER (bug#51173).
* lisp/help.el (describe-key): Use BUFFER as arg for help--analyze-key. (describe-key-briefly): Change arg UNTRANSLATED deprecated in 27.1 to BUFFER. * lisp/gnus/gnus-art.el (gnus-article-describe-key) (gnus-article-describe-key-briefly): Call describe-key and describe-key-briefly with first arg as a cons with raw keys, and the BUFFER arg set to the current buffer.
This commit is contained in:
parent
cb8b12b56d
commit
59df93e2dd
2 changed files with 25 additions and 20 deletions
|
@ -6866,7 +6866,9 @@ KEY is a string or a vector."
|
||||||
unread-command-events))
|
unread-command-events))
|
||||||
(let ((cursor-in-echo-area t)
|
(let ((cursor-in-echo-area t)
|
||||||
gnus-pick-mode)
|
gnus-pick-mode)
|
||||||
(describe-key (read-key-sequence nil t))))
|
(describe-key (cons (read-key-sequence nil t)
|
||||||
|
(this-single-command-raw-keys))
|
||||||
|
(current-buffer))))
|
||||||
(describe-key key)))
|
(describe-key key)))
|
||||||
|
|
||||||
(defun gnus-article-describe-key-briefly (key &optional insert)
|
(defun gnus-article-describe-key-briefly (key &optional insert)
|
||||||
|
@ -6889,7 +6891,9 @@ KEY is a string or a vector."
|
||||||
unread-command-events))
|
unread-command-events))
|
||||||
(let ((cursor-in-echo-area t)
|
(let ((cursor-in-echo-area t)
|
||||||
gnus-pick-mode)
|
gnus-pick-mode)
|
||||||
(describe-key-briefly (read-key-sequence nil t) insert)))
|
(describe-key-briefly (cons (read-key-sequence nil t)
|
||||||
|
(this-single-command-raw-keys))
|
||||||
|
insert (current-buffer))))
|
||||||
(describe-key-briefly key insert)))
|
(describe-key-briefly key insert)))
|
||||||
|
|
||||||
;;`gnus-agent-mode' in gnus-agent.el will define it.
|
;;`gnus-agent-mode' in gnus-agent.el will define it.
|
||||||
|
|
31
lisp/help.el
31
lisp/help.el
|
@ -677,9 +677,11 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
|
||||||
(defun help--binding-undefined-p (defn)
|
(defun help--binding-undefined-p (defn)
|
||||||
(or (null defn) (integerp defn) (equal defn 'undefined)))
|
(or (null defn) (integerp defn) (equal defn 'undefined)))
|
||||||
|
|
||||||
(defun help--analyze-key (key untranslated)
|
(defun help--analyze-key (key untranslated &optional buffer)
|
||||||
"Get information about KEY its corresponding UNTRANSLATED events.
|
"Get information about KEY its corresponding UNTRANSLATED events.
|
||||||
Returns a list of the form (BRIEF-DESC DEFN EVENT MOUSE-MSG)."
|
Returns a list of the form (BRIEF-DESC DEFN EVENT MOUSE-MSG).
|
||||||
|
When BUFFER is nil, it defaults to the buffer displayed
|
||||||
|
in the selected window."
|
||||||
(if (numberp untranslated)
|
(if (numberp untranslated)
|
||||||
(error "Missing `untranslated'!"))
|
(error "Missing `untranslated'!"))
|
||||||
(let* ((event (when (> (length key) 0)
|
(let* ((event (when (> (length key) 0)
|
||||||
|
@ -699,9 +701,8 @@ Returns a list of the form (BRIEF-DESC DEFN EVENT MOUSE-MSG)."
|
||||||
;; is selected from the context menu that should describe KEY
|
;; is selected from the context menu that should describe KEY
|
||||||
;; at the position of mouse click that opened the context menu.
|
;; at the position of mouse click that opened the context menu.
|
||||||
;; When no mouse was involved, don't use `mouse-set-point'.
|
;; When no mouse was involved, don't use `mouse-set-point'.
|
||||||
(defn (if (consp event)
|
(defn (if buffer (key-binding key t)
|
||||||
(save-excursion (mouse-set-point event) (key-binding key t))
|
(save-excursion (mouse-set-point event) (key-binding key t)))))
|
||||||
(key-binding key t))))
|
|
||||||
;; Handle the case where we faked an entry in "Select and Paste" menu.
|
;; Handle the case where we faked an entry in "Select and Paste" menu.
|
||||||
(when (and (eq defn nil)
|
(when (and (eq defn nil)
|
||||||
(stringp (aref key (1- (length key))))
|
(stringp (aref key (1- (length key))))
|
||||||
|
@ -731,7 +732,7 @@ Returns a list of the form (BRIEF-DESC DEFN EVENT MOUSE-MSG)."
|
||||||
;; If nothing left, then keep one (the last one).
|
;; If nothing left, then keep one (the last one).
|
||||||
(last info-list)))
|
(last info-list)))
|
||||||
|
|
||||||
(defun describe-key-briefly (&optional key-list insert untranslated)
|
(defun describe-key-briefly (&optional key-list insert buffer)
|
||||||
"Print the name of the functions KEY-LIST invokes.
|
"Print the name of the functions KEY-LIST invokes.
|
||||||
KEY-LIST is a list of pairs (SEQ . RAW-SEQ) of key sequences, where
|
KEY-LIST is a list of pairs (SEQ . RAW-SEQ) of key sequences, where
|
||||||
RAW-SEQ is the untranslated form of the key sequence SEQ.
|
RAW-SEQ is the untranslated form of the key sequence SEQ.
|
||||||
|
@ -739,8 +740,10 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer.
|
||||||
|
|
||||||
While reading KEY-LIST interactively, this command temporarily enables
|
While reading KEY-LIST interactively, this command temporarily enables
|
||||||
menu items or tool-bar buttons that are disabled to allow getting help
|
menu items or tool-bar buttons that are disabled to allow getting help
|
||||||
on them."
|
on them.
|
||||||
(declare (advertised-calling-convention (key-list &optional insert) "27.1"))
|
|
||||||
|
BUFFER is the buffer in which to lookup those keys; it defaults to the
|
||||||
|
current buffer."
|
||||||
(interactive
|
(interactive
|
||||||
;; Ignore mouse movement events because it's too easy to miss the
|
;; Ignore mouse movement events because it's too easy to miss the
|
||||||
;; message while moving the mouse.
|
;; message while moving the mouse.
|
||||||
|
@ -748,15 +751,13 @@ on them."
|
||||||
`(,key-list ,current-prefix-arg)))
|
`(,key-list ,current-prefix-arg)))
|
||||||
(when (arrayp key-list)
|
(when (arrayp key-list)
|
||||||
;; Old calling convention, changed
|
;; Old calling convention, changed
|
||||||
(setq key-list (list (cons key-list
|
(setq key-list (list (cons key-list nil))))
|
||||||
(if (numberp untranslated)
|
(with-current-buffer (if (buffer-live-p buffer) buffer (current-buffer))
|
||||||
(this-single-command-raw-keys)
|
|
||||||
untranslated)))))
|
|
||||||
(let* ((info-list (mapcar (lambda (kr)
|
(let* ((info-list (mapcar (lambda (kr)
|
||||||
(help--analyze-key (car kr) (cdr kr)))
|
(help--analyze-key (car kr) (cdr kr) buffer))
|
||||||
key-list))
|
key-list))
|
||||||
(msg (mapconcat #'car (help--filter-info-list info-list 1) "\n")))
|
(msg (mapconcat #'car (help--filter-info-list info-list 1) "\n")))
|
||||||
(if insert (insert msg) (message "%s" msg))))
|
(if insert (insert msg) (message "%s" msg)))))
|
||||||
|
|
||||||
(defun help--key-binding-keymap (key &optional accept-default no-remap position)
|
(defun help--key-binding-keymap (key &optional accept-default no-remap position)
|
||||||
"Return a keymap holding a binding for KEY within current keymaps.
|
"Return a keymap holding a binding for KEY within current keymaps.
|
||||||
|
@ -916,7 +917,7 @@ current buffer."
|
||||||
(mapcar (lambda (x)
|
(mapcar (lambda (x)
|
||||||
(pcase-let* ((`(,seq . ,raw-seq) x)
|
(pcase-let* ((`(,seq . ,raw-seq) x)
|
||||||
(`(,brief-desc ,defn ,event ,_mouse-msg)
|
(`(,brief-desc ,defn ,event ,_mouse-msg)
|
||||||
(help--analyze-key seq raw-seq))
|
(help--analyze-key seq raw-seq buffer))
|
||||||
(locus
|
(locus
|
||||||
(help--binding-locus
|
(help--binding-locus
|
||||||
seq (event-start event))))
|
seq (event-start event))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue