Michael Albinus [Sun, 13 Jul 2025 13:48:54 +0000 (15:48 +0200)]
tramp-file-name-with-method can be set connection-local
* doc/misc/tramp.texi (Ad-hoc multi-hops):
tramp-file-name-with-method can be set connection-local.
* etc/NEWS: tramp-file-name-with-method can be set connection-local.
Presentational fixes and improvements.
* lisp/net/tramp-cmds.el (tramp-get-file-name-with-method): New defun.
(with-tramp-file-name-with-method, tramp-file-name-with-sudo): Use it.
(tramp-dired-find-file-with-sudo): Fix docstring.
Sean Whitton [Sun, 13 Jul 2025 11:50:22 +0000 (12:50 +0100)]
New global minor mode vc-auto-revert-mode
* lisp/vc/vc-hooks.el (auto-revert-mode): Declare.
(vc-auto-revert-mode): New global minor mode.
(vc-turn-on-auto-revert-mode-for-tracked-files): New function.
* lisp/vc/vc-dispatcher.el (auto-revert-mode)
(auto-revert-buffers): Declare.
(vc-resynch-window): Don't call vc-revert-buffer-internal when
auto-revert-mode will revert the buffer. Call
auto-revert-buffers to ensure that this reversion happens in a
timely manner.
* lisp/vc/vc.el (vc-register): Apply vc-auto-revert-mode to
buffers visiting newly registered files.
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
Improve the generated docstring.
* doc/emacs/vc1-xtra.texi (VC Auto-Reverting):
* etc/NEWS: Document the new minor mode.
Sean Whitton [Sun, 13 Jul 2025 11:30:43 +0000 (12:30 +0100)]
vc-register: Fix setting backup-inhibited
* lisp/vc/vc.el (vc-register): Delete unreachable code trying to
use 'buffer-file-name' as one of the file names. Properly set
'backup-inhibited' in any file-visiting buffers.
Sean Whitton [Fri, 11 Jul 2025 08:58:20 +0000 (09:58 +0100)]
VC: Fix displaying the async command buffer during async checkins
* lisp/vc/vc-dispatcher.el (vc--display-async-command-buffer):
New function, factored out of vc-do-async-command.
(vc-do-async-command): Use it.
(vc-finish-logentry): Bind vc--inhibit-async-window when running
the log operation, then call vc--display-async-command-buffer
again ourselves after performing other window changes.
Sean Whitton [Fri, 11 Jul 2025 08:30:19 +0000 (09:30 +0100)]
Apply vc-use-incoming-outgoing-prefixes to vc-dir-mode-map too
* lisp/vc/vc-dir.el (vc-use-incoming-outgoing-prefixes):
* lisp/vc/vc-hooks.el: Apply vc-use-incoming-outgoing-prefixes
to the corresponding bindings in vc-dir-mode-map, too.
Speed up low-level parts of the reader and refactor
Inspect the given 'readcharfun' source once, before using it, instead of
for each character read. This moves a bunch of branches away from the
critical path, with separate functions for different source types.
Replace some preprocessor macros with functions.
* src/lread.c (READCHAR, UNREAD, READCHAR_REPORT_MULTIBYTE)
(FROM_FILE_P): Remove; use corresponding functions instead.
All callers adapted.
(source_t): New struct that takes the place of the `readcharfun` and
`readbyte` arguments in many places.
(init_source)
(source_buffer_get, source_buffer_unget)
(source_marker_get, source_marker_unget)
(source_string_get, source_string_unget)
(source_file_get, source_file_unget)
(source_function_get, source_function_unget)
(from_file_p, unreadbyte_from_file):
New.
(readbyte_from_stdio): Replace `readbyte_from_file`.
(readchar, unreadchar): Rewrite.
(lisp_file_lexical_cookie, readevalloop, read_internal_start):
Create a source_t for use during reading. All signatures and functions
called adapted.
(read_char_escape): Remove check for an error that can no longer occur.
Juri Linkov [Thu, 10 Jul 2025 06:40:51 +0000 (09:40 +0300)]
Cache only the last string in 'tab-bar-format-align-right' (bug#78953)
* lisp/tab-bar.el (tab-bar--align-right-cache):
Rename from 'tab-bar--align-right-hash'.
(tab-bar-format-align-right): Use it to store
the string in the car, and the width in the cdr.
Yuan Fu [Fri, 23 May 2025 00:57:37 +0000 (17:57 -0700)]
Eldoc: Run eldoc-display-functions with original buffer (bug#78530)
Also bump eldoc version so Eglot can require the new version
later.
* lisp/emacs-lisp/eldoc.el (eldoc--invoke-strategy): Run the
hook with the original buffer as the current buffer. This way
we're certain that the buffer-local value of
'eldoc-display-functions' is used.
(eldoc-display-functions): Update docstring.
Pip Cet [Wed, 9 Jul 2025 15:16:07 +0000 (15:16 +0000)]
Call eieio--class-* accessors only on eieio classes (bug#78786)
* lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default):
(eieio-oset, eieio-oset-default): Don't look for class slots except in
eieio classes.
* test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
(eieio-test-defstruct-slot-value): New test.
Martin Rudalics [Wed, 9 Jul 2025 07:52:01 +0000 (09:52 +0200)]
Handle invalid frame_or_window slots in tty input events (Bug#78966)
* src/frame.c (make_terminal_frame): Initialize terminal's
top_frame slot if it has not been set up yet (Bug#78966).
* src/keyboard.c (kbd_buffer_get_event): Do not assume that the
event's frame_or_window slot always produces a valid frame
(Bug#78966).
(tty_read_avail_input): Try to make sure that the input event we
create has a valid frame_or_window slot (Bug#78966). Add assertion
to that purpose.
Yuan Fu [Wed, 9 Jul 2025 06:15:58 +0000 (23:15 -0700)]
Ditch the async range update in tree-sitter (bug#78402)
Right now in treesit-outline-search -> treesit-navigate-thing, a
freshly created tree-sitter node becomes outdated within the
function. I'm not sure _exactly_ how it happend, but it might
look like this: we first get a node from, say, html parser, then
get another node from, say, liquid parser. Creating the node
from liquid parser causes a reparse which updated the range of
the html parser, which rendered the html node outdated.
There're several problems with the current design, let's start
with the most obvious one: we add
treesit--font-lock-mark-ranges-to-fontify as a notifier of the
primar parser in treesit-major-mode-setup. Now, if a ts major
mode inherits another major mode, treesit-major-mode-setup will
be called twice, once in the parent mode and once in the child
node, and two parsers will have the notifier. But
treesit--font-lock-mark-ranges-to-fontify is designed to run
only once.
I believe this bug, together with some mysterious async
execution order, led to the problems we saw in the bug report.
My solution is to just make everything synchronous.
So I added treesit-parser-changed-regions, and modified
treesit--font-lock-mark-ranges-to-fontify to use it. Now we
don't need to add the notifier to the primary parser anymore.
I also applied the tree-sitter-outline change we discussed in
the bug report. (Change to treesit-outline-search, and remove
treesit--after-change.)
* lisp/treesit.el:
(treesit--font-lock-mark-ranges-to-fontify): Remove the unused
PARSER arg.
(treesit--pre-redisplay): Make use of
treesit-parser-changed-regions.
(treesit-outline-search): Call treesit--pre-redisplay in the
beginning.
(treesit--after-change): Remove function.
(treesit-major-mode-setup): Don't add notifier to primary parser.
Yuan Fu [Wed, 9 Jul 2025 06:14:20 +0000 (23:14 -0700)]
Add a synchronous way to get parser change ranges (bug#78402)
This commit only adds the new function, the fix for the bug is
in the next commit.
* doc/lispref/parsing.texi (Using Parser): Add docs.
* lisp/treesit.el (treesit): Add shortdoc.
* src/treesit.c (treesit_get_affected_ranges): New function
extracted from treesit_call_after_change_functions.
(treesit_call_after_change_functions): Extract out.
(treesit_ensure_parsed): Return affected regions.
(Ftreesit_parser_changed_regions): New function that returns the
affected regions.
Juri Linkov [Wed, 9 Jul 2025 06:28:05 +0000 (09:28 +0300)]
Fix tab-bar-format-align-right to not call tab-bar-format-global twice
* lisp/tab-bar.el (tab-bar-format-align-right): Add optional arg 'rest'
to handle it specially in 'tab-bar-format-list'. Use the value from 'rest'
instead of calling format functions twice by 'tab-bar-format-list'.
(tab-bar-format-list): When 'format-list' contains the item
'tab-bar-format-align-right', collect the rest of formatted items
and call 'tab-bar-format-align-right' explicitly with the collected
list (bug#78953).
Abstract the buffering in the reader with a struct and plain functions
instead of rather unhygienic preprocessor macros.
* src/lread.c (READ_AND_BUFFER, INVALID_SYNTAX_WITH_BUFFER):
Removed, replaced with...
(readbuf_t, readbuf_grow, add_char_to_buffer, read_and_buffer)
(invalid_syntax_with_buffer): ...these new functions and struct.
(read0): Use new code instead of old preprocessor macros.
Sean Whitton [Mon, 7 Jul 2025 14:44:34 +0000 (15:44 +0100)]
Resolve FIXME regarding running vc-checkin-hook
Running vc-checkin-hook needs to be delayed in the case of an
async checkin. As a quick fix we had been relying on the
backend checkin functions to run the hook in the async case.
This restores handling running the hook in generic code even for
the async case.
* lisp/vc/vc.el (vc-checkin): Always pass vc-checkin-hook to
vc-start-logentry. Return the result of calling the backend
'checkin-patch' or 'checkin' function to vc-finish-logentry.
* lisp/vc/vc-dispatcher.el (vc-finish-logentry): If the log
operation returns a cons of the form (async . #<process ...>),
use vc-exec-after to delay vc-resynch-buffer and hooks until the
async process completes. Approach suggested by Dmitry Gutov.
* lisp/vc/vc-git.el (vc-git-checkin):
* lisp/vc/vc-hg.el (vc-hg-checkin): For an async checkin, return
a cons (async . #<process ...>) containing the async checkin
process. No longer run vc-checkin-hook.
* lisp/vc/vc.el (with-vc-properties): Return the result of
evaluating FORM.
* lisp/vc/vc-dispatcher.el (vc-exec-after): Change to PROC's
buffer before calling vc-set-mode-line-busy-indicator.
Turn compiler macro defalias messages into warnings
* lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defalias):
Turn messages into warnings to make them more visible to the user and
provide a source location (bug#78792).
Jim Porter [Wed, 25 Jun 2025 05:50:22 +0000 (22:50 -0700)]
Use short revisions by default when navigating to revisions
* lisp/vc/vc-annotate.el (vc-annotate-revision-previous-to-line)
(vc-annotate-show-diff-revision-at-line-internal)
(vc-annotate-warp-revision): Let-bind 'vc-use-short-revision'
around calls to 'previous-revision' and 'next-revision'.
Jim Porter [Fri, 4 Jul 2025 23:23:45 +0000 (16:23 -0700)]
Show "readable" status in the EWW mode line
* lisp/net/eww.el (eww-display-html): Check whether a readable form of
the document exists; if not, don't set ':readable' to t.
(eww-readable): Check whether a readable form of the document exists; if
not, warn the user and don't add to history.
(eww-readable-dom): Return nil if no readable form exists.
(eww-mode): Check the ':readable' property of 'eww-data' to show
"readable" state in the mode line.
* test/lisp/net/eww-tests.el
(eww-test/readable/default-readable/non-readable-page): New test
(bug#78958).
Sean Whitton [Sun, 6 Jul 2025 12:43:24 +0000 (13:43 +0100)]
vc-checkin: Check whether the fileset or patches have changed
* lisp/vc/vc-dispatcher.el (vc-finish-logentry): Delay popping
to vc-parent-buffer until after calling the log operation.
That way if the log operation exits early, the current buffer
remains *vc-log*.
(vc-dir-marked-files, dired-get-marked-files): Declare.
(vc-dispatcher--explicit-marks-p): New function.
* lisp/vc/vc.el (vc-checkin): Check the user isn't likely to be
surprised by what is included in the checkin. Specifically,
check whether the fileset or patches implied by vc-parent-buffer
are unchanged.
* doc/emacs/maintaining.texi (VC With A Merging VCS): Explain
how the fileset or patch string is fixed once *vc-log* pops up.
Michael Albinus [Sun, 6 Jul 2025 12:41:02 +0000 (14:41 +0200)]
Adapt filenotify-tests.el for Emba
* test/infra/gitlab-ci.yml (.filenotify-gio-template): Enable also
for scheduled jobs.
* test/lisp/filenotify-tests.el (file-notify--test-cleanup):
Fix docstring.
(file-notify--deftest-remote): Use `file-notify--test-cleanup'.
(file-notify-test03-events, file-notify-test05-file-validity)
(file-notify-test06-dir-validity)
(file-notify-test07-many-events)
(file-notify-test09-watched-file-in-watched-dir): Adapt tests.
(file-notify-test03-events-remote)
(file-notify-test04-autorevert-remote)
(file-notify-test07-many-events-remote)
(file-notify-test09-watched-file-in-watched-dir-remote): Do not
tag as :unstable.
Michael Albinus [Sat, 5 Jul 2025 17:21:48 +0000 (19:21 +0200)]
Add file notification handler for Tramp's "smb" method.
* etc/NEWS: Mention new file notification handler for Tramp "smb".
* lisp/filenotify.el (file-notify--expand-file-name): Fix the
remote case.
(file-notify-callback): Extend for "smb-notify".
(file-notify--call-handler): Fix debug message.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch):
* lisp/net/tramp-sh.el (tramp-sh-gio-monitor-process-filter):
Use connection property "file-monitor".
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Use `tramp-smb-handle-file-notify-add-watch'.
(tramp-smb-handle-delete-directory): Do not error if there is a
pending deletion of a directory under file-watch.
(tramp-smb-handle-file-notify-add-watch)
(tramp-smb-notify-process-filter): New defuns.
(tramp-smb-send-command): New optional argument NOOUTPUT.
(tramp-smb-wait-for-output): Improve debug message.
* lisp/net/tramp.el (tramp-directory-watched): New defun.
(tramp-accept-process-output, tramp-wait-for-regexp):
Improve debug message.
* test/lisp/filenotify-tests.el (top): Filter also for
"smb-notify". Set some other Tramp related variables.
(file-notify--test-wait-for-events)
(file-notify--test-with-actions-check)
(file-notify--test-with-actions): Add debug message.
(file-notify--test-cleanup, file-notify--deftest-remote):
Keep Tramp debugs buffer.
(file-notify--test-monitor): Check for "smb-notify".
(file-notify--deftest-remote): Call `file-notify-rm-all-watches'.
(file-notify--test-make-temp-name): Use a better name for parent
directory.
(file-notify--test-event-handler): Use `string-match-p'.
(file-notify--test-with-actions): Check also for the `stopped'
event as limit.
(file-notify-test03-events, file-notify-test04-autorevert)
(file-notify-test05-file-validity)
(file-notify-test07-many-events, file-notify-test08-backup)
(file-notify-test09-watched-file-in-watched-dir): Adapt tests for
"smb-notify".
(file-notify-test12-unmount): Skip for "smb-notify".
Stefan Monnier [Sat, 5 Jul 2025 15:17:51 +0000 (11:17 -0400)]
(eieio--validate-slot-value): Don't break on struct objects
Nowadays `eieio-oset` applies to more than just EIEIO objects.
The old code tended to work OK but only because `eieio--class-slots`
is usually compiled/inlined without checks.
* lisp/emacs-lisp/eieio-core.el (eieio--validate-slot-value):
Don't assume CLASS is an EIEIO class.
Sean Whitton [Sat, 5 Jul 2025 08:49:13 +0000 (09:49 +0100)]
Don't call vc-buffer-sync-fileset when committing a patch
* lisp/vc/vc-dispatcher.el (vc-finish-logentry): Move call to
vc-buffer-sync-fileset from here ...
* lisp/vc/vc.el (vc-checkin): ... to here, and conditionalize so
as not to call when committing a patch. Also fix comment.
Eli Zaretskii [Sat, 5 Jul 2025 08:07:29 +0000 (11:07 +0300)]
Fix 'ediff-before-setup-hook'
* lisp/vc/ediff-util.el
(ediff-clone-buffer-for-region-comparison): Wrap body in
'save-window-excursion', to make sure original window
configuration is restored after quitting 'ediff-regions-linewise'.
Suggested by Aaron Zeng <azeng@janestreet.com>. (Bug#78897)