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.
Stefan Kangas [Sun, 24 Nov 2024 10:27:19 +0000 (11:27 +0100)]
Delete obsolete section in admin/notes/repo
* admin/notes/repo: Delete section "How to merge changes from emacs-24
to master", which is documented in admin/notes/git-workflow. Also
delete out-of-date autoload advice.
Joost Kremers [Mon, 11 Nov 2024 22:38:49 +0000 (23:38 +0100)]
Improve documentation for 'while-let'
* doc/lispref/control.texi (Conditionals): Reorganise describing
what's overlapping between the macros (and between the macros
and let*), and then improve the documentation for 'while-let'.
Yuan Fu [Sun, 24 Nov 2024 05:39:40 +0000 (21:39 -0800)]
Remove mention of treesit-defun-prefer-top-level (bug#74474)
treesit-defun-prefer-top-level is removed before Emacs 29
released and was replaced by treesit-defun-tactic. These
statements that set it doesn't do anything other than introduce
confusion, so we should remove them.
Eli Zaretskii [Sun, 24 Nov 2024 09:27:00 +0000 (11:27 +0200)]
Fix user options for listing and marking diary files
* lisp/calendar/diary-lib.el (diary-nongregorian-listing-hook)
(diary-nongregorian-marking-hook): Add Chinese functions to the
list of variable's options. (Bug#74498)
Juri Linkov [Sat, 23 Nov 2024 18:27:39 +0000 (20:27 +0200)]
; Improve example of display-buffer-alist category in ELisp Reference
* doc/lispref/windows.texi (Choosing Window): Use 'add-to-list'
and add an example how to override display-buffer-alist entries
such as 'inhibit-same-window' by matching the window
using the 'category' condition (bug#74457).
Juri Linkov [Wed, 27 Nov 2024 07:39:19 +0000 (09:39 +0200)]
* test/lisp/repeat-tests.el: Improve using new key mnemonics (bug#74140).
(repeat-tests-repeat-map): Use :repeat keywords with :enter and :exit
for 'defvar-keymap'.
(with-repeat-mode): Add new arg 'map' to defmacro.
(repeat-tests-check-key, repeat-tests-exit-key)
(repeat-tests-keep-prefix): Use new key mnemonics.
(repeat-tests-exit-command): New test.
(repeat-tests-bind-keys): New test for 'bind-keys' from 'use-package'.
Dmitry Gutov [Wed, 27 Nov 2024 01:43:22 +0000 (03:43 +0200)]
Make Xref commands follow 'display-buffer' customizations
* lisp/progmodes/xref.el (xref--show-pos-in-buf): Append
'(category . xref-jump)' to display-buffer action argument, when
the target window or frame is not made explicit by the command.
(xref--switch-to-buffer): New function (bug#74361).
Do the switch through 'pop-to-buffer' and use the new category.
(xref-go-back, xref-go-forward, xref-pop-to-location): Use it.
* etc/NEWS: Describe the change.
* test/lisp/simple-tests.el (simple-tests--undo-apply): New test.
(simple-tests--undo-equiv-table): Adjust test so it's not influenced by
previous operation.
Jim Porter [Fri, 1 Nov 2024 20:11:47 +0000 (13:11 -0700)]
Remove 'eshell-escape-arg'
Eshell no longer needs this function, since all command parsing is
performed first, with special syntax annotated with text properties as
needed, as opposed to marking literal text with a property (bug#54486).
* lisp/eshell/em-pred.el (eshell-modifier-alist): Make "q" modifier
obsolete.
(eshell-modifier-help-string): Remove mention of "q".
Stefan Monnier [Sun, 24 Nov 2024 03:05:33 +0000 (22:05 -0500)]
(dir-locals-collect-variables): Don't autoload if not needed (bug#74349)
While dir-local settings for `c-mode` may require (auto)loading `cc-mode.el`
to get all the `safe-local-variable` properties, they may not. So before
(auto)loading that file, make sure we don't already have all the
`safe-local-variable` properties we need.
* lisp/files.el (dir-locals--load-mode-if-needed): New function.
(hack-one-local-variable): Don't inf-loop if `eval` calls a major mode.
(dir-locals-collect-variables): Use `dir-locals--load-mode-if-needed`.
Rust ts: fontify as type the possible suffix of number literals
* lisp/progmodes/rust-ts-mode.el
(rust-ts-mode--fontify-number-literal): Perform the improved
fontification of numbers. (Bug#73877)
* test/lisp/progmodes/rust-ts-mode-tests.el:
* test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs:
* test/lisp/progmodes/rust-ts-mode-resources/font-lock-number.rs:
Add tests for the new optional fontification of the possible type
suffix of numbers.
Sean Devlin [Mon, 28 Oct 2024 14:34:48 +0000 (10:34 -0400)]
Use prefix argument in 'package-install-selected-packages'
* lisp/emacs-lisp/package.el (package-install-selected-packages):
When invoked with a prefix argument, skip user confirmation when
installing packages.
* etc/NEWS: Announce the prefix argument usage. (Bug#73932)
Sean Devlin [Mon, 21 Oct 2024 15:28:06 +0000 (11:28 -0400)]
Add noconfirm to 'package-autoremove'
* lisp/emacs-lisp/package.el (package-autoremove):
Add optional argument NOCONFIRM to skip user confirmation when removing
packages.
* etc/NEWS: Announce the new argument. (Bug#73932)
Eli Zaretskii [Thu, 21 Nov 2024 09:47:07 +0000 (11:47 +0200)]
; More accurate documentation of 'set-mark-command'
* doc/emacs/mark.texi (Setting Mark, Global Mark Ring): Explain
that activating an existing mark doesn't set a new mark, and
doesn't push the mark onto the global mark ring. (Bug#74438)
Eli Zaretskii [Thu, 21 Nov 2024 07:43:34 +0000 (09:43 +0200)]
Fix overriding 'c-ts-mode' by 'c-mode'
* lisp/progmodes/c-ts-mode.el: Remove all c- and c++-mode
associations from 'major-mode-remap-defaults' before installing
entries that remap to 'c-ts-mode' and 'c++-ts-mode'. (Bug#74339)