Commit graph

655 commits

Author SHA1 Message Date
Eli Zaretskii
e45bd10a3d Fix indentation regression in 'C-h l'
* lisp/help.el (view-lossage): Fix indentation of commands
when the key sequence includes a semicolon.  (Bug#62453)
2023-03-29 14:56:20 +03:00
Eli Zaretskii
19c95b1416 Allow showing prefix commands in Help buffers
* lisp/help.el (describe-bindings-show-prefix-commands): New user
option.
(describe-map): Use it to decide whether to output prefix
commands.  Patch by Bob Rogers <rogers@rgrjr.com>.  (Bug#62279)

* etc/NEWS: Document 'describe-bindings-show-prefix-commands'.
2023-03-23 10:31:56 +02:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Juri Linkov
db96b1282f * lisp/help.el: Use 'C-h C-q' to toggle 'help-quick' window (bug#60249).
(help-map): Bind "C-q" to 'help-quick-toggle'.  Rebind "q" to 'help-quit'.
(help-quick): Replace help-quit-or-quick with help-quick-toggle.
(help-quick-toggle): New command.
(help-quit-or-quick): Remove command.
(help-for-help): Replace help-quick-or-quit with help-quick-toggle.
2022-12-28 20:49:23 +02:00
Eli Zaretskii
afa4fcb95b Fix "C-h k" when clicking on another frame
* lisp/help.el (help--analyze-key): Don't barf if the key sequence
includes a switch-frame event.  (Bug#59785)
2022-12-03 21:43:36 +02:00
Juri Linkov
7a4f524314 * lisp/help.el (describe-bindings): Use the outline-default-rules feature.
Set buffer-local outline-default-state to 1, and outline-default-rules
to match "Key translations", instead of searching and hiding this section
explicitly.
2022-11-23 20:34:27 +02:00
Stefan Kangas
f176a36f46 ; Doc fixes: remove references to missing symbols
* lisp/allout.el (allout-process-exposed): Don't refer to missing
value 'flat-indented'.
* lisp/help.el (resize-temp-buffer-window): Don't refer to missing
function 'preserve-window-size'.
* lisp/pcomplete.el (pcomplete-stub): Don't refer to missing
function 'pcomplete-filename'.
2022-11-21 15:20:11 +01:00
Stefan Kangas
ce52746444 Prefer defvar-keymap in help.el
* lisp/help.el (help-key): New function.
(help-map): Prefer defvar-keymap.
2022-10-29 08:21:59 +02:00
Juri Linkov
fab2084956 Unify outline-minor-mode-use-buttons with in-margins/insert values (bug#57813)
* doc/emacs/text.texi (Outline Mode): Remove outline-minor-mode-use-margins.
Document the values insert/in-margins of outline-minor-mode-use-buttons.

* lisp/help.el (describe-bindings):
Set outline-minor-mode-use-buttons to 'insert'.

* lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common):
Set outline-minor-mode-use-buttons to 'in-margins'.

* lisp/outline.el (outline-minor-mode-use-buttons): Change :type
from 'buffer-predicate' to choice of const values nil/in-margins/t.
(outline--use-buttons, outline-minor-mode-insert-buttons)
(outline-minor-mode-use-margins, outline--use-margins): Remove variables.
(outline-minor-mode-highlight-buffer): Change overlay name
'outline-overlay' to 'outline-highlight'.
(outline-minor-mode): Simplify to handle possible values of
'outline-minor-mode-use-buttons' instead of using many variables.
(outline--make-button-overlay): Use value 'insert' of
'outline-minor-mode-use-buttons'.
(outline--insert-open-button, outline--insert-close-button)
(outline--fix-up-all-buttons, outline--fix-buttons-after-change):
Handle values of outline-minor-mode-use-buttons instead of using
many variables.
2022-10-22 21:37:56 +03:00
Juri Linkov
ab1b491f83 * lisp/outline.el (outline-minor-mode-insert-buttons): New defvar-local.
(outline--make-button-overlay, outline--insert-open-button)
(outline--insert-close-button): Insert button when
outline-minor-mode-insert-buttons is non-nil, otherwise
put an overlay with before-string.  (bug#57813)

* lisp/help.el (describe-bindings): Set buffer-local
outline-minor-mode-insert-buttons to t.

* lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common):
Set buffer-local outline-minor-mode-use-margins to t.  Don't set
outline-regexp for leading spaces because now spaces are not added
in the NEWS buffer.
2022-10-18 21:13:29 +03:00
Lars Ingebrigtsen
0164d5e71d Clear misleading message in help-quit-or-quick
* lisp/help.el (help-quit-or-quick): Clear misleading message
(bug#58542).
2022-10-16 11:53:03 +02:00
Philip Kaludercic
51fc195d39
Add a quick-help menu
* lisp/help.el (help-map): Bind 'help-quit-or-quick' instead of 'help-quit'.
(help-quick-sections): Add variable.
(help-quick): Add main command.
(cheat-sheet): Add alias for 'help-quick'.
(help-quit-or-quick): Add auxiliary command.
lisp/help.el (help-for-help):  Mention 'help-quit-or-quick'.
* etc/NEWS (https): Mention 'help-quit'.
2022-10-14 18:26:08 +02:00
Robert Pluim
cee9a2cbe0 Fix substitute-command-keys for global binding lookup
The previous change forgot to account for the (rare) case of doing a
lookup for a global binding when a specific keymap is in force.

* lisp/help.el (substitute-command-keys): Redo lookup in global map if
lookup in specific map fails.
*
test/lisp/help-tests.el (help-tests-substitute-command-keys/keymap-change):
Add testcase for specific map overriding advertised-binding.
2022-09-21 09:15:47 +02:00
Robert Pluim
120ade62cd Allow keymap to override advertised-binding in docstrings
Previously

(substitute-command-keys "\\<undo-repeat-map>\\[undo]")

would use the global advertised-binding for `undo', even though
there's a binding in `undo-repeat-map', which is highly
counter-intuitive.  Now the binding is looked up in the specified
keymap first.

* lisp/help.el (substitute-command-keys): Restrict the initial key
lookup to the specified keymap (if there is one).  (Bug#51384)
2022-09-20 17:44:05 +02:00
Lars Ingebrigtsen
aed39a518d Revert "Fix help--analyze-key problem when not called from menu"
This reverts commit 7e374b9663.

This should not be needed -- perhaps it was triggered by
an ephemeral code change in my running Emacs.
2022-09-13 18:26:11 +02:00
Lars Ingebrigtsen
7e374b9663 Fix help--analyze-key problem when not called from menu
* lisp/help.el (help--analyze-key): Don't bug out when not called
from the menu.
2022-09-13 16:14:57 +02:00
Stefan Kangas
6cd9e586cc New function substitute-quotes
* lisp/help.el (substitute-quotes): New function.  (Bug#51040)
* doc/lispref/help.texi (Keys in Documentation): Document
substitute-quotes.
* test/lisp/help-tests.el (help-tests-substitute-quotes): New test.

* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-theme.el (describe-theme-1):
* lisp/emacs-lisp/cl-extra.el (cl--describe-class):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/package.el (describe-package-1):
* lisp/help-fns.el (help-fns--parent-mode, help-fns--var-risky)
(help-fns--var-file-local, help-fns--var-bufferlocal)
(describe-face):
* lisp/help.el (substitute-command-keys):
* lisp/progmodes/octave.el (octave-help): Use the new function
instead of 'substitute-command-keys'.
2022-09-10 07:37:36 +02:00
Stefan Kangas
a936335aa0 Fix return value of help--key-description-fontified
This fixes a bug with warning about obsolete commands in
`command-execute', where we incorrectly showed empty parenthesis
instead of the empty string when there was no keybinding for the new
command.

* lisp/help.el (help--key-description-fontified): Return nil instead
of the empty string if KEYS argument is nil.
* test/lisp/help-tests.el (help--key-description-fontified): New test.
(with-substitute-command-keys-test): Fix indentation.
2022-08-19 20:36:12 +02:00
Stefan Kangas
eb2f394289 * lisp/help.el (describe-map-tree, describe-map): Simplify. 2022-08-03 17:44:03 +02:00
Stefan Kangas
95856c5154 Add face to mouse buttons in command substitutions
* lisp/help.el (substitute-command-keys): Add help-key-binding face to
mouse buttons in literal key substitutions.
* test/lisp/help-tests.el
(help-tests-substitute-command-keys/literal-key-sequence): Expand
test for above change.
2022-08-03 16:18:00 +02:00
Lars Ingebrigtsen
d7e848ccda Use icons in outline
* lisp/help.el (describe-bindings): Don't force buttons on
(bug#56691).

* lisp/outline.el (outline-minor-mode-use-buttons): Default
buttons on in special-mode buffers.
* lisp/outline.el (outline-minor-mode-buttons): Remove.
(outline-open, outline-close): New icons.
(outline-minor-mode-highlight-buffer): Use the new predicate to
switch on/off.
(outline--make-button): Remove.
(outline--make-button-overlay): Use icons.el instantiation.
(outline--valid-emoji-p): Remove.
(outline--valid-char-p): Remove.
(outline--insert-open-button, outline--insert-close-button): Make
point movement better in *Help* buffers.
2022-07-28 14:39:38 +02:00
Stefan Kangas
a463dccdd0 Merge from origin/emacs-28
b4067394dc Set `default-directory' of Tramp archive connection buffer
2529e82002 ; * doc/lispref/functions.texi (Declare Form): Fix typo.
54c4ceb009 Update the documentation of 'declare' forms
7263631dca Fix bookmark support for Help functions in native-compilat...

# Conflicts:
#	lisp/help.el
2022-07-24 09:55:01 +02:00
Eli Zaretskii
7263631dca Fix bookmark support for Help functions in native-compilation builds
* lisp/help.el (describe-key--helper, describe-function--helper):
New helper functions.
(describe-key): Call 'describe-key--helper' instead of a
lambda-function.
* lisp/help-fns.el (describe-function): Call
'describe-function--helper' instead of a lambda-function.
(Bug#56643)
2022-07-23 11:11:47 +03:00
Stefan Kangas
5f1023a2ff Minor doc fix in search-forward-help-for-help
* lisp/help.el (search-forward-help-for-help): Use command
substitution.
2022-07-21 09:23:27 +02:00
Stefan Kangas
ac0027f6a5 Remove dead branch from substitute-command-keys
* lisp/help.el (substitute-command-keys): Remove dead branch;
where-is-internal will follow any remaps for us.  Note also that the
test case for remapping still pass.
2022-07-11 17:22:19 +02:00
Lars Ingebrigtsen
274fcfa850 Restore temp-buffer-resize-mode behaviour wrt. [back] buttons
* lisp/help.el (help--window-setup): If temp-buffer-resize-mode, do
the window setup after adding [back] buttons (bug#56306).
2022-06-30 12:35:55 +02:00
Stefan Kangas
37315f9895 Don't error out on invalid literal key substitutions
It would be backwards-incompatible to error out on invalid literal key
substitutions.  Consider this docstring fragment, where "\\`" should
have been escaped but wasn't:

    "Example value: \"\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)\"."

If we error out, we can't display this docstring at all.  However, it
is clearly better to display something in such cases, even if
suboptimal, than refusing to display anything at all.

* lisp/help.el (substitute-command-keys): Don't error out on invalid
literal key substitutions: just ignore them instead.
* test/lisp/help-tests.el
(help-tests-substitute-command-keys/literal-key-sequence-errors):
Delete test.
(help-tests-substitute-command-keys/literal-key-sequence-ignore-invalid):
New test.
2022-06-25 12:25:58 +02:00
Lars Ingebrigtsen
a5387dec4e Fix previous describe-key change
* lisp/help.el (describe-function-orig-buffer): Ensure we bind
dynamically.
2022-06-21 13:34:54 +02:00
Lars Ingebrigtsen
ef03c8852d Make describe-key do doc string command key substitution again
* lisp/help.el (describe-key): Do doc string command key
substitution (bug#56106).
2022-06-21 13:33:02 +02:00
Lars Ingebrigtsen
7934bad23b Fix fontification in describe-key
* lisp/help.el (describe-key): Use insert instead of princ so that
text properties on the key descriptions survive.
2022-06-21 13:25:19 +02:00
Stefan Kangas
4f3c1eb4c5 Respect no-face argument in literal key substitutions
* lisp/help.el (substitute-command-keys): Respect 'no-face' argument
also in literal key substitutions.
* test/lisp/help-tests.el
(help-tests-substitute-key-bindings/help-key-binding-face): Rename
from help-tests-substitute-key-bindings/face-help-key-binding.
(help-tests-substitute-key-bindings/help-key-binding-no-face): New test.
2022-06-18 19:56:07 +02:00
Lars Ingebrigtsen
f188b0185e Allow saying \\=`M-x ...' in a doc string
* lisp/help.el (substitute-command-keys): Allow saying \\=`M-x
foo' in doc strings (and have it be fontified as a key binding).
2022-06-13 17:02:55 +02:00
Lars Ingebrigtsen
a6b8bcad58 Further tweaks to how remapped commands are described
* lisp/help.el (describe-map): Rework how remapped commands are
output to avoid repetitions.

They're now shown as:

C-x 4 C-o	ido-display-buffer
  (Remapped via <remap> <display-buffer>)
C-x 5 C-o	ido-display-buffer-other-frame
  (Remapped via <remap> <display-buffer-other-frame>)
C-x x i		ido-insert-buffer
  (Remapped via <remap> <insert-buffer>)
2022-06-11 12:34:18 +02:00
Lars Ingebrigtsen
15a5c5ce40 Make describe-prefix-bindings say when there are no matches
* lisp/help.el (describe-prefix-bindings): Say when there are no
bindings under a prefix (bug#55875), for instance in `C-c C-h' in
a buffer with no `C-c' commands.
2022-06-10 11:39:51 +02:00
Lars Ingebrigtsen
f0cd91067d Improve `C-h b' output for remapped commands.
* lisp/help.el (describe-map): Include the bindings of the
remapped commands (bug#14084).

This will result in output like this, instead of just listing the
remapped commands:

<remap> <display-buffer>                ido-display-buffer
C-x 4 C-o                               display-buffer
<remap> <display-buffer-other-frame>    ido-display-buffer-other-frame
C-x 5 C-o                               display-buffer-other-frame
<remap> <insert-buffer>                 ido-insert-buffer
C-x x i                                 insert-buffer
<remap> <kill-buffer>                   ido-kill-buffer
C-x k                                   kill-buffer
<remap> <switch-to-buffer>              ido-switch-buffer
C-x b                                   switch-to-buffer
<remap> <switch-to-buffer-other-frame>  ido-switch-buffer-other-frame
C-x 5 b                                 switch-to-buffer-other-frame
<remap> <switch-to-buffer-other-window> ido-switch-buffer-other-window
C-x 4 b                                 switch-to-buffer-other-window
2022-06-09 16:41:03 +02:00
Lars Ingebrigtsen
d036891967 Fix the final divergent single quote usages in doc strings
* lisp/view.el (view-mode-map):
* lisp/repeat.el (repeat-is-really-this-command):
* lisp/help.el (substitute-command-keys):
* lisp/electric.el (electric-quote-mode):
* lisp/cedet/srecode/texi.el (srecode-texi-texify-docstring):
* lisp/cedet/semantic/sort.el
(semantic-orphaned-member-metaparent-type): Audit usages of single
quotes in doc strings.
2022-05-24 18:48:50 +02:00
Lars Ingebrigtsen
334fa0c91d Restore `with-help-window' return code
* lisp/help.el (help--window-setup): Return the correct thing.
2022-05-14 04:13:56 +02:00
Lars Ingebrigtsen
bd464297bd Don't overwrite variables set by callback in help--window-setup
* lisp/help.el (help--window-setup): Initialize the buffer in the
correct order to avoid resetting variables set by the callback.
2022-05-13 17:14:36 +02:00
Lars Ingebrigtsen
cd87a5c7a1 Don't clear out local variables in `with-help-window'
* lisp/help-mode.el (help-mode-setup): Declare obsolete.
(help-mode-finish): Ditto.

* lisp/help.el (with-help-window): Don't be a wrapper around
`with-temp-buffer-window', because that made the macro big and
difficult to understand.
(help--window-setup): Implement the relevant bits from
`with-temp-buffer-window'.  Also don't clear out local variables,
because that makes things like `text-scale-mode' not work (bug#25979).
2022-05-13 17:14:36 +02:00
Lars Ingebrigtsen
ebfec5c119 Allow substitute-command-keys to include menus in \{...} output
* doc/lispref/help.texi (Keys in Documentation): Document it.
* lisp/help.el (substitute-command-keys): Add an argument to
include menus in the \{...-map} output (bug#24236).
2022-05-13 15:54:16 +02:00
Stefan Kangas
2fba71cf1f Fix handling double-click-time nil or t
* lisp/mouse.el (mouse-double-click-time): New function to always
return a number for `double-click-time'.
* lisp/emulation/viper-mous.el (viper-multiclick-timeout):
* lisp/foldout.el (foldout-mouse-swallow-events):
* lisp/help.el (help--read-key-sequence):
* lisp/org/org-mouse.el (org-mouse-show-context-menu): Use
'mouse-double-click-time' instead of 'double-click-time'.
* src/keyboard.c (syms_of_keyboard): Mention
'mouse-double-click-time' in doc string of 'double-click-time'.
* test/lisp/mouse-tests.el (mouse-test-mouse-double-click-time):
New test.
2022-05-02 12:03:08 +02:00
Lars Ingebrigtsen
97badaab79 Allow reusing the *Help* window with i'/s/ commands
* doc/emacs/help.texi (Help): Document it.

* lisp/help-mode.el (help-function-def--button-function): Use it.
* lisp/help-mode.el (help-goto-info): Use it.

* lisp/help.el (help-window-select): Mention it.
(help-window-keep-selected): New user option (bug#9054).

* lisp/info-look.el (info-lookup-symbol):
(info-lookup): Allow keeping the same window.
2022-05-02 11:30:52 +02:00
Stefan Monnier
4dba7c31a2 Use advice--cd*r where applicable
* lisp/emacs-lisp/bytecomp.el (byte-compile--function-signature):
* lisp/emacs-lisp/advice.el (ad-get-orig-definition):
* lisp/help.el (help-function-arglist): Use `advice--cd*r`.
2022-04-26 17:36:13 -04:00
Lars Ingebrigtsen
d5f2305187 Clean up view-emacs-news code
* lisp/help.el (view-emacs-news): Remove workaround after fixing
mode: cookie error.
2022-04-18 11:53:59 +02:00
Lars Ingebrigtsen
b49cca7012 Make :filters run in the correct buffer in describe-buffer-bindings
* lisp/help.el (describe-map-tree): Take an optional buffer parameter.
(describe-map): Ditto, and use it to run `lookup-key' in the
correct buffer.  This fixes problems of filters being run in the
wrong buffer (bug#39149).

* src/keymap.c (Fdescribe_buffer_bindings): Pass in BUFFER to
describe-map-tree.
2022-04-17 18:06:26 +02:00
Lars Ingebrigtsen
1a339d6ba5 Don't leave `C-h N' in a text-mode derived mode
* lisp/help.el (view-emacs-news): Use emacs-news-view-mode.
* lisp/textmodes/emacs-news-mode.el (emacs-news-view-mode): Split
into own mode to avoid confusion.
2022-04-16 19:42:33 +02:00
Lars Ingebrigtsen
5a59059b24 Add a new mode for editing and viewing the Emacs NEWS file
* etc/NEWS (mode): Use emacs-news-mode.
* lisp/help.el (view-emacs-news): Use emacs-news-mode.

* lisp/textmodes/emacs-news-mode.el: New mode for editing and
viewing the Emacs NEWS file.
2022-04-16 15:42:10 +02:00
Stefan Monnier
06ea82e4e3 Remove some early-bootstrap dependencies for advice
The dependencies between `advice`, cl-generic`, `bytecomp`, `cl-lib`,
`simple`, `help`, ... were becoming unmanageable.
Break the reliance on `advice` (which includes making sure the
compiler is not needed during the early bootstrap).

* lisp/simple.el (pre-redisplay-function): Set without using `add-function`.

* lisp/loadup.el (advice, simple): Move to after `cl-generic`.

* lisp/help.el (command-error-function): Set without using `add-function`.
(help-command-error-confusable-suggestions): Explicitly call
`command-error-default-function` instead.

* lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p): Don't
optimize during early-bootstrap.

* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Tiny simplification.
(cl-defmethod): Label the obsolescence warning as it should.
(cl--generic-compiler): New variable.
(cl--generic-get-dispatcher): Use it.
(cl--generic-prefill-dispatchers): Make freshly made dispatchers.
2022-03-17 19:07:59 -04:00
Lars Ingebrigtsen
55bcad776d Fix byte-code button in help--describe-command
* lisp/help.el (help--describe-command): Fix byte-code button
(bug#24235).
2022-03-15 12:44:50 +01:00
Stefan Kangas
1de7382b57 Merge from origin/emacs-28
e77fc8262a Update to Org 9.5.2-22-g33543d
9bce4b67f1 ; * lisp/help.el (with-help-window): Doc fix.  (Bug#54170)
558b03a958 Add explicit '--no-heading' for ripgrep
2022-02-28 06:33:06 +01:00