Paul Eggert [Tue, 10 Dec 2024 19:19:25 +0000 (11:19 -0800)]
Use builtin-expect directly
* admin/merge-gnulib (GNULIB_MODULES): Add builtin-expect,
since src/lisp.h now uses __builtin_expect directly,
which we should no longer rely on it being pulled in as
a dependency of some other Gnulib module that we use.
Stephen Gildea [Tue, 10 Dec 2024 17:09:39 +0000 (09:09 -0800)]
time-stamp: properly abbreviate instead of truncating names
* lisp/time-stamp (time-stamp-string-preprocess): Stop truncating month
and weekday name strings; it didn't internationalize well.
Some historical conversions, previously accepted quietly, now warn.
(time-stamp-format): Recommend the simpler formats implemented in 2019.
* test/lisp/time-stamp-tests.el: Update tests and comments to match.
Revert commit 83e4559664 (2022-07-01), which was working around the
former confusion between truncation and abbreviation.
F. Jason Park [Sun, 8 Dec 2024 00:52:12 +0000 (16:52 -0800)]
; Mark failing tests in erc-scenarios-match.el as :unstable
* test/lisp/erc/erc-scenarios-match.el
(erc-scenarios-match--stamp-both-invisible-fill-static)
(erc-scenarios-match--stamp-both-invisible-fill-static--nooffset):
Tag as :unstable for a `system-type' of `berkeley-unix'.
(Bug#74722)
F. Jason Park [Sat, 7 Dec 2024 03:09:04 +0000 (19:09 -0800)]
; Slightly improve test case for erc-parse-modes
* lisp/erc/erc.el (erc--merge-local-modes): Look for a symbol's
`erc-module' property before examining its name.
* test/lisp/erc/erc-tests.el (erc-parse-modes): Expand case to cover
alternating plus and minus mode changes.
Stefan Kangas [Mon, 9 Dec 2024 03:01:44 +0000 (04:01 +0100)]
Make setting tex-dvi-view-command to an sexp obsolete
This is more in line with how we generally handle user options for
commands to call. Later, we can get rid of the 'eval' call.
* lisp/textmodes/tex-mode.el (tex-view): Warn if tex-dvi-view-command is
set to an sexp instead of a string; say that this use is obsolete.
(tex-dvi-view-command): Change the default value to a string. Update
docstring to reflect the above obsoletion.
Yuan Fu [Sun, 8 Dec 2024 07:18:53 +0000 (23:18 -0800)]
Allow treesit--font-lock-level-setter to be an alist
* lisp/treesit.el (treesit-font-lock-level): Allow the
value to be an alist mapping major modes to font lock levels.
(treesit--font-lock-level-setter): Rewrite.
(treesit--compute-font-lock-level): New function.
(treesit-font-lock-recompute-features): Use new function.
* doc/lispref/modes.texi (Parser-based Font Lock): Minor fix.
john muhl [Mon, 2 Dec 2024 15:20:01 +0000 (09:20 -0600)]
Don't restrict 'lua-ts-send-file' to 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts-send-file): Remove
restriction on interactive use. Unlike related send-* commands
it can be useful to send a file to the Lua interpreter outside of
a 'lua-ts-mode' buffer. (Bug#74705)
Manuel Giraud [Mon, 2 Dec 2024 14:11:52 +0000 (15:11 +0100)]
Fix the version of librsvg API change
* src/image.c (init_svg_functions, svg_load_image): The first
official version that introduces
'rsvg_handle_get_pixbuf_and_error' is 2.59.0 not 2.58.0.
(Bug#74606)
Michael Albinus [Fri, 6 Dec 2024 10:56:05 +0000 (11:56 +0100)]
Better handling of "%" in Tramp user or host names
* lisp/net/tramp.el (tramp-format-spec): New defun.
(tramp-dissect-file-name, tramp-compute-multi-hops)
(tramp-expand-args):
* lisp/net/tramp-cmds.el (tramp-default-rename-file): Use it.
Yuan Fu [Tue, 3 Dec 2024 04:47:38 +0000 (20:47 -0800)]
Validate font-lock rules when setting up tree-sitter major mode
When tree-sitter grammar make breaking changes, major modes
breaks completely: no highlighting is shown. This new function
will run in treesit-major-mode-setup, validate each
font-lock features, and disable the ones that are not compatible
with the new grammar, so that the rest of the features still
work. It also displays a warning explaining the situation,
which looks like this:
Warning (treesit-font-lock-rules-mismatch): Emacs cannot
compile every font-lock rules because a mismatch between the
grammar and the rules. This is most likely due to a
mismatch between the font-lock rules defined by the major
mode and the tree-sitter grammar.
This error can be fixed by either downgrading the
grammar (tree-sitter-c) on your system, or upgrading the
major mode package. The following are the temporarily
disabled features:
- `preprocessor' for c.
* lisp/treesit.el (treesit-validate-font-lock-rules): New function.
(treesit-major-mode-setup): Validate font-lock rules.
Yuan Fu [Tue, 3 Dec 2024 04:14:55 +0000 (20:14 -0800)]
Make treesit-query-compile compile compiled-query eagerly
* src/treesit.c (treesit_ensure_query_compiled_signal): Extrat
out into a function.
(Ftreesit_query_compile): If EAGER is non-nil and QUERY is a
lazily compiled query, compile it eagerily.
Yuan Fu [Tue, 3 Dec 2024 01:23:08 +0000 (17:23 -0800)]
Make tree-sitter-explorer support selecting local parser
Now treesit-explore-mode will prompt the user to select a parser
to explore, rather than a language. It'll also include the
local parsers at point for selection.
* lisp/treesit.el (treesit--explorer-language): Change to
treesit--explorer-parser.
(treesit--explorer--nodes-to-highlight):
(treesit--explorer-refresh): Change to use parser.
(treesit--explorer-generate-parser-alist): New function.
(treesit-explorer-switch-parser): New command.
(treesit-explore-mode): Use switch-parser to setup.
* doc/lispref/parsing.texi (Language Grammar): Mention
treesit-explorer-switch-parser.
* lisp/textmodes/tex-mode.el (tex-display-shell)
(tex-recenter-output-buffer):
Replace 'display-tex-shell-buffer-action' with a list of
'display-buffer-in-previous-window' and '(category . tex-shell)'.
Robert Pluim [Tue, 3 Dec 2024 14:41:48 +0000 (15:41 +0100)]
Improve docstrings of functions for moving to message headers
* lisp/gnus/message.el (message-goto-to, message-goto-from,
message-goto-subject, message-goto-cc, message-goto-bcc,
message-goto-fcc, message-goto-reply-to,
message-goto-newsgroups, message-goto-distribution,
message-goto-followup-to, message-goto-mail-followup-to,
message-goto-keywords, message-goto-summary): Mention that these
will insert an empty header if the header is not found.
(message-position-on-field): Explain that this inserts an empty
header if the header is missing, and that insertion is done
after the headers mentioned in AFTERS.
Yuan Fu [Mon, 2 Dec 2024 00:40:05 +0000 (16:40 -0800)]
Standardize and promote c-ts-mode's custom matcher and anchor
Specifically, standalone-parent and prev-sibling. The c-ts-mode
custom version skips labels and proproc directives.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--standalone-parent-skip-preproc): Rename to
c-ts-mode--standalone-parent, and make it skip labels too.
(c-ts-mode--preproc-indent-rules): Rename standalone-parent and
prev-sibling.
(c-ts-mode--label-indent-rules): Use custom standalone-parent
and prev-sibling.
Yuan Fu [Sun, 1 Dec 2024 07:49:14 +0000 (23:49 -0800)]
Add more c-ts-mode indent tests
* test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: Fix
label test.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add some
test, make other tests harder.
Yuan Fu [Sun, 1 Dec 2024 08:15:08 +0000 (00:15 -0800)]
Use new baseline indent rule in c-ts-mode
Rework the indent rules in c-ts-mode using
c-ts-common-baseline-indent-rule. Also reworked internal
functions for setting indent styles to make it simpler and (more
importantly) more readable. Now there's a single function,
c-ts-mode--simple-indent-rules, that returns a value that can go
straight to treesit-simple-indent-rules.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--indent-style-setter): Simplify.
(c-ts-mode--get-indent-style): Remove function.
(c-ts-mode--prompt-for-style): Use a hard-coded list of styles.
This is a tiny downgrade from the computed lists but is
acceptable.
(c-ts-mode-set-style): Use c-ts-mode--simple-indent-rules.
(c-ts-mode--standalone-grandparent): Docstring change.
(c-ts-mode--for-loop-indent-rule): New function.
(c-ts-mode--preproc-indent-rules): New variable. Copied from
old indent rules and added some new rule.
(c-ts-mode--macro-heuristic-rules):
(c-ts-mode--simple-indent-rules):
(c-ts-mode--parenthesized-expression-indent-rule):
(c-ts-mode--label-indent-rules): New functions.
(c-ts-mode):
(c++-ts-mode): Use c-ts-mode--simple-indent-rules.
Yuan Fu [Sat, 30 Nov 2024 04:43:09 +0000 (20:43 -0800)]
Add baseline tree-sitter indent rule for C-like languages
I found a really good baseline indent rule that handles a wide
range of situations very well. Now major modes can just start
with this rule and add exceptions on top.
This is worth mentioning in the manual, but that'll be a large
change, and doesn't have to be included in this commit.
* lisp/progmodes/c-ts-common.el:
(c-ts-common-list-indent-style): New variable.
(c-ts-common--standalone-parent):
(c-ts-common--prev-standalone-sibling):
(c-ts-common-parent-ignore-preproc):
(c-ts-common-baseline-indent-rule): New function.
* lisp/treesit.el (treesit--indent-prev-line-node): New function.
(treesit-simple-indent-presets): Add new preset.
Yuan Fu [Fri, 29 Nov 2024 22:10:45 +0000 (14:10 -0800)]
Allow treesit-simple-indent's rule to be a single function
* lisp/treesit.el (treesit-simple-indent-rules): Allow the rule
to be a single function. Also replace cl-loop with dolist plus
catch-throw.
(treesit--indent-rules-optimize): Handle the case when a rule is
a function.
* doc/lispref/modes.texi (Parser-based Indentation): Update
manuel.
F. Jason Park [Mon, 25 Nov 2024 08:01:04 +0000 (00:01 -0800)]
Reserve erc-normalize-port for equality comparisons
* etc/ERC-NEWS: Add entry explaining changes to entry point 'erc-tls'
and library functions `erc-normalize-port' and `erc-compute-port'.
* lisp/erc/erc.el (erc-normalize-port): Map "ircu" to 6665 instead of
6667, and add related IANA service mappings. Return 0 for unknown
nonempty strings.
(erc-open): Pass `erc-session-port' through `erc-string-to-port' before
handing it to `erc-server-connect'. This prevents the network machinery
from ever seeing a numeric string, like "6667".
(erc-select-read-args): Since `erc-compute-port' no longer relies on
`erc-normalize-port', ensure its input is a number. Use
`erc-port-equal' instead of `eql'.
(erc-tls): Respect a configured non-nil `erc-port' option when the user
does not provide a :port keyword argument from Lisp code.
(erc-determine-parameters): Use `erc-compute-port' for initializing
`erc-session-port'.
(erc-compute-port): Don't pass the result through `erc-normalize-port',
which can convert it to an unintuitive form.
(erc--url-default-connect-function): Use `erc-compute-port' instead of
`erc-normalize-port'.
(erc-handle-irc-url): Use `erc-port-equal' for comparison.
* test/lisp/erc/erc-scenarios-auth-source.el
(erc-scenarios-common--auth-source): Allow tests to convey the automatic
port number to `erc-open' via `erc-port'.
(erc-scenarios-base-auth-source-server--dialed): Use `erc-port' option
instead of passing a :port parameter to entry-point command.
* test/lisp/erc/erc-tests.el (erc-normalize-port): New test.
(Bug#74516)
Trevor Arjeski [Sun, 24 Nov 2024 20:35:41 +0000 (23:35 +0300)]
Allow querying auth-source with port as string in ERC
* lisp/erc/erc.el (erc--auth-source-determine-params-defaults): Allow
arbitrary strings for `ers-session-port'. Previously, if a port/service
was any string other than "irc", the auth-source query would fail for a
seemingly unknown reason. Restricting the value to "irc" is unnecessary
since "irc" is already added to the list of ports, and
`make-network-process' already consults /etc/services for well-known
service names, like "ircs-u", etc. This change allows a user to (setopt
erc-port "1234"), intentionally or accidentally, while still being able
to use .authinfo for password management. (Bug#74516)
F. Jason Park [Sun, 24 Nov 2024 23:30:02 +0000 (15:30 -0800)]
Clear buffer-undo-list after sending input in ERC
* lisp/erc/erc.el (erc-insert-line): Assume `erc-insert-marker' points
somewhere.
(erc-send-current-line): Set `buffer-undo-list' to nil because it should
only record editing changes in the prompt area, which has just been
cleared. ERC did this via `erc-display-prompt' prior to 5.6, but it now
leaves the prompt alone by default.
* test/lisp/erc/erc-tests.el (erc-update-undo-list): New test.
(Bug#74518)
Alan Mackenzie [Sun, 1 Dec 2024 17:27:34 +0000 (17:27 +0000)]
CC Mode: Optimize scanning of heavily nested brace blocks
This should have fixed bug#74357.
* lisp/progmodes/cc-engine.el (c-laomib-cache): Change the
size of this cache from 4 to 50.
(c-laomib-get-cache, c-laomib-put-cache): Use assq, memq, and
ntake or butlast, rather than looping through the cache with a
cdr loop. No longer attempt to preserve the "largest" cache
element.
(c-looking-at-or-maybe-in-bracelist): Extend the range covered
by a c-laomib-cache element, rather than adding a second
element to the cache.
(c-no-bracelist-cache): A new cache for the use of
c-inside-bracelist-p, based on the c-parse-state cache.
(c-inside-bracelist-p): Use the new cache to call
c-looking-at-or-maybe-in-bracelist less often.
Manuel Giraud [Fri, 29 Nov 2024 15:35:47 +0000 (16:35 +0100)]
Fix exiting Emacs after saving a tutorial
* lisp/tutorial.el (tutorial--lang)
(tutorial--point-before-chkeys): Add both variables as
permanent-local, so that saving the tutorial to some file
doesn't kill these buffer-local variables. Otherwise, trying to
exit Emacs after saving the tutorial will signal an error,
because 'tutorial--lang' is nil. (Bug#74364)
Vincenzo Pupillo [Mon, 25 Nov 2024 10:06:02 +0000 (11:06 +0100)]
Support PHP 8.4 and more reliable indentation (bug#74525)
Added support for PHP 8.4 property hook. More reliable CSS and
Javascript syntax indentation when there are attributes in
<script> and <style>.
* lisp/progmodes/php-ts-mode.el:
(php-ts-mode--language-source-alist): Switch to the latest php
grammar.
(php-ts-mode--js-css-tag-bol): CSS and Javascript indentation is
now more more reliable in different formatting styles.
(php-ts-mode--test-property-hook-clause-p): New function that
tests property_hook support.
(php-ts-mode--font-lock-settings): Use the new function.
(php-ts-mode--colorize-css-value): The function now behaves
exactly like the one in css-ts-mode.
(php-ts-mode--feature-list): Changed the list to match
css-ts-mode.
Martin Rudalics [Thu, 28 Nov 2024 17:53:45 +0000 (18:53 +0100)]
Don't inadvertently reset frame scroll bar sizes (Bug#74435)
* src/frame.c (gui_set_scroll_bar_width)
(gui_set_scroll_bar_height): When the new size equals the old one
do not reset size to default size (Bug#74435).
Eli Zaretskii [Thu, 28 Nov 2024 14:55:26 +0000 (16:55 +0200)]
Allow to go back to using 'ruby-mode' after loading 'ruby-ts-mode'
* lisp/progmodes/ruby-ts-mode.el (major-mode-remap-defaults):
Remap 'ruby-mode' to 'ruby-ts-mode'. Add commentary.
* lisp/progmodes/ruby-mode.el (major-mode-remap-defaults): Remove
any remappings of ruby-mode'.
* lisp/progmodes/c-ts-mode.el: Fix a typo in a comment. (Bug#74339)
Michael Albinus [Thu, 28 Nov 2024 12:28:58 +0000 (13:28 +0100)]
Extend Tramp tests
* test/lisp/net/tramp-tests.el (tramp-test47-read-password)
(tramp-test47-read-otp-password, tramp-test47-read-fingerprint):
Use `tramp-default-remote-shell' and
`tramp-connection-properties'. Cleanup at the end.
(tramp-test47-read-security-key): New test.
Andrea Corallo [Wed, 27 Nov 2024 13:18:24 +0000 (14:18 +0100)]
* src/lisp.h (EQ): Improve generated code.
Outside compilation 'symbols_with_pos_enabled' is always false, so ask
the compiler to organize the most likely execution path in a sequential
fashion in order to favor run-time performance.