Correct conversion of strings to tree-sitter query syntax
The treesitter query syntax for string literals differs from that of
Elisp so we cannot just use the Lisp printer (bug#64017).
* src/treesit.c (treesit_query_string_string): New function.
(Ftreesit_pattern_expand): Use it.
* test/src/treesit-tests.el (treesit-query-api): Add test case.
Tony Zorman [Sat, 3 Jun 2023 12:23:19 +0000 (14:23 +0200)]
eshell-next-prompt: More precisely navigate to the prompt (bug#63748)
* lisp/eshell/em-prompt.el (eshell-next-prompt): Navigate to the
current prompt more accurately by using text properties instead of
going to the beginning of the line. This is important for multiline
prompts, as they don't necessarily start at the beginning of the
current line.
* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test--with-multiline):
Execute a given body with a multiline prompt.
(em-prompt-test/next-previous-prompt-with):
(em-prompt-test/forward-backward-matching-input-with):
Helper functions for code reuse.
(em-prompt-test/forward-backward-matching-input):
(em-prompt-test/next-previous-prompt):
Rewrite in terms of the appropriate helper functions.
(em-prompt-test/next-previous-prompt-multiline):
(em-prompt-test/forward-backward-matching-input-multiline):
Add multiline variants of existing tests.
Eli Zaretskii [Thu, 15 Jun 2023 07:08:55 +0000 (10:08 +0300)]
Fix subscripts in the Calc manual
* doc/misc/calc.texi (Musical Notes): Use @sub instead of TeX-only
'_' notation. For the details, see the discussion in
https://lists.gnu.org/archive/html/emacs-devel/2023-06/msg00096.html.
Handle point not at EOB in minibuffer-choose-completion
Without this change, only the minibuffer contents before point are
cleared when a completion is chosen, which results in stray text when
point is in the middle of the minibuffer.
After this change, we heuristically decide either to clear the whole
buffer or only part of it, taking into account the location of point.
* lisp/minibuffer.el (minibuffer-completion-help): Use point when
calculating completion-base-affixes. (Bug#62700)
* doc/lispref/positions.texi (List Motion): Incorporate more
accurate description of treesit-defun-type-regexp from
'(elisp) Tree-sitter Major Modes', replacing that duplicate
entry (bug#64018).
* doc/lispref/parsing.texi (Parsing Program Source)
(Language Grammar, Using Parser, Retrieving Nodes)
(Accessing Node Information, Pattern Matching, Multiple Languages):
(Tree-sitter Major Modes):
* doc/lispref/modes.texi (Parser-based Font Lock): Improve wording,
grammar, punctuation, and markup. Fix typos.
(Parser-based Indentation): Ditto. Document indent rule presets
field-is, catch-all, nth-sibling, grand-parent, and
great-grand-parent.
Move quoted lambda funarg check and expand coverage
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Move check for incorrectly quoted lambda arguments from here...
* lisp/emacs-lisp/bytecomp.el (byte-compile-form):
... to here, which should provide more detection opportunities.
Expand the set of functions for which this check is performed, now
also for some keyword arguments.
Robert Pluim [Mon, 5 Jun 2023 09:57:03 +0000 (11:57 +0200)]
Don't feed the awk scripts into themselves
* admin/unidata/Makefile.in (${unidir}/charscript.el,
${unidir}/emoji-zwj.el): Define variables for the required sources and
pass those to awk instead of $^, since the latter includes the awk
script itself.
F. Jason Park [Sat, 10 Jun 2023 06:34:58 +0000 (23:34 -0700)]
Define missing groups for ERC modules
* lisp/erc/erc-imenu.el (erc-imenu): Define group even though there
aren't any associated faces or user options because `imenu' is a
global module, and `define-erc-module' calls `define-minor-mode',
which needs a group for its mode variable. This should have been
handled by bug#60954 but wasn't.
* lisp/erc/erc-sound.el (erc-sound): Move group definition above
module definition.
* lisp/erc/erc-spelling.el (erc-spelling): Define group.
F. Jason Park [Fri, 9 Jun 2023 06:38:05 +0000 (23:38 -0700)]
Revert "Add hook to regain nickname in ERC"
This reverts commit 8c0c98268440b27a77faf30738dfd72c909bb33f. The
functionality it introduced is likely being migrated to a
"regain"-specific local module to live in the library erc-services.el
alongside the existing `services' module. Its scope will be expanded
to address common "regain" cases requiring NickServ. This commit is
being reverted to prevent any confusion that might arise from users
encountering the old interface while the new one is being hashed out
on the tracker.
F. Jason Park [Sat, 10 Jun 2023 07:17:44 +0000 (00:17 -0700)]
Don't insert prompt input before markers in ERC
* etc/ERC-NEWS: Update entry in 5.6 section announcing a persistent
prompt.
* lisp/erc/erc-dcc.el (erc-dcc-chat-setup): Use helper
`erc--initialize-markers' to set up prompt.
* lisp/erc/erc.el (erc--initialize-markers): Change
`erc-insert-marker' type to t. Do this to spare modules that want to
remember the current message location from resorting to workarounds,
like leaving a marker one char before the end of a message, which is
not foolproof.
(erc--refresh-prompt): Temporarily change type of `erc-insert-marker'
when inserting prompt.
(erc-display-line-1): Insert incoming message normally instead of
forcing before markers, thus respecting markers left by third parties.
Strictly speaking, this is a breaking change.
(erc-display-msg): Insert normally instead of calling
`insert-before-markers', which was a regression introduced by 05f6fdb9
"Preserve ERC prompt and its bounding markers".
* test/lisp/erc/erc-dcc-tests.el
(erc-dcc-tests--dcc-handle-ctcp-send,
erc-dcc-tests--erc-dcc-do-GET-command): Use helper to initialize
prompt and markers.
* test/lisp/erc/erc-networks-tests.el
(erc-networks--ensure-announced,
erc-networks--rename-server-buffer--existing--reuse,
erc-networks--rename-server-buffer--existing--noreuse,
erc-networks--rename-server-buffer--reconnecting,
erc-networks--rename-server-buffer--id,
erc-networks--rename-server-buffer--existing--live,
erc-networks--rename-server-buffer--local-match,
erc-networks--rename-server-buffer--local-nomatch): Use helper to
initialize prompt and bounding markers.
* test/lisp/erc/erc-stamp-tests.el (erc-stamp-tests--insert-right):
Use `erc--initialize-markers' for setting up prompt.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Adjust assertions
for expected prompt content. (Bug#60936)
F. Jason Park [Mon, 5 Jun 2023 10:49:44 +0000 (03:49 -0700)]
Cement ordering of essential hook members in ERC
* etc/ERC-NEWS: Add new section explaining the pinning of certain hook
members owned by built-in modules to fixed depths.
* lisp/erc/erc-button.el (erc-button-mode, erc-button-enable): Change
hook depth for `erc-button-add-buttons' from 90 to 30.
* lisp/erc/erc-fill.el (erc-fill-mode, erc-fill-enable): Change hook
depth for `erc-fill' from 0 to 40.
* lisp/erc/erc-match.el (erc-match-mode, erc-match-enable): Change
hook depth for `erc-match-message' from 90 to 60.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Change
hook depth for `erc-add-timestamp' from 90 to 50.
* test/lisp/erc/erc-tests.el
(erc-tests--assert-printed-in-subprocess): Add fixture for testing a
form printed from a subprocess.
(erc--find-mode, erc--essential-hook-ordering): Use helper in existing
and new tests, respectively. (Bug#60936)
F. Jason Park [Mon, 5 Jun 2023 09:35:53 +0000 (02:35 -0700)]
Measure stamps pixel-wise with erc-fill-wrap
* lisp/erc/erc-fill.el (erc-fill-wrap-mode, erc-fill-wrap-enable):
Change "how" for advice applied to `erc-stamp--insert-date-function'
from `:filter-args' to `:after'.
(erc-fill--wrap-stamp-insert-prefixed-date): Change signature to
conform to `:after'-style advice. Use `buffer-text-pixel-size' when
desired and available for generating display spec.
(erc-fill-wrap): Remove confusing comment. Don't apply text props to
newlines because there's no obvious use case for inheriting these.
* lisp/erc/erc.el (erc-send-action, erc-display-msg): Add
`erc-command' property (as "PRIVMSG") to inserted message, sans
newline, so that all inserted messages in an ERC buffer contain this
property.
* test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update data.
* test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update data.
* test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld: Update.
* test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld: Update.
* test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld: Update.
* test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld: Update.
* test/lisp/erc/resources/fill/snapshots/spacing-01-mono.eld: Update.
(Bug#60936)
F. Jason Park [Mon, 19 Dec 2022 03:01:40 +0000 (19:01 -0800)]
Allow ERC modules to extend erc-nick-popup-alist
* etc/ERC-NEWS: Mention changes to `erc-button-alist' and superficial
changes to `erc-nick-popup-alist'.
* lisp/erc/erc-button.el (erc-nick-popup-alist): Change type to prefer
associating strings with functions instead of arbitrary sexps.
(erc-button-cmd-KICK, erc-button-cmd-MSG): New functions to serve as
interrogative wrappers for `erc-cmd-KICK' and `erc-cmd-MSG' in
`erc-nick-popup-alist'. The first also fixes a bug in which all but
the first token of a given "reason" would be omitted from the
":trailing" portion of an outgoing "KICK" message.
(erc-button--nick-popup-alist): New variable to help built-in modules
expose special actions to `erc-nick-popup' without touching
`erc-nick-popup-alist'.
(erc-nick-popup): Present members from both `erc--nick-popup-alist'
and `erc-nick-popup-alist' to the invoking user. Accommodate
functions as well as arbitrary sexps. (bug#63569)
F. Jason Park [Fri, 2 Jun 2023 05:07:03 +0000 (22:07 -0700)]
Deprecate nicknames entry in erc-button-alist
* lisp/erc/erc-button.el (erc-button-mode, erc-button-enable,
erc-button-disable): Restore running `erc-button-setup' on
`erc-mode-hook' and also do so immediately in all ERC buffers.
Do this instead of calling `erc-button--check-nicknames-entry.
(erc-button-buttonize-nicks): Mention that this option's value must be
non-nil for all but the most basic client functionality.
(erc-button-alist): Remove `nicknames' entry entirely. Describe
deprecation, replacement behavior, and available escape hatches in doc
string. Update and improve custom type definition, in particular, by
including long supported but never mentioned variants for the "REGEXP"
field.
(erc-button-keys-added): Deprecate because unused and misleading: keys
are bound during module init and remain so while module is enabled.
(erc-button--has-nickname-entry): New variable to indicate whether to
follow legacy code path when a `nicknames' entry exists in
`erc-button-alist'.
(erc-button-setup): Rewrite to provide warnings about deprecated
values for `erc-button-alist'.
(erc-button-nickname-callback-function): Add escape hatch for those
needing a custom callback for what was the default `nickname' entry in
`erc-button-alist'.
(erc-button-add-buttons): Always run `erc-button-add-nickname-buttons'
unless `erc-button--has-nickname-entry' is non-nil.
(erc-button--maybe-warn-arbitrary-sexp, erc-button--extract-form):
Rename former to latter and abstain from emitting a warning.
(erc-button--check-nicknames-entry): Remove unused function.
(erc-button-add-nickname-buttons): Defer to `erc-button--extract-form'
for determining value of third FORM slot of entry.
(erc-button-add-buttons-1): Call renamed version of
`erc-button--maybe-warn-arbitrary-sexp'. (Bug#60933)
F. Jason Park [Fri, 2 Jun 2023 05:07:03 +0000 (22:07 -0700)]
Add alias erc-buffer-do for erc-buffer-filter
* lisp/erc/erc-goodies.el (erc-scrolltobottom-enable,
erc-scrolltobottom-mode): Prefer `erc-buffer-do' to
`erc-buffer-filter'.
(erc-move-to-prompt-mode, erc-move-to-prompt-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-imenu.el (erc-imenu-mode, erc-imenu-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-match.el (erc-match-enable, erc-match-mode): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc.el (erc-buffer-filter): Improve doc string.
(erc-buffer-do): Add alias for new code to prefer when calling
`erc-buffer-filter' for effect. Do this because continually having to
refer back to the doc strings and implementations of the latter as
well as `erc-buffer-p', `erc-buffer-list', and co. is unproductive.
(erc-buffer-list): Use `always' as fallback predicate.
F. Jason Park [Fri, 2 Jun 2023 06:18:56 +0000 (23:18 -0700)]
Prefer emacs-news-mode in etc/ERC-NEWS
* etc/ERC-NEWS: Remove `outline' from prop line and prefer
`emacs-news-mode' in local variables list.
* lisp/erc/erc.el (erc-news): Overwrite cached file and ask before
re-fetching.
Michael Albinus [Sun, 11 Jun 2023 18:33:34 +0000 (20:33 +0200)]
Fix tramp-sshfs
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-exists-p): New defun.
(tramp-fuse-mount-timeout): Move up.
(tramp-fuse-mount-point): Use `tramp-fuse-mount-timeout'.
(tramp-fuse-unmount): Flush "mount-point" file property.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-fuse-handle-file-exists-p'.
* test/lisp/net/tramp-tests.el (all): Use function read syntax
where appropriate.
(tramp-test39-detect-external-change): Let-bind
`read-from-minibuffer' instead of `yes-or-no-p'.
Eli Zaretskii [Sun, 11 Jun 2023 06:15:01 +0000 (09:15 +0300)]
Fix tex-mode display-buffer issues
* lisp/window.el (display-tex-shell-buffer-action): New defcustom.
* lisp/textmodes/tex-mode.el (tex-display-shell)
(tex-cmd-doc-view, tex-recenter-output-buffer): Use it.
(Bug#63956)
Morgan Smith [Tue, 6 Jun 2023 19:02:57 +0000 (15:02 -0400)]
Add test for when 'completion-auto-help' is 'visible'
* test/lisp/minibuffer-tests.el (completion-auto-help-test): Add
test for when 'completion-auto-help' is 'visible'. Also test
for successful completion message. (Bug#63913)
Daniel Martín [Sat, 10 Jun 2023 10:36:53 +0000 (12:36 +0200)]
Mention indent-rigidly in the Emacs manual
* doc/emacs/indent.texi (Indentation Commands): Rewrite the first
sentence of 'C-x TAB' to mention the command that it executes, and
without using passive voice. (Bug#63997)
Eli Zaretskii [Sat, 10 Jun 2023 10:42:43 +0000 (06:42 -0400)]
Merge from origin/emacs-29
0d8b69e0ad3 Don't ding when completion succeeded f11e2d36999 ; * admin/git-bisect-start: Update failing commits 9855a3ea744 ; * src/xdisp.c (redisplay_tool_bar): Fix a typo in a com... f4ee696b887 Improve documentation of color-related functions 90eadc3e234 Revert "* package.el (package--get-activatable-pkg): Pref... 65f355ea0a3 ; Update my mail address a3a69ec2342 Fix connection-local user options handling (bug#63300) 240803cc3e1 Document 'startup-redirect-eln-cache' 026afb22984 ; * etc/PROBLEMS: Entry about crashes due to anti-virus (... bcc222251e1 Fix `emacs-lisp-native-compile-and-load' for C-h f (bug#5... 07c8211ca30 Add 'infer' as a keyword to typescript-ts-mode (bug#63880) dd2d8ff2f5c ; * etc/NEWS: Mention the issue with PGTK on WSL (bug#633... fa8135f8916 Revert changes to the order in which package descs are lo... 27fcfa2c0a7 ; * etc/NEWS: Improve instructions for grammar libraries. 2a84ab905c8 Handle point in last file-name component in minibuffer co... 05f25238b7b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 4bc043ff45d Avoid asking redundant question in emacsbug.el 2eadf328d05 * test/infra/Dockerfile.emba (emacs-base): Don't install ... 583ba1db7ee typescript-ts-mode: Add a rule for function_signature
Morgan Smith [Mon, 5 Jun 2023 17:34:59 +0000 (13:34 -0400)]
Don't ding when completion succeeded
* lisp/minibuffer.el (minibuffer-completion-help): Ensure 'ding'
is not called on a successful completion. Ensure 'ding' is not
called on a failure if 'completion-fail-discreetly' is set.
Also change "No completions" to "No match" as that is what is
used elsewhere. (Bug#63913)
The Pyright language server issues very heavy file watching requests,
which sometimes exceed the OS limit. Most of these file watches are
useless, but Pyright insists on issuing them.
What's more, for some (absurd?) reason, Pyright issues two file
watching requests for the _same_ directories, only to then almost
immediately ask to undo the effects of one of these requests.
This change to Eglot makes it so that if a single server requests to
watch a specific directory twice, only one file watch object is used.
Suggested by: https://github.com/thejeffphil
* lisp/progmodes/eglot.el (eglot-lsp-server): Change structure of
file-watches field.
(eglot--on-shutdown): Adapt to new structure.
(eglot-register-capability): Rework.
(eglot-unregister-capability): Rework.
This reverts commit fb87d5008e21d1bc03547c1edf2280fb4cb8311e.
It caused problems when new versions of packages are installed
without deleting old versions. (Bug#63757)
Michael Albinus [Thu, 8 Jun 2023 07:59:06 +0000 (09:59 +0200)]
Fix connection-local user options handling (bug#63300)
* lisp/files-x.el (connection-local-set-profiles)
(connection-local-set-profile-variables): Avoid saving the changed
user option to file unless triggered explicitly by user. (Bug#63300)
Po Lu [Tue, 6 Jun 2023 13:00:44 +0000 (21:00 +0800)]
Fix problems resulting from modification of the undo list
* doc/lispref/text.texi (Atomic Changes): Describe what not to
do inside an atomic change group.
* lisp/elec-pair.el (electric-pair-inhibit-if-helps-balance):
Don't call `delete-char'; that edits the undo list by removing
boundary markers.
* lisp/subr.el (atomic-change-group, prepare-change-group): Warn
against modifying the undo list inside.
Eshel Yaron [Sun, 4 Jun 2023 16:41:20 +0000 (19:41 +0300)]
Avoid header line with some empty non-nil formats
Allow the value of 'header-line-format' to indicate that no header
line should be displayed when it trivially yields 'nil', even if it is
not plain 'nil'. Previously, any non-nil 'header-line-format'
resulted in a (possibly empty) header line. This change adds some
flexibility by also taking a non-nil value of 'header-line-format' to
mean that no header line should be displayed if it's a list whose
'car' is a symbol and either that symbol is ':eval' and the second
list element evaluates to 'nil', or the symbol's value as a variable
is 'nil' or void.
(Bug#63825)
* src/xdisp.c (safe_eval_inhibit_quit): New function.
* src/lisp.h (safe_eval_inhibit_quit): Declare it.
* src/window.c (null_header_line_format): New function.
(window_wants_header_line): Use it.
* doc/lispref/modes.texi (Header Line): Update to reflect new
conditions for displaying a window's header line.
* etc/NEWS: Announce updated treatment of 'header-line-format'.
Sean Whitton [Tue, 6 Jun 2023 11:15:25 +0000 (12:15 +0100)]
eval-command-interactive-spec: Shorten code
* lisp/emacs-lisp/subr-x.el (eval-command-interactive-spec): Don't
reimplement checking for an 'interactive-form symbol property.
`interactive-form' already does this. Thanks to Stefan Monnier.
Andrea Corallo [Tue, 6 Jun 2023 09:27:13 +0000 (11:27 +0200)]
Fix `emacs-lisp-native-compile-and-load' for C-h f (bug#58314)
* lisp/emacs-lisp/comp.el (comp-write-bytecode-file): New function
spilling code from `batch-byte+native-compile'.
(batch-byte+native-compile): Make use of.
* lisp/progmodes/elisp-mode.el
(emacs-lisp-native-compile-and-load): Produce the elc file and ask
to have it loaded.
Eli Zaretskii [Mon, 5 Jun 2023 12:57:05 +0000 (15:57 +0300)]
Fix bug with point-adjustment after M-x COMMAND
* src/keyboard.c (command_loop_1): Preserve 'last_point_position'
across command execution, to avoid bugs in
'adjust_point_for_property' if the command invokes
'recursive-edit'. Reported by Mats Lidell <matsl@gnu.org>.
Michael Albinus [Mon, 5 Jun 2023 11:29:21 +0000 (13:29 +0200)]
Adapt emba integration
* test/infra/Dockerfile.emba (emacs-tree-sitter):
Use "/root/.emacs.d/tree-sitter" instead of "/usr/local/lib/tree-sitter".
* test/infra/gitlab-ci.yml (.job-template): Run "/bin/bash -xvc".
(test-eglot): Revert last change, it doesn't work yet.
(test-tree-sitter): Set TEST_HOME instead of LD_LIBRARY_PATH.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Optimise closed-over values in closure creation like any other, which
can lead to stack variables being eliminated.
Revert changes to the order in which package descs are loaded
* lisp/emacs-lisp/package.el (package-load-all-descriptors): Remove
NOSORT argument to 'directory-files', reverting back to the behaviour
as of Emacs 28. (Bug#63757)
Andrea Corallo [Tue, 30 May 2023 13:30:11 +0000 (15:30 +0200)]
Print know function types in C-h f
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Improve comment.
(comp-funciton-type-spec): New function.
* lisp/help-fns.el (help-fns--signature): Update to make use of
`comp-funciton-type-spec'.
Spencer Baugh [Sat, 3 Jun 2023 00:57:32 +0000 (20:57 -0400)]
Handle point in last file-name component in minibuffer completion
This is a followup to commit e338a8ac41d4a9fd798dda90275abe75ac071335
(Handle point not at EOB in minibuffer-choose-completion).
That commit added a heuristic, but the heuristic was insufficient:
It still had the original wrong behavior when completing the last
file-name component (i.e., the completion category is 'file' and
there's no slash after point). This patch makes the heuristic
cover that case as well.
* lisp/minibuffer.el (minibuffer-next-completion)
(minibuffer-choose-completion): If in file completion and there's no
slash after point, clear what's after point when we complete.
(Bug#62700)