350 |
(interactive) |
(interactive) |
351 |
(help-setup-xref (list #'view-lossage) (interactive-p)) |
(help-setup-xref (list #'view-lossage) (interactive-p)) |
352 |
(with-output-to-temp-buffer (help-buffer) |
(with-output-to-temp-buffer (help-buffer) |
353 |
(princ (mapconcat (function (lambda (key) |
(princ (mapconcat (lambda (key) |
354 |
(if (or (integerp key) |
(if (or (integerp key) (symbolp key) (listp key)) |
355 |
(symbolp key) |
(single-key-description key) |
356 |
(listp key)) |
(prin1-to-string key nil))) |
|
(single-key-description key) |
|
|
(prin1-to-string key nil)))) |
|
357 |
(recent-keys) |
(recent-keys) |
358 |
" ")) |
" ")) |
359 |
(with-current-buffer standard-output |
(with-current-buffer standard-output |
448 |
(setq defn (and local-map (lookup-key local-map key))))) |
(setq defn (and local-map (lookup-key local-map key))))) |
449 |
defn)) |
defn)) |
450 |
|
|
451 |
(defun describe-key-briefly (key &optional insert) |
(defun help-key-description (key untranslated) |
452 |
|
(let ((string (key-description key))) |
453 |
|
(if (or (not untranslated) (eq (aref untranslated 0) ?\e)) |
454 |
|
string |
455 |
|
(let ((otherstring (key-description untranslated))) |
456 |
|
(if (equal string otherstring) |
457 |
|
string |
458 |
|
(format "%s (translated from %s)" string otherstring)))))) |
459 |
|
|
460 |
|
(defun describe-key-briefly (key &optional insert untranslated) |
461 |
"Print the name of the function KEY invokes. KEY is a string. |
"Print the name of the function KEY invokes. KEY is a string. |
462 |
If INSERT (the prefix arg) is non-nil, insert the message in the buffer." |
If INSERT (the prefix arg) is non-nil, insert the message in the buffer. |
463 |
(interactive "kDescribe key briefly: \nP") |
If non-nil UNTRANSLATED is a vector of the untranslated events. |
464 |
|
It can also be a number in which case the untranslated events from |
465 |
|
the last key hit are used." |
466 |
|
(interactive "kDescribe key briefly: \nP\np") |
467 |
|
(if (numberp untranslated) |
468 |
|
(setq untranslated (this-single-command-raw-keys))) |
469 |
(save-excursion |
(save-excursion |
470 |
(let ((modifiers (event-modifiers (aref key 0))) |
(let ((modifiers (event-modifiers (aref key 0))) |
471 |
(standard-output (if insert (current-buffer) t)) |
(standard-output (if insert (current-buffer) t)) |
484 |
;; Ok, now look up the key and name the command. |
;; Ok, now look up the key and name the command. |
485 |
(let ((defn (or (string-key-binding key) |
(let ((defn (or (string-key-binding key) |
486 |
(key-binding key))) |
(key-binding key))) |
487 |
(key-desc (key-description key))) |
(key-desc (help-key-description key untranslated))) |
488 |
(if (or (null defn) (integerp defn) (equal defn 'undefined)) |
(if (or (null defn) (integerp defn) (equal defn 'undefined)) |
489 |
(princ (format "%s is undefined" key-desc)) |
(princ (format "%s is undefined" key-desc)) |
490 |
(princ (format (if (windowp window) |
(princ (format (if (windowp window) |
494 |
(if (symbolp defn) defn (prin1-to-string defn))))))))) |
(if (symbolp defn) defn (prin1-to-string defn))))))))) |
495 |
|
|
496 |
|
|
497 |
(defun describe-key (key) |
(defun describe-key (key &optional untranslated) |
498 |
"Display documentation of the function invoked by KEY. |
"Display documentation of the function invoked by KEY. |
499 |
KEY should be a key sequence--when calling from a program, |
KEY should be a key sequence--when calling from a program, |
500 |
pass a string or a vector." |
pass a string or a vector. |
501 |
(interactive "kDescribe key: ") |
If non-nil UNTRANSLATED is a vector of the untranslated events. |
502 |
|
It can also be a number in which case the untranslated events from |
503 |
|
the last key hit are used." |
504 |
|
(interactive "kDescribe key: \np") |
505 |
|
(if (numberp untranslated) |
506 |
|
(setq untranslated (this-single-command-raw-keys))) |
507 |
(save-excursion |
(save-excursion |
508 |
(let ((modifiers (event-modifiers (aref key 0))) |
(let ((modifiers (event-modifiers (aref key 0))) |
509 |
window position) |
window position) |
519 |
(goto-char position)) |
(goto-char position)) |
520 |
(let ((defn (or (string-key-binding key) (key-binding key)))) |
(let ((defn (or (string-key-binding key) (key-binding key)))) |
521 |
(if (or (null defn) (integerp defn) (equal defn 'undefined)) |
(if (or (null defn) (integerp defn) (equal defn 'undefined)) |
522 |
(message "%s is undefined" (key-description key)) |
(message "%s is undefined" (help-key-description key untranslated)) |
523 |
(help-setup-xref (list #'describe-function defn) (interactive-p)) |
(help-setup-xref (list #'describe-function defn) (interactive-p)) |
524 |
(with-output-to-temp-buffer (help-buffer) |
(with-output-to-temp-buffer (help-buffer) |
525 |
(princ (key-description key)) |
(princ (help-key-description key untranslated)) |
526 |
(if (windowp window) |
(if (windowp window) |
527 |
(princ " at that spot")) |
(princ " at that spot")) |
528 |
(princ " runs the command ") |
(princ " runs the command ") |