Paul Eggert [Wed, 2 Apr 2025 20:52:30 +0000 (13:52 -0700)]
Pacify gcc -Wclobbered in Freplace_region_contents
* src/editfns.c (Freplace_region_contents): Redo slightly to
pacify gcc -Wclobbered, by hoisting the eassume out of SCHARS and
into the caller later, where it’ll do more good anyway.
Stefan Monnier [Wed, 2 Apr 2025 19:05:02 +0000 (15:05 -0400)]
cl-macs.el: Fix minor merge snafu (bug#77348)
* lisp/emacs-lisp/cl-macs.el (cl-flet, cl-labels): Recover the changes
made in commit 476426168106 and accidentally undone by a later merge of
commit 63adf9dcf53a.
Eli Zaretskii [Wed, 2 Apr 2025 17:25:09 +0000 (20:25 +0300)]
Fix display of wide characters in display margins on TTY frames
* src/xdisp.c (display_line): Remove incomplete glyph sequence of
the last multi-column character, if not all of its glyphs fit in
the marginal area. (Bug#77452)
Eli Zaretskii [Wed, 2 Apr 2025 13:12:03 +0000 (16:12 +0300)]
More thorough fix for image slices on mode/header-line
* src/xdisp.c (note_mode_line_or_margin_highlight): Remove
correction of DX and DY due to image slices, as this is now done
in 'mode_line_string'.
* src/dispnew.c (mode_line_string): Make DX and DY account for
image slices. (Bug#77429)
Stefan Monnier [Tue, 1 Apr 2025 22:06:31 +0000 (18:06 -0400)]
(custom--standard-value-p): New function
* lisp/cus-edit.el (custom-variable-state)
(custom-variable-mark-to-reset-standard): Use `custom--standard-value-p`.
* lisp/custom.el (custom--standard-value-p): New function.
(customize-mark-to-save, custom-push-theme, enable-theme): Use it.
* lisp/help-fns.el (describe-variable): Use `custom--standard-value`.
Extracted from `customize-mark-to-save` by with `ignore-errors`
replaced by `with-demoted-errors`.
Stefan Kangas [Tue, 1 Apr 2025 19:25:33 +0000 (21:25 +0200)]
function-put: signal error with non-symbol
* lisp/subr.el (function-get): Signal an error if given a non-symbol
for consistency with 'get'.
* test/lisp/subr-tests.el (subr-butlast): Test for the above.
Juri Linkov [Tue, 1 Apr 2025 17:17:17 +0000 (20:17 +0300)]
New treesit generic mode 'liquid-generic-ts-mode' (bug#77255)
* lisp/treesit.el (treesit-replace-font-lock-feature-settings):
Check the query language in addition to checking the feature.
(treesit-font-lock-fontify-region): Use treesit-font-lock-setting-*
accessors.
* lisp/treesit-x.el (treesit-generic-mode-setup): Append new
font-lock rules to an existing treesit-font-lock-settings
possibly inherited from the parent.
(treesit-generic-mode-setup): Use treesit-merge-font-lock-feature-list
to merge with an existing feature list inherited from the parent.
(liquid-generic-ts-mode): New treesit generic mode.
(alpinejs-generic-ts-setup): New treesit generic setup.
Since vc-resolve-conflicts is referenced in backend files, which only
require vc at runtime, move it to vc-hooks to avoid a void
variable error. (Bug#3860)
Eli Zaretskii [Tue, 1 Apr 2025 15:40:59 +0000 (18:40 +0300)]
Fix :map property on sliced images on mode line and header line
* src/xdisp.c (note_mode_line_or_margin_highlight): Fix coordinates
for image slices wrt ':map' keyword when the image is on the mode
line or header line. (Bug#77429)
Vincenzo Pupillo [Mon, 31 Mar 2025 19:49:36 +0000 (21:49 +0200)]
Added a check to see if the 'speedbar-buffer' is still alive
Fix suggested by Rudi Schlatte <rudi@constantly.at>.
* lisp/speedbar.el (speedbar-frame-or-window): Added an additional check
to see if 'speedbar-buffer' is still alive (bug#77405).
Ikumi Keita [Fri, 28 Mar 2025 13:18:42 +0000 (22:18 +0900)]
Suppress error in non-file buffer
* lisp/textmodes/reftex.el (reftex--suppress-nonfile-error): New
variable.
(reftex-TeX-master-file): Don't signal error in non-file buffer.
(AUCTeX bug#76615)
Earl Hyatt [Thu, 13 Mar 2025 03:01:49 +0000 (23:01 -0400)]
Add cl-with-accessors
* lisp/emacs-lisp/cl-macs.el (cl-with-accessors): New macro.
* doc/misc/cl.texi (Structures): Mention the new macro.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-lib-struct-with-accessors):
New Test.
* etc/NEWS (New macro 'cl-with-accessors'.): Mention the macro.
This macro is useful when making repeated use of a structures accessor
functions, such as reading from a slot and then writing to a slot. It
is similar to 'with-slots' from EIEIO, but uses accessor functions
instead of slot names.
Juri Linkov [Mon, 31 Mar 2025 17:40:17 +0000 (20:40 +0300)]
Improve logic of tab handling when quitting windows (bug#71386)
* lisp/window.el (window-deletable-p): Add tab logic that returns
the symbol 'tab' for a set of predefined conditions.
(window--delete): Call 'tab-bar-close-tab' when 'window-deletable-p'
returns the symbol 'tab'.
(quit-restore-window): Remove tab logic and merge it with frame logic.
* test/lisp/tab-bar-tests.el (tab-bar-tests-close-other-tabs-default)
(tab-bar-tests-close-other-tabs-with-arg): Clean up tabs afterwards.
(tab-bar-tests-quit-restore-window): New test.
Eli Zaretskii [Mon, 31 Mar 2025 13:55:49 +0000 (16:55 +0300)]
Fix replace-region in japan-util.el
* lisp/language/japan-util.el (japanese-replace-region): Allow
STRING to be a character in addition to a string. Un-obsolete
it.
(japanese-katakana-region, japanese-hiragana-region)
(japanese-hankaku-region, japanese-zenkaku-region): Call
'japanese-replace-region' instead of 'replace-region-contents'.
(Bug#77397)
Pip Cet [Fri, 28 Mar 2025 02:33:19 +0000 (02:33 +0000)]
Respect narrowed buffers when parsing JSON (bug#77325)
* src/json.c (Fjson_insert): Simplify 'memcpy' argument.
(Fjson_parse_buffer): Only read to ZV, not all the way to Z.
* test/src/json-tests.el (with-all-gap-positions-in-temp-buffer):
New macro.
(json-parse-buffer/restricted): New test.
Eli Zaretskii [Sun, 30 Mar 2025 07:29:57 +0000 (10:29 +0300)]
Fix display of overlay arrow immediately after invisible text
* src/xdisp.c (overlay_arrow_at_row): Allow the overlay arrow's
marker position to be anywhere between the row's start and end
charpos. This keeps the overlay arrow on display even when the
preceding text is invisible. (Bug#54843)
Po Lu [Sun, 30 Mar 2025 02:24:45 +0000 (10:24 +0800)]
Don't obsolete the _command_ replace-buffer-contents
* lisp/subr.el (replace-buffer-contents): Don't obsolete
function. Its purpose is to serve as a command and such
obsoletion was unnecessary to begin with.
Stephen Gildea [Sat, 29 Mar 2025 23:48:58 +0000 (16:48 -0700)]
time-stamp source commentary: point to manual section
* lisp/time-stamp.el: Add an Info link in the commentary,
now that the manual has more to say.
* doc/emacs/files.texi (Time Stamps for One File): Expand one
consistent example.
Stefan Monnier [Fri, 28 Mar 2025 04:49:33 +0000 (00:49 -0400)]
Org: Use new `replace-region-contents`
* lisp/org/org-compat.el (org-replace-buffer-contents): Delete function.
(org-replace-region-contents): New function.
* lisp/org/org-src.el (org-edit-src-save, org-edit-src-exit): Use it.
Stefan Monnier [Fri, 28 Mar 2025 05:01:17 +0000 (01:01 -0400)]
Use `replace-region-contents` to replace insert+delete
* lisp/minibuffer.el (completion--replace):
* lisp/emacs-lisp/cl-lib.el (cl--set-buffer-substring):
* lisp/subr.el (replace-string-in-region):
Use `replace-region-contents` instead of insert+delete.
* lisp/help-fns.el (help-fns--signature):
Use `replace-region-contents` instead of `cl--set-buffer-substring`.
* lisp/language/japan-util.el (japanese-replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(japanese-katakana-region, japanese-hankaku-region):
Use `replace-region-contents` instead.
* lisp/progmodes/flymake-proc.el (flymake-proc--replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(flymake-proc--check-patch-master-file-buffer):
Use `replace-region-contents` instead.
Stefan Monnier [Fri, 28 Mar 2025 04:46:53 +0000 (00:46 -0400)]
(replace-region-contents): Improve and promote (bug#76313)
Swap the role of `replace-region-contents` and `replace-buffer-contents`,
so `replace-region-contents` is the main function, implemented in C,
and `replace-buffer-contents` is a mere wrapper (marked as obsolete).
Also remove the need to rely on narrowing and on describing the
new text as a function.
Finally, allow MAX-SECS==0 to require a cheap replacement, and
add an INHERIT argument.
* src/editfns.c: Include `coding.h`.
(Freplace_region_contents): Rename from `Freplace_buffer_contents`.
Change calling convention to that of `replace-region-contents`.
Add more options for the SOURCE argument. Add INHERIT argument.
Skip the costly algorithm if MAX-SECS is 0.
* src/insdel.c (replace_range): Allow NEW to be a buffer.
* lisp/subr.el (replace-buffer-contents): New implementation.
* lisp/emacs-lisp/subr-x.el (replace-region-contents): Delete.
* doc/lispref/text.texi (Replacing): Document new API for
`replace-region-contents`. Remove documentation of
`replace-buffer-contents`.
* test/src/editfns-tests.el (replace-buffer-contents-1)
(replace-buffer-contents-2, replace-buffer-contents-bug31837):
Use `replace-region-contents`.
(editfns--replace-region): Delete.
(editfns-tests--replace-region): Use `replace-region-contents`.
Adds tests for new types of SOURCE args.
Stefan Kangas [Sat, 29 Mar 2025 12:50:21 +0000 (13:50 +0100)]
Use 'hash-table-contains-p' in a few places
This replaces open coded versions of the common idiom
(not (eq (gethash key table 'missing) 'missing))
with
(hash-table-contains-p key table)
in files where we can rely on features in Emacs 31.
Stefan Kangas [Sat, 29 Mar 2025 13:59:26 +0000 (14:59 +0100)]
New function 'hash-table-contains-p'
This function tests whether a given key is present in a hash table.
Emacs Lisp has long lacked a standard way to do this, leading users to
write one of:
This idiom is error-prone (when 'missing' or 'nil' are valid values),
and it obscures intent. The new function avoids such pitfalls,
improves readability, and makes the intent explicit:
(hash-table-contains-p key table)
The name 'hash-table-contains-p' exists in other Lisp dialects (e.g.,
SRFI-125), and follows the precedent of 'seq-contains-p'. Other
alternatives considered include `hash-table-has-key-p` and
`hash-table-key-exists-p`, but none were clearly better.
This was previously discussed in 2018, and all comments were positive,
but the proposed patch (implementing it in C) was never pushed:
https://lists.gnu.org/r/emacs-devel/2018-02/msg00424.html
* lisp/subr.el (hash-table-contains-p): New function.
* lisp/emacs-lisp/shortdoc.el (hash-table):
* doc/lispref/hash.texi (Other Hash): Document the new function.
* test/lisp/subr-tests.el (hash-table-contains-p): New test.
Vincenzo Pupillo [Sat, 22 Mar 2025 11:30:30 +0000 (12:30 +0100)]
Fix compiler warnings in mhtml-ts-mode.el (bug#77017).
* lisp/textmodes/mhtml-ts-mode.el:
Added variable and function declarations to prevent compiler
warnings.
(mhtml-ts-mode): Require 'html-ts-mode' after checking that
the html parser is available.
Vincenzo Pupillo [Fri, 14 Mar 2025 20:11:22 +0000 (21:11 +0100)]
PHP should be in the PATH, either locally or remotely. (bug#76242).
* lisp/progmodes/php-ts-mode.el
(php-ts-mode-php-default-executable): Renamed from
'php-ts-mode-php-executable'.
(php-ts-mode--executable): New function that returns the absolute
filename of the PHP executable, local or remote, based on
'default-directory'.
(php-ts-mode--anchor-prev-sibling): Replaced 'when-let' with
“when-let*.”
(php-ts-mode--indent-defun): Replaced 'when-let' with
'when-let*'.
(php-ts-mode-run-php-webserver): Use the new function
(php-ts-mode-php-default-executable).
(run-php): Use the new function (php-ts-mode-php-default-executable).
This minor lets you automatically closing block comments after
typing `block-comment-start'. Thus, typing "/*" in c-mode and
its derivatives automatically inserts "*/". (Bug#77081)
* etc/NEWS: Add minor-mode item.
* lisp/electric.el
(electric-block-comment-post-self-insert-function): New function.
(electric-block-comment-mode): New minor mode definition.
Daniel Mendler [Sat, 22 Mar 2025 09:29:45 +0000 (10:29 +0100)]
New Eldoc function `eldoc-show-help-at-pt'
Show `help-at-pt' string via Eldoc as an alternative to the
`help-at-pt-display-when-idle' timer. The help-at-pt timer
competes with Eldoc for the echo area, such that the two
mechanisms do not work well together. Therefore when using
Eldoc, the setting `eldoc-help-at-pt' may be preferable.
* lisp/emacs-lisp/eldoc.el (eldoc-help-at-pt): New customization option.
(eldoc-show-help-at-pt): New Eldoc function.
(eldoc-documentation-functions): Register the new function.
* lisp/help-at-pt.el (help-at-pt-display-when-idle): Mention
`eldoc-help-at-pt' in the docstring.
* doc/emacs/help.texi: Document `eldoc-help-at-pt'.
* etc/NEWS: Announce the change. (Bug#77169)
Jens Schmidt [Sat, 8 Mar 2025 17:13:54 +0000 (18:13 +0100)]
Improve message handling on server stop
* lisp/server.el (server-stop): Use a clearer signal message if there is
an existing, external Emacs server.
(server-start): Use a different warning if one attempts to only
stop (and not restart) an external server.
(server-unload-function): Silently stop the server if unloading its
library. (Bug#76870)
Add major mode for highlighting npmrc files (Bug#77138)
* etc/NEWS: mention the new mode.
* lisp/textmodes/conf-mode.el (conf-npmrc-mode-syntax-table): New
variable.
* lisp/textmodes/conf-mode.el (conf-npmrc-mode): New major mode
derived from conf-mode for highlighting .npmrc files.
* lisp/files.el (auto-mode-alist): Associate the new mode with .npmrc
files.
Po Lu [Sat, 29 Mar 2025 06:45:38 +0000 (14:45 +0800)]
Do not redundantly dump constant forwarding objects
* src/pdumper.c (dump_fwd_int, dump_fwd_bool, dump_fwd_obj): Do
not redundantly dump constant forwarding descriptors; restrict
to dumping the objects being forwarded to.
(dump_fwd_buffer_obj): Copy from the dump file into bss rather
than load buffer forwarding descriptors from the dump file
itself.
(dump_fwd_kboard_obj): Delete function.
(dump_fwd): Don't return offset of dumped objects.
(dump_blv): Adjust correspondingly.
(dump_pre_dump_symbol): Improve documentation. Record offset of
forwarding objects in relation to `emacs_basis' rather than the
dump file.
(dump_symbol): Restore forwarding descriptors to their original
values as static variables in Emacs. This reduces the size of
dump files by an insignificant 2kb but facilitates certain kinds
of watchpoints on platforms where ASLR cannot be disabled, e.g.,
Android.
Stefan Kangas [Tue, 25 Mar 2025 22:16:11 +0000 (23:16 +0100)]
; Improve type specifier documentation
* doc/lispref/functions.texi (Declare Form): Clarify wording for
precision and consistency; note consequences of incorrect declarations.
* doc/lispref/objects.texi (Type Specifiers): Mention use by the native
compiler; tighten wording.
Stephen Gildea [Fri, 28 Mar 2025 14:04:03 +0000 (07:04 -0700)]
; Time Stamps doc: expand the explanation of the examples
* doc/emacs/files.texi (Time Stamps): Divide into three sections.
* doc/emacs/emacs.texi: Add new nodes to menu.
* lisp/time-stamp.el: Change reference to new node.
Michael Albinus [Thu, 27 Mar 2025 16:48:20 +0000 (17:48 +0100)]
Handle better changed default-directory in shell-command
* lisp/simple.el (shell-command): Kill buffer-local values of
`shell-file-name' and `shell-command-switch', there could be left
connection-local values. (Bug#76888)
Alan Mackenzie [Thu, 27 Mar 2025 10:24:48 +0000 (10:24 +0000)]
C++ Mode: Fix some indentation bugs. FIxes bug#19867
1. Fix closing paren aligning with trailing comment on line
with matching open paren.
2. Fix indentation of first identifier inside a comma separated
list aligning with the type rather than the subsequent
identifiers.
3. Fix lambda expressions inside a brace list aligning like a
single statement.
* lisp/progmodes/cc-align.el (c-lineup-arglist): Take into
account any preceding comments when lining up the arguments in
the arglist.
(c-lineup-arglist-intro-after-paren): Handle comments properly,
and don't line up the closing parenthesis with a trailing
comment on the first line.
(c-lineup-item-after-paren-at-boi): Also allow a paren to count
as being at BOI when it is preceded only by open parens on that
line.
(c-lineup-runin-statements, c-lineup-ObjC-method-call): Hanle
comments better.
* lisp/progmodes/cc-engine.el (c-forward-comments) Introduce an
optional limit parameter. Use this limit in calls from
cc-align.el and cc-mode.el.
(c-just-after-func-arglist-p): Handle the presence of a
protection keyword such as "public".
(c-at-bracelist-p): Renamed from c-inside-bracelist-p, after
dropping the accept-in-paren parameter, having removed its
functionality.
(c-looking-at-statement-block-1): New function, based on the
old c-looking-at-statement-block. Enhanced to handle C++
lambda expressions, and to return the symbol `maybe' when the
contents of a brace delimited block fail to determine whether
it is a statement block.
(c-looking-at-statement-block): Enhanced to examine the context
of a brace delimited block when the contents are ambiguous.
(c-looking-at-c++-lambda-expression): Check the character after
point is a < before calling c-forward-<>-arglist.
(c-add-stmt-syntax): Make the context more accurate by calling
c-looking-at-statement-block.
(c-guess-basic-syntax, CASE 5D.5): Replace the syntactic symbol
topmost-intro-cont with the new symbol class-field-cont,
additionally determining the position of the enclosing brace as
an extra anchor point.
(c-guess-basic-syntax, CASE 5V): New case for an identifier
following a type inside class braces.
(c-guess-basic-syntax, CASE 9): Use
c-looking-at-statement-block to detect a brace list more
accurately.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context):
Rename the call to c-inside-bracelist-p to c-at-bracelist-p.
* lisp/progmodes/cc-langs.el (c-protection-kwds): Add an entry
for java-mode.
(c-stmt-block-only-keywords-regexp): Prevent this regexp also
matching a character preceding the keyword.
* /lisp/progmodes/cc-mode.el (c-before-change-include-<>)
(c-after-change-include-<>): Use the new limit argument to
c-forward-comments.
* lisp/progmodes/cc-styles.el (c-style-alist, "gnu" and "java"
styles): Change the offset for arglist-close to
c-lineup-arglist-close-under-paren.
* lisp/progmodes/cc-vars.el (c-offsets-alist): Introduce the
new syntactic symbol class-field-cont, giving it default
offset +.
* doc/misc/cc-mode.texi (Syntactic Symbols, Class Symbols):
Document the new syntactic symbol class-field-cont.