* lisp/help.el (substitute-command-keys): New optional argument
NO-FACE, to avoid putting the 'help-key-binding' face on the key
bindings.
* lisp/calendar/calendar.el (calendar-mode-line-entry): Call
'substitute-command-keys' with the new optional argument non-nil.
(Bug#52366)
* doc/lispref/help.texi (Keys in Documentation): Document the new
optional argument of 'substitute-command-keys'.
* etc/NEWS: Announce the addition of a new argument to
'substitute-command-keys'.
* lisp/help.el (help--analyze-key): Use posn-set-point instead of
mouse-set-point that runs the hook mouse-leave-buffer-hook via
mouse-minibuffer-check. Using posn-set-point also unnecessitates
extra conditions added in bug#51421.
* lisp/isearch.el (isearch-describe-key, isearch-describe-mode):
Add precautions to not call isearch-update when the executed
command exited isearch-mode (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.
(outline-minor-mode-cycle--bind): New helper function.
(outline-minor-mode-cycle-map): Rename from outline-mode-cycle-map.
(outline-mode-map): Revert part of 6458e16f33 to disassociate
keymaps outline-mode-map and outline-minor-mode-cycle-map.
(outline-font-lock-keywords, outline-minor-mode-highlight-buffer):
Use outline-minor-mode-cycle-map instead of outline-mode-cycle-map.
* lisp/help.el (describe-bindings): Rename outline-mode-cycle-map
to outline-minor-mode-cycle-map.
* lisp/help-fns.el (describe-symbol): Use it.
* lisp/help.el (describe-key): Use it.
* lisp/simple.el (separator-line): New face.
(make-separator-line): New function (bug#49630).
* lisp/help-fns.el (describe-command): New command.
(help-fns--describe-function-or-command-prompt): New helper
function to prompt for a function or function. (Bug#46627)
(describe-function): Use above new helper function.
* lisp/help.el (help-map): Bind above new command to `C-h x'.
(help-for-help): Add this new command to the help summary.
* lisp/menu-bar.el (menu-bar-describe-menu): Add the new command to
the help menu.
* doc/emacs/help.texi (Help Summary, Name Help): Document
'describe-command', and update documentation on 'describe-function'.
* etc/tutorials/TUTORIAL: Change reference from 'describe-function' to
'describe-command'.
* lisp/help.el (help--for-help-make-commands): Avoid missing
whitespace before description of command.
Problem reported by Dmitry Gutov <dgutov@yandex.ru>.
* lisp/faces.el (help-key-binding): New face.
* lisp/help.el
(help-for-help): Rename from 'help-for-help-internal'. Use
'substitute-command-keys' syntax.
(help): Make into alias for 'help-for-help'.
(help-for-help-internal): Make into obsolete alias for
'help-for-help'.
(help--key-description-fontified): New function to add the
'help-key-binding' face.
(help-key-description, substitute-command-keys)
(describe-map-tree, help--describe-command)
(help--describe-translation, describe-map):
* lisp/help-fns.el (help-fns--key-bindings, describe-mode):
Use above new function.
* lisp/isearch.el (isearch-help-for-help-internal): Use
`substitute-command-keys' syntax.
* lisp/help-macro.el (make-help-screen): Use
'substitute-command-keys' and 'help--key-description-fontified'.
Simplify.
* src/keymap.c (describe_key_maybe_fontify): New function to add
the 'help-key-binding' face to keybindings.
(describe_vector): Use above new keybinding.
(syms_of_keymap) <Qfont_lock_face, Qhelp_key_binding>: New
DEFSYMs.
(fontify_key_properties): New static variable.
* lisp/tooltip.el (tooltip-show): Avoid overriding faces in
specified tooltip text.
* test/lisp/help-tests.el (with-substitute-command-keys-test):
Don't test for text properties.
(help-tests-substitute-command-keys/add-key-face)
(help-tests-substitute-command-keys/add-key-face-listing):
New tests.
* lisp/help.el (describe-map): Fix running `menu-item' :filter
functions. This fixes a mistake in the previous conversion of this
defun from the old C function describe_map. See the discussion in
Bug#39149.
* test/src/keymap-tests.el
(keymap---get-keyelt/runs-menu-item-filter)
(describe-buffer-bindings/menu-item-filter-show-binding)
(describe-buffer-bindings/menu-item-filter-hide-binding):
New tests.
(keymap-tests--test-menu-item-filter): New defun.
* lisp/help.el (describe-map-tree): Fix mistake in conversion to Lisp
from the C function describe_map_tree; make the condition match the
now removed C code. (Bug#44360)
This fixes a regression with regards to the old C version of
substitute-command-keys.
* lisp/help.el (substitute-command-keys): Don't bind standard-output.
See Bug#39149.
* test/lisp/help-tests.el
(help-tests--was-in-buffer): New variable.
(help-substitute-command-keys/menu-filter-in-correct-buffer): New
test.
* lisp/help.el (describe-map-tree): Insert header into the original
buffer, not in standard-output.
* test/src/keymap-tests.el
(describe-buffer-bindings/header-in-current-buffer)
(describe-buffer-bindings/returns-nil): New tests.
Ref: https://debbugs.gnu.org/39149#31
The previous conversion of describe_vector from C to Lisp for the
keymap and char table case lead to an unacceptable performance hit.
Moving back to the C version, as we do here, makes this function
around 50 times faster.
The Lisp version of `substitute-command-keys' was benchmarked using
the form `(documentation 'dired-mode)', which now takes less than 8 ms
on my machine. This is around 16 times slower than the previous C
version.
Thanks to Stefan Monnier for helpful pointers on benchmarking.
* src/keymap.c (Fhelp__describe_vector): New defun to expose
describe_vector to Lisp for keymaps and char tables.
(syms_of_keymap): New defsubr for Fhelp__describe_vector.
* lisp/help.el (describe-map): Use above defun instead of Lisp
version.
(help--describe-vector): Remove defun; keep it commented out for now.
Third step in converting substitute-command-keys to Lisp.
* lisp/help.el (describe-map): New Lisp version of describe_map.
(help--describe-map-compare, help--describe-translation)
(help--describe-command, help--shadow-lookup): New helper
functions for describe-map.
(help--keymaps-seen, help--previous-description-column): New
variables.
* src/keymap.c
(Fkeymap__get_keyelt): New defun to expose get_keyelt to Lisp.
(Fdescribe_map_tree_old, Fdescribe_map): Remove defuns.
(Fdescribe_vector_internal): New defun to expose describe_vector to
Lisp in a way usable by describe-map.
(syms_of_keymap): New defsubrs for Fkeymap__get_keyelt and
Fdescribe_vector_internal. Remove defsubrs for Fdescribe_map_tree_old
and Fdescribe_map. Remove 'help--keymaps-seen'.
* test/lisp/help-tests.el
(help-tests-substitute-command-keys/shadow): Extend test.
(help-tests-substitute-command-keys/test-mode)
(help-tests-substitute-command-keys/compare-all)
(help-tests-describe-map-tree/no-menu-t)
(help-tests-describe-map-tree/no-menu-nil)
(help-tests-describe-map-tree/mention-shadow-t)
(help-tests-describe-map-tree/mention-shadow-nil)
(help-tests-describe-map-tree/partial-t)
(help-tests-describe-map-tree/partial-nil): New tests.
This is the second step in converting substitute-command-keys to Lisp.
* lisp/help.el (describe-map-tree): New Lisp version of
describe_map_tree.
(substitute-command-keys): Update to use above function.
* src/keymap.c (Fdescribe_map): New defun to expose describe_map to
Lisp.
* src/keymap.c (syms_of_keymap): New variable 'help--keymaps-seen'; a
temporary kludge planned for removal. New defsubr for Fdescribe_map.
This is only the first step towards a full Lisp implementation, and
does not remove the old C code. On the contrary, it is partly based
on using the old C code, which is to be replaced in steps. This also
makes it easy to test that it produces the same output as the old.
* src/doc.c (Fsubstitute_command_keys_old): Rename from
Fsubstitute_command_keys.
(Fget_quoting_style): New defun to expose text_quoting_style to Lisp.
(syms_of_doc): Expose above symbols.
* lisp/help.el (substitute-command-keys): New Lisp version of
substitute-command-keys. (Bug#8951)
* src/keymap.c
(Fdescribe_map_tree): New defun to expose describe_map_tree to Lisp.
(syms_of_keymap): New defsubr for Fdescribe_map_tree.
* src/keyboard.c (help_echo_substitute_command_keys):
* src/doc.c (Fdocumentation, Fdocumentation_property):
* src/print.c (print_error_message):
* src/syntax.c (Finternal_describe_syntax_value): Fix calls to use new
Lisp implementation of substitute-command-keys.
* test/src/doc-tests.el: Remove file.
* test/lisp/help-tests.el: Add tests for substitute-command-keys
copied from above file.