Sean Whitton [Fri, 25 Jul 2025 18:34:04 +0000 (19:34 +0100)]
VC: New support for other working trees
* lisp/vc/vc-git.el (vc-git--read-start-point): New function,
factored out of vc-git-create-tag.
(vc-git-create-tag): Use it.
(vc-git--worktrees, vc-git-known-other-working-trees)
(vc-git-add-working-tree, vc-git-delete-working-tree)
(vc-git-move-working-tree):
* lisp/vc/vc-hg.el (vc-hg-known-other-working-trees)
(vc-hg-add-working-tree, vc-hg--shared-p)
(vc-hg-delete-working-tree, vc-hg-move-working-tree): New
functions.
* lisp/vc/vc.el: Define API for known-other-working-tree,
add-working-tree, delete-working-tree and move-working-tree
backend functions.
(vc-dir-status-files): New function.
(project-current-directory-override): Declare.
(dired-rename-subdir): Autoload.
(vc-add-working-tree, vc-switch-working-tree)
(vc-delete-working-tree, vc-move-working-tree): New commands.
* lisp/vc/vc-hooks.el (vc-prefix-map): Bind them under C-x v.
* doc/emacs/vc1-xtra.texi (Other Working Trees): New node.
* etc/NEWS: Announce the new commands.
* test/lisp/vc/vc-tests/vc-tests.el
(vc-test--other-working-trees): New function.
(vc-test-git07-other-working-trees)
(vc-test-hg07-other-working-trees): New tests.
Sean Whitton [Fri, 25 Jul 2025 17:45:59 +0000 (18:45 +0100)]
Bind vc-rename-file to C-x v R
* lisp/vc/vc-hooks.el (vc-prefix-map): Bind vc-rename-file to
C-x v R.
* doc/emacs/files.texi (Copying and Naming):
* doc/emacs/vc1-xtra.texi (VC Delete/Rename, Revision Tags):
* etc/NEWS (bindings): Document the new binding.
Paul Eggert [Fri, 25 Jul 2025 02:44:48 +0000 (19:44 -0700)]
Streamline init_callproc a bit
* src/callproc.c (init_callproc): Don’t bother testing for the
existence of ../src/ and NEWS if installation-directory is
non-nil, because in that case we will test for ../etc/NEWS anyway.
Simplify by using AUTO_STR.
Paul Eggert [Fri, 25 Jul 2025 02:41:01 +0000 (19:41 -0700)]
Refactor to allow nameless auto strings
* src/lisp.h (AUTO_STR, AUTO_STR_WITH_LEN): New macros.
Long ago this sort of thing would have been a no-no
because we needed to GCPRO the strings.
However, GCPRO went away a decade ago.
Paul Eggert [Thu, 24 Jul 2025 22:02:49 +0000 (15:02 -0700)]
Diagnose load-path only if interactive
* lisp/startup.el (command-line): Warn about dubious
user-emacs-directory and load-path only if interactive, as that’s
where warning helps and the warnings just complicate batch usage
(e.g., -Q).
Paul Eggert [Thu, 24 Jul 2025 21:49:52 +0000 (14:49 -0700)]
PATH defaults now act more like GNU and POSIX
When PATH is unset or empty, use the system default,
to be consistent with GNU/Linux and with POSIX.
If there is no system default do not default to "."
as that can be dangerous.
* src/callproc.c (init_callproc_1, init_callproc):
Default PATH to the null pointer, not the empty string.
* src/emacs.c (default_PATH): New function.
(find_emacs_executable, decode_env_path): Be consistent with POSIX
and with glibc about what to do when PATH is unset or empty.
Paul Eggert [Thu, 24 Jul 2025 12:32:37 +0000 (05:32 -0700)]
Treat ‘.../emacs’ like ‘emacs’ in realpath startup
* src/emacs.c (find_emacs_executable): If the executable name
contains a slash, use the same optimization for symlink resolution
that we already use when the executable name has no slash.
Robert Pluim [Tue, 22 Jul 2025 12:48:54 +0000 (14:48 +0200)]
Use macro to reduce repetition in TLS tests
* test/lisp/net/network-stream-tests.el (with-tls-params): New
macro, abstracts most of the boiler plate for TLS tests.
(connect-to-tls-ipv4-wait, connect-to-tls-ipv4-nowait)
(connect-to-tls-ipv6-nowait, open-network-stream-tls-wait)
(open-network-stream-tls-nowait, open-network-stream-tls)
(open-network-stream-tls-nocert)
(open-gnutls-stream-new-api-default)
(open-gnutls-stream-new-api-wait)
open-gnutls-stream-old-api-wait)
(open-gnutls-stream-new-api-nowait)
(open-gnutls-stream-old-api-nowait): Use it.
Paul Eggert [Thu, 24 Jul 2025 00:38:32 +0000 (17:38 -0700)]
Simplify file end finding in insert-file-contents
* src/fileio.c (Finsert_file_contents): Don’t give up finding the
file’s end merely because SEEK_END fails. Try a small test read
anyway. This might work in non-POSIX file systems where SEEK_END
is not allowed, and trying is easy and simplifies the code.
Michael Albinus [Wed, 23 Jul 2025 14:22:26 +0000 (16:22 +0200)]
Add consistent environment for local process calls in Tramp
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection):
* lisp/net/tramp-androidsu.el (tramp-androidsu-maybe-open-connection):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory)
(tramp-smb-handle-file-acl)
(tramp-smb-handle-file-notify-add-watch)
(tramp-smb-handle-set-file-acl, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command):
Use `tramp-start-process'. Do not call `tramp-post-process-creation'.
* lisp/net/tramp.el (with-tramp-local-environment): New defmacro.
(tramp-start-process): New defun.
(tramp-call-process, tramp-call-process-region)
(tramp-process-lines): Use `with-tramp-local-environment'.
NS: Use different window collection behavior for tooltips (bug#73037)
* src/nsterm.m ([EmacsView updateCollectionBehavior]):
Use NSWindowCollectionBehaviorFullScreenAuxiliary for non-native
tooltips which are not child frames.
Michael Albinus [Tue, 22 Jul 2025 15:47:38 +0000 (17:47 +0200)]
Add function exec-suffixes
* doc/lispref/processes.texi (Subprocess Creation):
Add function exec-suffixes.
* etc/NEWS: New function 'exec-suffixes'.
Presentational fixes and improvements.
* lisp/files-x.el (exec-suffixes): New defun. (Bug#78886)
* lisp/files.el (executable-find): Use function `exec-suffixes'.
* lisp/net/tramp-integration.el
(tramp-connection-local-default-system-variables): Add also
`exec-suffixes'.
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection): Use
default values of `path-separator', `null-device' and
`exec-suffixes'.
(tramp-smb-connection-local-default-system-variables):
New defconst. Add it to connection-local profiles.
Paul Eggert [Mon, 21 Jul 2025 22:10:56 +0000 (15:10 -0700)]
insert-file-contents respect END better
This fixes some longstanding bugs, along with bugs recently
introduced as part of fixes for Bug#77315.
* src/fileio.c (Finsert_file_contents): Arrange for END_OFFSET
to never be less than BEG_OFFSET, to simplify the code.
Do not go past END_OFFSET when sampling or optimizing reading.
Avoid a few unnecessary lseeks.
Paul Eggert [Mon, 21 Jul 2025 21:56:43 +0000 (14:56 -0700)]
insert-file-contents shrinking Solaris file fix
This is related to recent fixes for Bug#77315.
* src/fileio.c (Finsert_file_contents): Defend against
a file shrinking to be smaller than its initial offset.
This can happen only on platforms like Solaris where
the initial offset can be positive.
Paul Eggert [Sun, 20 Jul 2025 20:40:20 +0000 (13:40 -0700)]
insert-file-contents read size increase
This increases the max read size from 0.25 to 1 MiB, which is a
bit better for Emacs in my measurements. The old value was taken
from coreutils, but was for a different purpose.
* src/fileio.c (INSERT_READ_SIZE_MAX): New constant, replacing
IO_BUFSIZE. All uses changed.
(Finsert_file_contents): Do not use a read buffer that is larger
than INSERT_READ_SIZE_MAX.
Paul Eggert [Sun, 20 Jul 2025 19:38:43 +0000 (12:38 -0700)]
Fix insert-file-contents infloop with unlucky END
This partially reverts 55f41ca3aa8fe487d10730708a7396137a2c9d18,
which was a partial fix for Bug#77315.
* src/fileio.c (Finsert_file_contents): Go back to accepting
partial reads when doing the optimized way when code conversion is
not needed. This avoids an unlikely bug when END happens to lie
at a buffer boundary, causing an infloop. For consistency, do the
same when doing code conversion (though there’s no bug in then),
as there’s not a real need for emacs_full_read there either.
Paul Eggert [Sun, 20 Jul 2025 16:37:51 +0000 (09:37 -0700)]
Refactor by coalescing MAX_RW_COUNT definitions
* src/emacs.c (read_full):
Simplify by assuming MAX_RW_COUNT is defined.
* src/lisp.h (MAX_RW_COUNT): Move here from src/sysdep.c.
* src/pdumper.c (dump_read_all):
Use MAX_RW_COUNT rather than defining our own equivalent.
Paul Eggert [Sun, 20 Jul 2025 15:59:16 +0000 (08:59 -0700)]
insert-file-contents from seekable non-regular
* src/fileio.c (Finsert_file_contents): Be more conservative
when reading from seekable non-regular files when END is given.
The code assumed that in this case, reads would succeed or fail
quickly so there was no need to call internal_condition_case_1.
However, in some cases, e.g., /dev/random, it could take a while.
This fixes a glitch introduced in commit cb4579ed6ba45c81ee7ec627bf197e1def121f24 dated 2022-06-11.
Paul Eggert [Sun, 20 Jul 2025 01:04:38 +0000 (18:04 -0700)]
insert-file-contents beware buffer relocation
This fixes a potential (albeit quite unlikely) bug
introduced during recent fixes to Bug#77315.
* src/fileio.c (union read_non_regular.s.inserted):
Bring back this member.
(read_non_regular, Finsert_file_contents): Work in the unlikely
case when internal_condition_case_1 relocates the buffer before
calling read_non_regular.
Paul Eggert [Sat, 19 Jul 2025 00:29:25 +0000 (17:29 -0700)]
insert-file-contents 1 KiB seek fix
This improves on recent fixes to Bug#77315.
When sampling the first 1 KiB and last 3 KiB, do not seek before
BEG if given. Instead, sample starting at BEG, to be consistent
with the non-optimized version.
* src/fileio.c (xlseek): Return POS, for convenience.
(Finsert_file_contents): Sample the first 1 KiB correctly when BEG.
In a CURPOS local, keep track of the input file offset, or for
nonseekable files the number of bytes read, while this value is
important. This lets us avoid some unnecessary seeks. Report an
error earlier if the file is not seekable and BEG is nonzero,
to save work and simplify the code. When sampling, discard less
data, as this is simpler and there’s little point to discarding it.
Paul Eggert [Fri, 18 Jul 2025 20:56:53 +0000 (13:56 -0700)]
insert-file-contents seek refactoring
* src/fileio.c (xlseek): New function.
(Finsert_file_contents): Use it instead of doing things by hand.
(write_region): Match diagnostic wording to xlseek’s.
Paul Eggert [Fri, 18 Jul 2025 06:00:38 +0000 (23:00 -0700)]
Fix insert-file-contents optimization glitch
This improves on recent fixes to Bug#77315.
* src/fileio.c (Finsert_file_contents): When optimizing
do not seek to 0 if the initial file offset is positive,
as that causes the optimized code to behave differently
from the nonoptimized.
Paul Eggert [Thu, 17 Jul 2025 17:46:33 +0000 (10:46 -0700)]
insert-file-contents SEEK_END optimization
This improves on recent fixes to Bug#77315.
* src/fileio.c (Finsert_file_contents):
Do not give up on seeking merely because SEEK_END fails.
On some files (/proc/cpuinfo, say) SEEK_END can fail
even though SEEK_SET and SEEK_CUR succeed, and the
code still works in this case.
Paul Eggert [Thu, 17 Jul 2025 16:50:07 +0000 (09:50 -0700)]
insert-file-contents st_size cleanup
* src/fileio.c (Finsert_file_contents): Store st_size,
not file_size_hint, into current_buffer->modtime_size,
since modtime_size is compared to a later st_size, not
to the actual file size. Simplify buffer overflow detection
from file size, since this occurred only on regular files.
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.