1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-09 16:32:18 -07:00
Commit graph

178944 commits

Author SHA1 Message Date
Paul Eggert
92dee45c5e insert-file-contents likely-end memory objects
* src/fileio.c (Finsert_file_contents): Treat memory objects like
regular files when inferring likely end.  Simplify likely end
computation.
2025-07-16 11:45:23 -07:00
Paul Eggert
8a1d368b62 Port insert-file-contents dir behavior to Unix
* src/fileio.c (Finsert_file_contents): Port better to traditional
Unix platforms like Solaris, where in some cases 'read' can
succeed on directories.
2025-07-16 11:45:23 -07:00
Paul Eggert
b282cb98e4 Avoid syscall in dir-locals--all-files
* lisp/files.el (dir-locals--all-files):
Omit an unnecessary call to file-directory-p.
2025-07-16 11:45:23 -07:00
Paul Eggert
2074951c2a 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.
2025-07-16 11:45:23 -07:00
Sean Whitton
94b2a0b2fc Merge from origin/emacs-30
24db9b7962 ; * lisp/vc/diff-mode.el (diff-mode): Scare-quote 'normal'.
756e7e5243 ; * lisp/window.el (window-state-put): Fix a typo (bug#79...
0fb20adf8e ; define-globalized-minor-mode: Fix info node link in doc...
2025-07-16 11:18:41 +01:00
Sean Whitton
24db9b7962 ; * lisp/vc/diff-mode.el (diff-mode): Scare-quote 'normal'. 2025-07-16 11:17:58 +01:00
Sean Whitton
48b3363ac4 ; vc-revert-buffer-internal: Capitalization fix. 2025-07-16 11:00:46 +01:00
Sean Whitton
3d04506cf3 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.
2025-07-16 10:49:26 +01:00
Sean Whitton
aec5c5f037 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).
2025-07-16 09:55:54 +01:00
Michael Albinus
e4db6aa545 ; * src/xdisp.c: Fix typo. 2025-07-16 08:47:23 +02:00
Paul Eggert
42548c25f7 Fix insert-file-contents overlap check
In commit 61a8ce0280 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.
2025-07-15 22:47:16 -07:00
Sean Whitton
a30372f42b ; Fix wording. 2025-07-15 21:58:59 +01:00
Sean Whitton
6ee0093b21 ; Fix recently introduced "ELisp". 2025-07-15 21:57:59 +01:00
Stefan Monnier
c3f3fe136c 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.
2025-07-15 13:49:29 -04:00
Michael Albinus
4c9b376607 Improve autorevert-tests
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.8.1-pre".

