Jim Porter [Sun, 20 Jul 2025 20:11:32 +0000 (13:11 -0700)]
Disable track-changes while reloading pages in EWW
This makes sure 'eww--track-changes' doesn't interfere with the initial
rendering process. Previously, this caused problems like <textareas>
consuming the rest of the page when reloading the document.
Speed up unintern, and fix symbol shorthand edge case (bug#79035)
Don't do a full lookup if the argument is a symbol, and only compute the
hash index once. Fix a bug that occurred when there is another symbol
whose shorthand is equal to the true name of the symbol being removed.
* src/lread.c (Funintern): Rewrite for speed and correctness.
(oblookup_last_bucket_number, oblookup): Remove now unused variable.
* test/src/lread-tests.el (lread-unintern): New test.
Sean Whitton [Sat, 19 Jul 2025 10:17:25 +0000 (11:17 +0100)]
Include shorter bindings in diff-mode docstring
* lisp/vc/diff-mode.el (diff-read-only-map): New keymap,
factored out of code modifying minor-mode-map-alist.
(diff-mode): Include bindings from diff-read-only-map in
docstring (bug#34080).
Manuel Giraud [Sat, 5 Jul 2025 19:17:00 +0000 (21:17 +0200)]
Saner defaults for `calendar-read-sexp' (Bug#78964)
* lisp/calendar/cal-bahai.el (calendar-bahai-read-date):
* lisp/calendar/cal-china.el (calendar-chinese-goto-date):
* lisp/calendar/cal-coptic.el (calendar-coptic-read-date):
* lisp/calendar/cal-french.el (calendar-french-goto-date):
* lisp/calendar/cal-hebrew.el (calendar-hebrew-read-date):
* lisp/calendar/cal-islam.el (calendar-islamic-read-date):
* lisp/calendar/cal-iso.el (calendar-iso-read-date):
* lisp/calendar/cal-julian.el (calendar-julian-goto-date)
(calendar-astro-goto-day-number):
* lisp/calendar/cal-mayan.el (calendar-mayan-read-haab-date)
(calendar-mayan-read-tzolkin-date):
* lisp/calendar/cal-persia.el (calendar-persian-read-date):
* lisp/calendar/diary-lib.el (diary-insert-cyclic-entry): Use
first day as default.
* lisp/calendar/cal-hebrew.el (calendar-hebrew-list-yahrzeits):
Set the default of end-year as start-year plus ten years.
Fix for 'windmove-do-window-select' if other-window is 'no-select
If the variable 'windmove-create-window' is set to a function
that returns 'no-select', 'windmove-do-window-select' is intended
to ignore the final window selection. However, because
'other-window' is passed to 'window-minibuffer-p' before checking
if 'other-window' is 'no-select', 'window-minibuffer-p' will
instead throw a type error, and the '(eq other-window 'no-select)'
case will never be reached. This patch moves this case up a line
to avoid this.
* lisp/windmove.el (windmove-do-window-select): Check for
'no-select' value earlier. (Bug#78997)
Paul Eggert [Fri, 18 Jul 2025 18:49:29 +0000 (11:49 -0700)]
GCC bug 117423 has a fix
Document the change in dependency. As we still need to work
around GCC bug 119085, there is no functional change in ‘configure’.
* configure.ac (emacs_cv_gcc_bug_119085_CFLAGS):
Rename from emacs_cv_gcc_bug_117423_CFLAGS. All uses changed.
Sean Whitton [Fri, 18 Jul 2025 13:53:43 +0000 (14:53 +0100)]
VC: Tighten up switching branches
* lisp/vc/vc.el: Require backend 'create-tag' functions to
prompt for the starting point of the branch.
(vc-retrieve-tag, vc-switch-branch): Accept empty NAME only when
not switching branches: it doesn't make sense to switch to the
current branch. Plain 'C-x v r' can still be used to check out
the latest revisions on the current branch.
Stefan Monnier [Sun, 6 Jul 2025 17:23:50 +0000 (13:23 -0400)]
outline.el: Don't silence buffer text modification
It's important not to hide buffer text modifications from
`after/after-change-functions` since it can break other packages'
assumptions.
* lisp/outline.el (outline--insert-button): Don't silence
buffer text modification.
(outline--fix-up-all-buttons): Save buffer's modified state instead.
Stefan Monnier [Sun, 6 Jul 2025 17:13:14 +0000 (13:13 -0400)]
outline.el: Use jit-lock to maintain the buttons
* lisp/outline.el (outline-minor-mode): Use jit-lock instead of
`after-change-functions`.
(outline-flag-region): Run `outline--fix-buttons` since jit-lock
won't be triggered.
(outline--fix-up-all-buttons): Make the args mandatory.
(outline--fix-buttons): Rename from `outline--fix-buttons-after-change`.
Fix the END calculation. Return the affected bounds, for jit-lock.
Stefan Monnier [Sun, 6 Jul 2025 16:27:04 +0000 (12:27 -0400)]
outline.el: Remove buttons properly, including the " "
In Xref, enabling+disabling `outline-minor-mode` left two spaces
in front of every heading (a.k.a "group") line.
* lisp/outline.el (outline--remove-buttons): New function.
(outline-minor-mode, outline--fix-buttons-after-change): Use it.
(outline-after-change-functions): Improve docstring.
Stefan Monnier [Thu, 17 Jul 2025 16:36:16 +0000 (12:36 -0400)]
comp.el: Fix minor corner-case annoyances
* lisp/emacs-lisp/comp.el (comp--native-compile): Avoid `%s`
on objects that may not have names.
* src/data.c (Ffset): Don't compute trampoline for no-op `fset`.
Paul Eggert [Wed, 16 Jul 2025 18:38:20 +0000 (11:38 -0700)]
insert-file-contents small gap bug
Problem reported by Zhengyi Fu (Bug#79031).
* src/fileio.c (Finsert_file_contents): Do not read more than
requested, even when the gap is so small that we use a local buffer.
Paul Eggert [Wed, 16 Jul 2025 15:43:14 +0000 (08:43 -0700)]
Avoid some syscalls in locate-dominating-file
* lisp/files.el (locate-dominating-file): Do not call
file-directory-p each time through a loop ascending the directory
hierarchy, as the file must be a directory after the first loop
iteration. Instead, call file-directory-p just once, before the
loop starts, and do this only if the file name is not already that
of a directory.
Sean Whitton [Wed, 16 Jul 2025 09:49:26 +0000 (10:49 +0100)]
view-mode-exit: Respect view-read-only
* lisp/view.el (view-mode-exit): When view-read-only is non-nil,
don't exit View mode if doing so would leave behind a read-only
buffer not in View mode.
(View-exit): Bind view-read-only to nil to override the above.
Sean Whitton [Wed, 16 Jul 2025 08:55:54 +0000 (09:55 +0100)]
vc-git-diff: Fix case where REV1 & REV2 are nil and no commits yet
* lisp/vc/vc-git.el (vc-git--empty-tree): New constant.
(vc-git-diff): When REV1 and REV2 are both nil and there are no
commits yet, diff against the empty tree object (bug#78987).
Paul Eggert [Wed, 16 Jul 2025 05:36:54 +0000 (22:36 -0700)]
Fix insert-file-contents overlap check
In commit 61a8ce0280668980a4452b112103c9bc879e1f49 I mistakenly
focused on overlap in the buffer. The code also needs to check
for overlap in the inserted file data.
Problem reported by Gerd Möllmann (Bug#79020).
* src/fileio.c (Finsert_file_contents): Prevent overlap in both
the buffer head and tail, and in the inserted file’s head and tail.
Also, shrink the file’s head if the file shrank to be smaller
than its head.
Stefan Monnier [Tue, 26 Dec 2023 03:40:02 +0000 (22:40 -0500)]
Add `redisplay_counter` to catch nested redisplays and abort outer one
The redisplay code is not re-entrant. To allow running ELisp code
from within redisplay, we have some hacks (e.g. `inhibit-redisplay`)
that try to avoid the resulting breakage.
This commit adds another one of those hacks, which tries
to get closer to the core of the problem, thereby making it "safe"
to override `inhibit-redisplay`, e.g. to debug jit-lock code.
* src/dispextern.h (redisplay_counter): Declare.
* src/xdisp.c (redisplay_counter): Define.
(redisplay_internal) Increment it.
(dsafe__call): Use it, in case `inhibit-redisplay` is overridden.
* src/eval.c (call_debugger): Use it as well to refine the test
we already had.
* lisp/net/tramp-sh.el (tramp-sh-gio-monitor-process-filter): Do not
prepend remote prefix.
* test/lisp/autorevert-tests.el: Unify file notification libraries
"gio-monitor" and "gvfs-monitor-dir" to "gio".
(top): Set some Tramp related variables.
(auto-revert--timeout): Increase value.
(auto-revert--test-enabled-remote)
(auto-revert-test02-auto-revert-deleted-file): Do not check for
EMACS_HYDRA_CI environment variable.
(auto-revert--wait-for-revert): Fix regexp to search for.
(auto-revert--deftest-remote): Fix debug declatation. Do not tag
:unstable.
(with-auto-revert-test): Fix debug declatation. Adapt revert intervals.
(auto-revert-test*): Start with (file-notify-rm-all-watches). Use
`buffer-string' and `string-match-p'.
(auto-revert-test00-auto-revert-mode): Unlock initial lockout.
(auto-revert-test01-auto-revert-several-files): Rearrange
temporary directory and file settings.
(auto-revert-test02-auto-revert-deleted-file): Adapt debug message.
(auto-revert-test03-auto-revert-tail-mode): Use `with-auto-revert-test'.
(auto-revert-test04-auto-revert-mode-dired):
Use `ert-with-temp-directory'. Adapt prefix of tmpfile.
(auto-revert-test04-auto-revert-mode-dired)
(auto-revert-test05-global-notify, auto-revert-test06-write-file):
Wait for proper file modification.
(auto-revert-test--instrument-kill-buffer-hook): Fix debug message.
(auto-revert-test07-auto-revert-several-buffers): Use
`with-auto-revert-test.
* test/lisp/filenotify-tests.el: Unify file notification libraries
"gio-monitor" and "gvfs-monitor-dir" to "gio".
(file-notify--deftest-remote): Fix debug declatation. Do not skip
for "gio".
(file-notify--test-with-actions): Fix debug declatation.
* test/lisp/net/tramp-tests.el (filenotify): Require.
(ert-remote-temporary-file-directory)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test45-asynchronous-requests): Do not check for
EMACS_HYDRA_CI environment variable.
(tramp-test46-file-notifications): New test.
Eli Zaretskii [Tue, 15 Jul 2025 13:23:03 +0000 (16:23 +0300)]
Fix shift-translation support of 'scroll-lock-mode' commands
* lisp/scroll-lock.el (scroll-lock-next-line-always-scroll)
(scroll-lock-next-line, scroll-lock-previous-line)
(scroll-lock-forward-paragraph, scroll-lock-backward-paragraph):
Make them support shift-translation, like the commands remapped to
them do. (Bug#79022)
Stefan Monnier [Mon, 14 Jul 2025 16:37:11 +0000 (12:37 -0400)]
(cl--class-allparents): Fix bug#78989
Give more control over ordering when linearizing the
parent graph and avoid pathological misbehavior (such as
placing `t` in the middle of the linearization instead of the
end) when we can't "do it right".
* lisp/subr.el (merge-ordered-lists): Degrade more gracefully in case
of inconsistent hierarchies and don't do it silently.
* lisp/emacs-lisp/cl-preloaded.el (cl--class-allparents): Use the local
ordering to break ties, as in the C3 algorithm.
Eli Zaretskii [Mon, 14 Jul 2025 12:48:45 +0000 (15:48 +0300)]
; Fix 'threads-join-error' test
* test/src/thread-tests.el (threads-thread-sleeps): New helper
function.
(threads-join-error): Fix to work as intended, and remove the
'unstable' tag. (Bug#40823)
Paul Eggert [Sun, 13 Jul 2025 20:33:27 +0000 (13:33 -0700)]
Speed up insert-file-contents reads
This change makes insert-file-contents-literally 30% faster on my
platform, when inserting xdisp.c.
* src/fileio.c (READ_BUF_SIZE): Remove, replacing with ...
(IO_BUFSIZE): ... this new constant from Coreutils.
All uses of READ_BUF_SIZE changed to either MAX_ALLOCA or
IO_BUFSIZE.
Paul Eggert [Sun, 13 Jul 2025 19:52:43 +0000 (12:52 -0700)]
Avoid some tiny /proc file reads
* src/fileio.c (union read_non_regular):
New members buf and bufsize replace inserted and trytry.
(read_non_regular): Adjust to this new, simpler interface.
(Finsert_file_contents): If the gap is smaller than read_buf
and we want to read more than the gap, read into read_buf
first, to avoid lots of tiny reads from /proc files.
Paul Eggert [Sun, 13 Jul 2025 17:55:14 +0000 (10:55 -0700)]
insert-file-contents file shrinkage in scanback
* src/fileio.c (emacs_full_read): New function.
(Fcopy_file, Finsert_file_contents): Use it.
(Finsert_file_contents): Check for partial reads when scanning
backwards through the file’s tail, as this indicates the file
shrank while we read it. Also, use emacs_full_read in other
situations where it’s simpler and should be a bit faster.
Paul Eggert [Sun, 13 Jul 2025 16:35:38 +0000 (09:35 -0700)]
int → ptrdiff_t for read results
* src/fileio.c (Finsert_file_contents): Use ptrdiff_t, not int, to
store results returned by emacs_fd_read, which return ptrdiff_t.
This doesn’t fix any bugs since the values happen to fit in int,
but is a bit clearer and may simplify future changes.
Paul Eggert [Sun, 13 Jul 2025 00:21:35 +0000 (17:21 -0700)]
insert-file-contents byte vs char confusion
* src/fileio.c (Finsert_file_contents): Use del_range_byte,
not del_range_1, since we are passing byte counts, not
character counts. Problem reported by Pip Cet (Bug#77315).
Paul Eggert [Sun, 13 Jul 2025 00:03:29 +0000 (17:03 -0700)]
Fix insert-file-contents overlap calculation
* src/fileio.c (Finsert_file_contents): Overlap is impossible, so
omit incorrect overflow adjustments that caused later index
calculations to go off the rails (Bug#77315). Change a ‘ZV_BYTE’
to ‘same_at_end’ for clarity; they have the same value here.
Paul Eggert [Sat, 12 Jul 2025 23:21:59 +0000 (16:21 -0700)]
insert-file-contents do not rely on st_size
This fix was prompted by Bug#77315.
* src/fileio.c (Finsert_file_contents): Do not rely on st_size for
anything other than a hint about the file size. Trust only the
file size as revealed by a read that returns 0.
Paul Eggert [Sat, 12 Jul 2025 21:31:18 +0000 (14:31 -0700)]
insert-file-contents file end EOF fixes
* src/fileio.c (Finsert_file_contents):
When counting bytes at file end, don’t trust lseek to seek
to the end of the file. Instead, read a bit after lseeking,
to make sure we get to the end, give up if we don’t get to EOF.
This works around problems on /proc filesystems
where lseek pretends the file is empty.
Update file_size_hint when reaching EOF.
Paul Eggert [Sat, 12 Jul 2025 21:22:02 +0000 (14:22 -0700)]
Fix insert-file-contents integer overflows
* src/fileio.c (Finsert_file_contents): Change ‘total’ from
ptrdiff_t to off_t since it might not fit in ptrdiff_t.
Check for overflow when estimating the insertion size.
Paul Eggert [Sat, 12 Jul 2025 20:56:55 +0000 (13:56 -0700)]
Remove ineffective overflow check
* src/fileio.c (Finsert_file_contents): Remove check for overflow.
The overflow is not possible, and the check was incorrectly
written and would not have caught it anyway.
Paul Eggert [Sat, 12 Jul 2025 19:36:56 +0000 (12:36 -0700)]
insert-file-contents initial offset fix
* src/fileio.c (Finsert_file_contents): Don’t assume that a
newly-opened file is at offset 0, even if it is a regular file.
This might not be true for files like /dev/stdin.
Paul Eggert [Sat, 12 Jul 2025 19:13:32 +0000 (12:13 -0700)]
Refactor negative file size checking
* src/fileio.c (Finsert_file_contents): Check for negative file
sizes earlier, as it’s easy, avoids some unnecessary work, and
will simplify later changes.
Paul Eggert [Sat, 12 Jul 2025 17:03:26 +0000 (10:03 -0700)]
Improve inserted file coding system finding
* src/fileio.c (Finsert_file_contents): When inserting a file into
a nonempty buffer, improve the heuristic for determining the
file’s coding system by not trusting lseek+SEEK_END, which is
unreliable in /proc or when the file is mutating.
Paul Eggert [Fri, 11 Jul 2025 23:32:31 +0000 (16:32 -0700)]
Improve insert-file-contents on non-regular files
This is part of a fix for Bug#77315,
and improves on the fix for Bug#71258.
* src/fileio.c (Finsert_file_contents): Do not pretend that
directories are regular files. Instead, signal an error when
attempting to read from them in the usual case where the OS
prohibits that; and otherwise read from them. However, when
visiting a directory report an error right away rather than
waiting until later, as this function is documented to not allow
visiting non-regular files. Nest the struct stat into a small
code block, to keep the code simpler and so that the compiler can
see what parts are used and can issue better diagnostics if
uninitialized storage is accessed. Be more skeptical of st_size,
when the file is not regular.
Paul Eggert [Fri, 11 Jul 2025 22:33:26 +0000 (15:33 -0700)]
Fix (find-file "/dev/null")
* lisp/files.el (find-file-noselect-1): When the file exists,
propagate any errors signaled by insert-file-contents,
instead of propagating them only when the file is unreadable.
This way, (find-file "/dev/null") gives a sensible diagnostic
"not a regular file" instead of the nonsense
"Maximum buffer size exceeded".
Paul Eggert [Wed, 22 Jan 2025 19:06:06 +0000 (11:06 -0800)]
Don’t trust st_size when scanning file head+tail
* src/fileio.c (Finsert_file_contents): Do not look at st_size
when scanning the file’s head and tail for a coding system comment.
Instead, just use read and SEEK_END and don’t worry if the latter fails.
st_size and lseek might not work in a /proc file system.
Paul Eggert [Wed, 22 Jan 2025 19:06:06 +0000 (11:06 -0800)]
copy-file no longer trusts st_size
In copy-file, do not trust st_size, since it might change as we run,
or we might be in a /proc system where it is unreliable anyway.
Also, fix some other unlikely copy-file bugs while we’re here.
* src/fileio.c (Fcopy_file): Use O_TRUNC when opening a
destination that already exists. This saves us the trouble
of having to call ftruncate with a possibly-bogus st_size;
the old motivation for using ftruncate is no longer compelling.
Do not assume ptrdiff_t is as wide as ssize_t; although this is
true on all known platforms, it’s easy to not assume it.
Don’t trust st_size. Prefer SSIZE_MAX to TYPE_MAXIMUM (ssize_t).
Always read+write, regardless of whether copy_file_range failed.
Paul Eggert [Sun, 13 Jul 2025 15:46:24 +0000 (08:46 -0700)]
READ_BUF_SIZE → sizeof read_buf
* src/fileio.c (Finsert_file_contents): Minor refactoring.
This should help future patches which distinguish read_buf’s size
from other uses of READ_BUF_SIZE which may change.
Paul Eggert [Sun, 13 Jul 2025 01:14:26 +0000 (18:14 -0700)]
insert-file-contents errno confusion
* src/fileio.c (read_non_regular): Return negation of
errno on failure, instead of -1.
(Finsert_file_contents): Signal with correct errno when a read fails.
Stefan Monnier [Mon, 14 Jul 2025 03:14:53 +0000 (23:14 -0400)]
org-persist.el: Silence fewer warnings and fix found warning
* lisp/org/org-persist.el: Minor cleanup.
(org-persist-directory, org-persist-remote-files)
(org-persist-default-expiry): Remove redundant `:group` arg.
(org-persist-collection-let): Document lack of hygiene.
Remove `with-no-warnings`.
(org-persist--find-index): Reindent, and simplify initialization of `r`.
(org-persist-associated-files:generic): Move before first use.
Alan Mackenzie [Sun, 13 Jul 2025 20:28:51 +0000 (20:28 +0000)]
Preserve source position of macro calls in macro expansions
This allows the byte compiler to give correct positions, those
of the invoking forms, when an error or warning is caused by
the innards of the invoked macros.
This fixes bug#73725 and bug#73746.
* lisp/emacs-lisp/macroexp.el (macroexp--posify-form-1)
(macroexp--posify-form): New functions.
(macroexp-preserve-posification): New macro.
(macroexp--compiler-macro, macroexp-macroexpand): Use the new
macro to preserve a calling form's position.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form): Use the new
macro to preserve source positions.
* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position.el
* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position-2.el:
New test files.
* test/lisp/emacs-lisp/bytecomp-tests.el: Two new tests using
the new test files.
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.