Po Lu [Mon, 17 Feb 2025 08:46:48 +0000 (16:46 +0800)]
Adapt query-replace and lazy highlighting to text conversion
* lisp/isearch.el (isearch-lazy-highlight-new-loop): Rather call
redisplay to guarantee a valid window-start than sit-for, to
account for cases where this function is called from an
after-change-function bound to a special input event quickly
followed by another event that does not modify the buffer.
* lisp/progmodes/prog-mode.el (treesit-node-at): Declare
function before references.
* lisp/replace.el (perform-replace): When querying, suppress
text conversion around the input loop.
Martin Rudalics [Mon, 17 Feb 2025 08:29:37 +0000 (09:29 +0100)]
When ignoring parameters let 'split-window' split root window (Bug#76317)
This fixes a behavior introduced by the fix of Bug#73527 that splits the
main window when the caller asks for splitting the root window.
* lisp/window.el (window--make-major-side-window): Bind
'ignore-window-parameters' to t so 'split-window' won't mess
with the WINDOW argument when it specifies the root window.
(split-window): If 'ignore-window-parameters' is non-nil, don't
try to split the main window instead of the root window.
Sean Whitton [Mon, 17 Feb 2025 07:40:38 +0000 (15:40 +0800)]
vc-revert-file: Support reverting directories
* lisp/vc/vc.el (vc-revert-file): Support reverting directories
by calling vc-responsible-backend instead of vc-backend when
FILE is a directory (bug#37310, bug#43464). Based on an
approach by Dmitry Gutov <dmitry@gutov.dev>.
(vc-rename-file): Add a FIXME to support reverting directories.
* etc/NEWS: Document the new functionality.
Vincenzo Pupillo [Fri, 14 Feb 2025 17:38:51 +0000 (18:38 +0100)]
Add mhtml-ts-mode.
New major-mode alternative to mhtml-mode, based on treesitter, for
editing files containing html, javascript and css.
* etc/NEWS: Mention the new mode and new functions.
* lisp/textmodes/mhtml-ts-mode.el: New file.
* lisp/progmodes/js.el
(js--treesit-thing-settings): New variable.
(js--treesit-font-lock-feature-list); New variable.
(js--treesit-simple-imenu-settings): New variable.
(js--treesit-defun-type-regexp): New variable.
(js--treesit-jsdoc-comment-regexp): New variable.
(js-ts-mode): Use of new variables instead of direct assignment of
values.
* lisp/textmodes/css-mode.el
(css-mode--menu): New variable.
(css-mode-map): Use new variable.
(css--treesit-font-lock-feature-list): New variable.
(css--treesit-simple-imenu-settings): New variable.
(css--treesit-defun-type-regexp): New variable.
(cs-ts-mode): Use of new variables instead of direct assignment of
values.
* lisp/textmodes/html-ts-mode.el
(html-ts-mode--treesit-things-settings): New variable.
(html-ts-mode--treesit-font-lock-feature-list): New variable.
(html-ts-mode--treesit-simple-imenu-settings): New variable.
(html-ts-mode--treesit-defun-type-regexp): New variable.
(html-ts-mode): Use of new variables instead of direct assignment of
values.
* lisp/treesit.el
(treesit-merge-font-lock-feature-list): New fuction.
(treesit-replace-font-lock-feature-settings): New fuction.
(treesit-modify-indent-rules): New function.
Stefan Kangas [Sun, 16 Feb 2025 23:52:45 +0000 (00:52 +0100)]
New functions oddp and evenp
* lisp/emacs-lisp/cl-lib.el (cl-oddp, cl-evenp): Move from here...
* lisp/subr.el (oddp, evenp): ...to here. Make old names into
aliases, documented as deprecated. Add type declarations.
* lisp/obsolete/cl.el: Don't alias oddp and evenp.
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-oddp)
(cl-lib-test-evenp): Move tests from here...
* test/lisp/subr-tests.el (subr-test-oddp, subr-test-evenp): ...to here.
* lisp/emacs-lisp/shortdoc.el (number): Add oddp and evenp.
(map): Prefer oddp and evenp to cl-oddp and cl-evenp.
* doc/lispref/numbers.texi (Predicates on Numbers): Document above new
functions oddp and evenp.
* doc/misc/cl.texi (Predicates on Numbers): Delete cl-oddp and cl-evenp.
(Other Clauses): Prefer oddp to cl-oddp.
Stefan Kangas [Mon, 17 Feb 2025 00:53:55 +0000 (01:53 +0100)]
Remove some details on which files are loaded from cl.texi
* doc/misc/cl.texi (Naming Conventions): Remove section listing
functions that do not cause other files than cl-lib.el to be loaded.
It lacks practical relevance to the user, and is a hostage to changing
implementation details.
David Ponce [Sat, 8 Feb 2025 12:55:16 +0000 (13:55 +0100)]
Fix DOM printing
Fix DOM printing when an attribute value is not a string, which is
often the case in SVG DOM. Don't print attributes without a
value. Refresh the list of HTML boolean attributes.
* lisp/dom.el (dom--html-boolean-attribute-p): New function.
(dom-print): Use it. Convert attribute value to string before to
call `url-insert-entities-in-string'. Don't print attribute
without a value. Compute indentation column outside of loop and
call `indent-line-to' to indent line. (Bug#5928)
* test/lisp/dom-tests.el (dom-tests-print-svg)
(dom-tests-print-html-boolean): New tests.
kobarity [Mon, 13 Jan 2025 13:38:42 +0000 (22:38 +0900)]
Fix string end search in python-nav-end-of-statement
* lisp/progmodes/python.el (python-nav-end-of-statement):
Change to look for string delimiter characters and check
syntax, instead of looking for string-delimiter syntax.
* test/lisp/progmodes/python-tests.el
(python-nav-end-of-statement-5): New test. (Bug#75387)
Eli Zaretskii [Sat, 15 Feb 2025 11:15:36 +0000 (13:15 +0200)]
Prevent buffer overflow in line-numbering code
* src/xdisp.c (maybe_produce_line_number): Limit the value of
'display-line-numbers-width' to what can be shown in the window,
and set dimension of the lnum_buf[] accordingly. (Bug#75969)
* lisp/vc/smerge-mode.el (smerge-refine-regions): Cover each region
with an overlay.
(smerge-refine-exchange-point): Use it to detect more reliably that
we're not inside a refined region.
Stefan Monnier [Sat, 15 Feb 2025 04:28:52 +0000 (23:28 -0500)]
(smerge-refine-exchange-point): New command
* lisp/vc/smerge-mode.el (smerge--refine-highlight-change):
Allow empty region and always create an overlay. Also, remember any
adjustment we applied the overlay's boundaries.
(smerge-refine-regions): Always create two overlays per hunk and "connect"
them via `smerge--refine-other`.
(smerge-refine-exchange-point): New command.
Stefan Kangas [Fri, 14 Feb 2025 21:46:07 +0000 (22:46 +0100)]
Inline important-return-value declarations in cl-lib.el
These declarations are now properly added to 'cl-lib.el' itself, or to
'cl-loaddefs.el'. This means that they will now correctly show up
immediately when loading 'cl-lib.el', instead of only after 'cl-macs.el'
is pulled in by an autoload. C.f. Bug#76247.
I did not considered worth reproducing everywhere the list saying which
functions among the below belong to these two categories:
1. Functions that are side-effect-free except for the behavior of
functions passed as argument.
2. Functions that mutate and return a list.
AFAIU, this is not actionable with our current byte-compiler, i.e. we
can't add any extra declarations based on it. However, if the list
should be needed at some point, for example due to improvements in the
compiler, this commit will be where to find it. In the worst case, and
with more work, it's also deducible from the source code itself.
The docstrings of cl-nintersection and cl-nset-difference have been
inconsistent with their manual entries since the beginning of
emacs.git history (bug#76017). This patch settles on the weaker and
thus backward-compatible requirement that only their first argument
be safe to mutate.
* lisp/emacs-lisp/bytecomp.el: Include only first argument in
mutates-arguments property.
* lisp/emacs-lisp/cl-seq.el (cl-nintersection, cl-nset-difference):
Make docstring consistent with manual in that the second argument is
not modified.
* test/lisp/emacs-lisp/cl-seq-tests.el (cl-nintersection-test)
(cl-nset-difference-test): Simplify.
(cl-nset-difference): Pass fresh list as second argument, otherwise
destructive modifications to it could go undetected.
Pip Cet [Fri, 14 Feb 2025 13:49:49 +0000 (13:49 +0000)]
Avoid crashes in lread.c when invalid characters are read
* src/lread.c (readchar): Don't crash for non-fixnum return values.
(read_filtered_event): Don't crash for invalid symbol properties.
(Fread_char):
(Fread_char_exclusive):
(character_name_to_code): Check 'FIXNUMP' before using 'XFIXNUM'.
(read_char_escape): Crash on invalid Lisp-supplied data when
ENABLE_CHECKING; otherwise, signal an error.
Stefan Kangas [Thu, 13 Feb 2025 02:02:39 +0000 (03:02 +0100)]
; Change "virus" to "malicious" in lispref
* doc/lispref/functions.texi (Function Safety): Replace 'virus' with
'malicious' to ensure broader accuracy, as 'malicious' encompasses all
harmful software types.
Yuan Fu [Fri, 14 Feb 2025 05:49:55 +0000 (21:49 -0800)]
Use a heuristic to support method chaining in c-ts-common
Test for "." at the beginning of a line to detect chained method.
* lisp/progmodes/c-ts-common.el:
(c-ts-common--standalone-predicate): New function.
(c-ts-common--standalone-parent):
(c-ts-common--prev-standalone-sibling): Use the new heuristic.
Yuan Fu [Fri, 14 Feb 2025 04:47:23 +0000 (20:47 -0800)]
Allow treesit-simple-indent-standalone-predicate to return anchor
* lisp/treesit.el:
(treesit-simple-indent-standalone-predicate): Allow it to return
an anchor instead of t.
(treesit-simple-indent-presets): Supports number.
* lisp/progmodes/c-ts-common.el:
(c-ts-common--standalone-parent):
(c-ts-common--prev-standalone-sibling): Supports number.
* lisp/treesit.el:
(treesit-simple-indent-standalone-predicate): New variable.
(treesit-simple-indent-presets): Use the predicate.
(treesit-simple-indent-presets): Update docstring.
* lisp/progmodes/c-ts-common.el:
(c-ts-common--standalone-parent):
(c-ts-common--prev-standalone-sibling): Use the predicate if
non-nil. Also, handle method chaining by default.
* doc/lispref/modes.texi (Parser-based Indentation): Add
documentation.
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-extra-test-isqrt):
Expect most specific error type.
(cl-extra-test-nreconc): Pass fresh list as first argument to
cl-nreconc. The usual mutates-arguments warning was not emitted,
possibly in relation to bug#74920 and cl-nreconc being proclaimed
inline.
(cl-extra-test-list-length): Simplify using nconc.
None of the tests using the macro cl-seq--with-side-effects were
being evaluated (since bug#24264), and other tests were not robust
against destructive operations or optimizations (since bug#24264 and
bug#75633). For further discussion, see:
https://lists.gnu.org/r/emacs-devel/2025-02/msg00053.html
* test/lisp/emacs-lisp/cl-seq-tests.el: Fit first line within 80
columns. Remove empty Commentary section.
(cl-union-test-00): Use bug#N reference in place of URL.
(cl-seq-test-bug24264): Ditto. Use nconc in place of append.
(cl-seq--test-list, cl-seq--test-list2, cl-seq--with-side-effects):
Remove.
(cl-seq-tests--relet*): New convenience macro replacing the need for
cl-seq--with-side-effects.
(cl-seq-fill-test, cl-seq-replace-test, cl-seq-delete-test): Use
cl-seq-tests--relet* to actually evaluate tests. Avoid mutating
quoted literals.
(cl-seq-nsubstitute-test): Ditto. Actually call cl-nsubstitute, not
cl-substitute. Avoid comparing mutated argument to itself; compare
to its original copy instead. Avoid calling cl-position on list
that is being mutated in :if predicate; use original copy instead.
(cl-seq-remove-test, cl-remove-if-not-test, cl-delete-if-not-test)
(cl-delete-duplicates-test, cl-seq-remove-duplicates-test)
(cl-seq-substitute-test, cl-seq-substitute-if-test)
(cl-seq-position-test, cl-count-if-test, cl-count-if-not-test)
(cl-member-if-test, cl-member-if-not-test, cl-assoc-if-test)
(cl-assoc-if-not-test, cl-rassoc-if-test, cl-subsetp-test):
Simplify.
(cl-remove-if-test, cl-seq-substitute-if-not-test, cl-find-if-test)
(cl-find-if-not-test, cl-position-if-test, cl-member-test)
(cl-assoc-test, cl-rassoc-test): Quote function symbols, not
lambdas.
(cl-delete-if-test): Use cl-seq-tests--relet*. Check result of
cl-delete-if to avoid relying on its side effects, and to pacify
byte-compiler warning.
(cl-seq-mismatch-test): Avoid 'easy to misread' hidden argument.
(cl-seq-search-test): Break long line.
(cl-sort-test, cl-stable-sort-test, cl-merge-test): Avoid mutating
quoted literals.
(cl-intersection-test): Avoid comparing eql-ity of string literals.
(cl-nintersection-test, cl-nset-difference-test)
(cl-nset-exclusive-or-test): Avoid mutating quoted literals. Don't
compare initial and final values of arguments, since they may have
been mutated.
(cl-set-difference-test, cl-set-exclusive-or-test): Use fresh
arguments to check for absence of mutation.
Robert Pluim [Fri, 17 Jan 2025 15:44:08 +0000 (16:44 +0100)]
Support non-ascii SMTP user and password strings
The user and more importantly the password used when
authenticating SMTP connections MUST be encoded in utf-8, and
'base64-encode-string' requires unibyte strings, so call
'encode-coding-string' on them before base64 encoding them in
case they are multibyte strings.
This applies to the CRAM-MD5, LOGIN, and PLAIN auth methods.
XOAUTH2 access tokens are specified to contain only characters
in the range #x20-#x7E (SPC through ~), so utf-8 encoding is not
necessary.
See RFC 4616 and RFC 4954 (or their later updates).
* lisp/mail/smtpmail.el (smtpmail-try-auth-method): Encode user
and password using utf-8 before base64 encoding.
Robert Pluim [Thu, 22 Aug 2024 16:49:12 +0000 (18:49 +0200)]
Teach gnus/message about international Re: variants
* lisp/mail/mail-utils.el (mail-re-regexps): New defcustom,
contains the components used to construct 'rmail-re-abbrevs' and
'message-subject-re-regexp'.
* lisp/gnus/message.el (message-subject-re-regexp): Derive from
'mail-re-regexps'.
(message-strip-subject-re): Make the match case-insensitive.
* lisp/mail/rmail.el (rmail-re-abbrevs): Derive from
'mail-re-regexps'. Update 'rmail-reply-regexp' when it changes.
(rmail-reply-regexp): Set to nil, 'rmail-re-abbrevs' will set
it.
Björn Bidar [Fri, 31 Jan 2025 01:24:44 +0000 (03:24 +0200)]
Bind sieve-refresh-scriptlist to 'g' in sieve-mode
* lisp/net/sieve.el (sieve-manage-mode-map): Bind
`sieve-refersh-scriptlist' to 'g' to refresh buffer.
(sieve-refresh-scriptlist): Highlight in docstring that the function
updates the current sieve buffer. (Bug#75956)
* doc/misc/sieve.texi (Managing Sieve): Document new keybinding and the
existing `sieve-refresh-scriptlist` function.