* lisp/autorevert.el (auto-revert-mode, auto-revert-tail-mode)
(auto-revert-notify-handler, auto-revert--end-lockout):
Use `auto-revert-buffer'.
(auto-revert-notify-handler): Rearrange setting current buffer.
(auto-revert-handler): Add debug message.  Rearrange check.
Cancel lockout timer if running.

* lisp/net/tramp.el (tramp-barf-if-file-missing)
(with-parsed-tramp-file-name, tramp-skeleton-file-truename):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-message.el (tramp-with-demoted-errors):
Fix debug declatation.

* 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.
2025-07-15 18:57:49 +02:00
Eli Zaretskii
0237e0d1a4 ; * test/lisp/vc/vc-tests/vc-tests.el (vc-test--version-diff): Fix for Bzr. 2025-07-15 19:30:05 +03:00
Eli Zaretskii
1ea3d7b1f7 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)
2025-07-15 16:23:03 +03:00
Sean Whitton
c82a62fa36 ; Improve cross-referencing in some VC docs. 2025-07-15 12:43:44 +01:00
Sean Whitton
8fb0e33a10 ; Wording fixes in VC docs. 2025-07-15 12:43:31 +01:00
Jonas Bernoulli
105ae06031
Allow trivially autoloading transient-define-group
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--make-autoload):
Allow uses of transient-define-group to be autoloaded using just
";;;autoload".
2025-07-15 12:45:05 +02:00
Sean Whitton
e4ea991ed9 vc-resynch-window: Check whether auto-revert-mode is bound
* lisp/vc/vc-dispatcher.el (auto-revert-mode): Delete
declaration.
(vc-resynch-window): Check whether auto-revert-mode is bound.
2025-07-15 10:18:52 +01:00
Pengji Zhang
5d9a67e4bd Move some RefTeX 'setq's to major mode definition
Move two 'setq' expressions from the RefTeX label selection loop
to the body of the major mode definition, so to make it easier
to adjust the settings of the buffer via the mode hook.

* lisp/textmodes/reftex-ref.el (reftex-offer-label-menu): Move
two 'setq' expressions from here...
* lisp/textmodes/reftex-sel.el (reftex-select-label-mode): ...to
here.  (bug#77335)
2025-07-14 21:24:45 +02:00
Stefan Monnier
7f1cae9637 (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.
2025-07-14 12:37:11 -04:00
Paul Nelson
c8b6e90b4e Improve prettification of (La)TeX symbols
* lisp/textmodes/tex-mode.el (tex--prettify-symbols-alist): Remove
entry for "\\newline", which resulted in an invisible display.
Prettify "\\ " with OPEN BOX instead of BOTTOM SQUARE BRACKET.
(tex--prettify-symbols-compose-p): Skip composition when the
control backslash is itself escaped (bug#78752).
2025-07-14 12:25:45 -04:00
Stefan Monnier
f01fc3d614 lisp/textmodes/tex-mode.el (tex--prettify-symbols-alist): Use \
This is the "standard" way to avoid those indentation problems
without relying on funny numbers.
2025-07-14 12:25:32 -04:00
Po Lu
b2d5e4fe40 Fix the Android port
* src/fileio.c (emacs_full_read): Retype FD param to `emacs_fd'.
(Fcopy_file): Label newsize MAYBE_UNUSED.
2025-07-14 21:41:18 +08:00
Eli Zaretskii
d0f96de277 ; 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)
2025-07-14 15:48:45 +03:00
Eli Zaretskii
756e7e5243 ; * lisp/window.el (window-state-put): Fix a typo (bug#79013). 2025-07-14 14:35:31 +03:00
Juri Linkov
817f7829f9 * src/xdisp.c (tab-bar-truncate): New variable (bug#78953).
(tab_bar_height): Use it.
2025-07-14 09:43:18 +03:00
Paul Eggert
a8b65860a5 ; Fix indentation. 2025-07-13 21:39:54 -07:00
Paul Eggert
5bce6753e2 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.
2025-07-13 21:09:40 -07:00
Paul Eggert
c3f96d20ee 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.
2025-07-13 21:09:40 -07:00
Paul Eggert
55f41ca3aa 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
8ac78986ff 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
f4adb56c9a insert-file-contents unexpected end shrinkage
* src/fileio.c (Finsert_file_contents): If the file unexpectedly
shrinks while reading its tail backwards, give up searching for
the match end.
2025-07-13 21:09:39 -07:00
Paul Eggert
c35d09edcf fileio.c comment spelling fix 2025-07-13 21:09:39 -07:00
Paul Eggert
4c4f68be4b 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).
2025-07-13 21:09:39 -07:00
Paul Eggert
61a8ce0280 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
e98da5cc3f 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
de0bb2e059 insert-file-contents file size hint improvement
* src/fileio.c (Finsert_file_contents): When reading yields 0,
update the file size hint to match.  This should improve its
accuracy.
2025-07-13 21:09:39 -07:00
Paul Eggert
aee9b59831 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
56091b6d5c 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
e6c6847973 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
535ab2d116 insert-file-contents END enforcement
* src/fileio.c (Finsert_file_contents): When matching text
at buffer start, don’t go past END if specified.
2025-07-13 21:09:39 -07:00
Paul Eggert
e6c1f46fb1 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
73ab98a8a2 insert-file-contents end offset infinity
* src/fileio.c (Finsert_file_contents): Simplify end_offset
calculation by defaulting to effectively infinity.
2025-07-13 21:09:39 -07:00
Paul Eggert
aa172be7d0 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
b1ada33b5d Non-nil orig_filename in insert-file-contents
* src/fileio.c (Finsert_file_contents): Don’t let orig_filename be
nil, as that might mess up later diagnostics.
2025-07-13 21:09:39 -07:00
Paul Eggert
6a9dbed40c 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.
2025-07-13 21:09:39 -07:00
Paul Eggert
6d09a339ce 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.
2025-07-13 21:09:39 -07:00