Commit graph

2276 commits

Author SHA1 Message Date
Po Lu
ecf08f0621 Merge from savannah/emacs-29
dc4e6b1329 ; Update copyright years in more files
64b3777631 ; Run set-copyright from admin.el
8e1c56ae46 ; Add 2024 to copyright years

# Conflicts:
#	doc/misc/modus-themes.org
#	doc/misc/texinfo.tex
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	etc/themes/modus-operandi-theme.el
#	etc/themes/modus-themes.el
#	etc/themes/modus-vivendi-theme.el
#	lib/alloca.in.h
#	lib/binary-io.h
#	lib/c-ctype.h
#	lib/c-strcasecmp.c
#	lib/c-strncasecmp.c
#	lib/careadlinkat.c
#	lib/cloexec.c
#	lib/close-stream.c
#	lib/diffseq.h
#	lib/dup2.c
#	lib/filemode.h
#	lib/fpending.c
#	lib/fpending.h
#	lib/fsusage.c
#	lib/getgroups.c
#	lib/getloadavg.c
#	lib/gettext.h
#	lib/gettime.c
#	lib/gettimeofday.c
#	lib/group-member.c
#	lib/malloc.c
#	lib/md5-stream.c
#	lib/md5.c
#	lib/md5.h
#	lib/memmem.c
#	lib/memrchr.c
#	lib/nanosleep.c
#	lib/save-cwd.h
#	lib/sha1.c
#	lib/sig2str.c
#	lib/stdlib.in.h
#	lib/strtoimax.c
#	lib/strtol.c
#	lib/strtoll.c
#	lib/time_r.c
#	lib/xalloc-oversized.h
#	lisp/auth-source-pass.el
#	lisp/emacs-lisp/lisp-mnt.el
#	lisp/emacs-lisp/timer.el
#	lisp/info-look.el
#	lisp/jit-lock.el
#	lisp/loadhist.el
#	lisp/mail/rmail.el
#	lisp/net/ntlm.el
#	lisp/net/webjump.el
#	lisp/progmodes/asm-mode.el
#	lisp/progmodes/project.el
#	lisp/progmodes/sh-script.el
#	lisp/textmodes/flyspell.el
#	lisp/textmodes/reftex-toc.el
#	lisp/textmodes/reftex.el
#	lisp/textmodes/tex-mode.el
#	lisp/url/url-gw.el
#	m4/alloca.m4
#	m4/clock_time.m4
#	m4/d-type.m4
#	m4/dirent_h.m4
#	m4/dup2.m4
#	m4/euidaccess.m4
#	m4/fchmodat.m4
#	m4/filemode.m4
#	m4/fsusage.m4
#	m4/getgroups.m4
#	m4/getloadavg.m4
#	m4/getrandom.m4
#	m4/gettime.m4
#	m4/gettimeofday.m4
#	m4/gnulib-common.m4
#	m4/group-member.m4
#	m4/inttypes.m4
#	m4/malloc.m4
#	m4/manywarnings.m4
#	m4/mempcpy.m4
#	m4/memrchr.m4
#	m4/mkostemp.m4
#	m4/mktime.m4
#	m4/nproc.m4
#	m4/nstrftime.m4
#	m4/pathmax.m4
#	m4/pipe2.m4
#	m4/pselect.m4
#	m4/pthread_sigmask.m4
#	m4/readlink.m4
#	m4/realloc.m4
#	m4/sig2str.m4
#	m4/ssize_t.m4
#	m4/stat-time.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/stdio_h.m4
#	m4/stdlib_h.m4
#	m4/stpcpy.m4
#	m4/strnlen.m4
#	m4/strtoimax.m4
#	m4/strtoll.m4
#	m4/time_h.m4
#	m4/timegm.m4
#	m4/timer_time.m4
#	m4/timespec.m4
#	m4/unistd_h.m4
#	m4/warnings.m4
#	nt/configure.bat
#	nt/preprep.c
#	test/lisp/register-tests.el
2024-01-02 10:28:14 +08:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
Eli Zaretskii
06f2bb9c24 ; * lisp/files.el (find-buffer-visiting): Fix whitespace of last change. 2023-12-30 13:04:58 +02:00
Ihor Radchenko
46a93aa7b0 find-buffer-visiting: Fix test breakage introduced in b7a737ef49
* lisp/files.el (find-buffer-visiting): Fix code branch checking for
buffers referring to the same file number.  We should check the found
buffer with the file number, not current.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66117#412
2023-12-30 13:02:05 +02:00
Ihor Radchenko
b7a737ef49 Improve performance of `find-buffer-visiting' (bug#66117)
* src/buffer.c (Fget_truename_buffer): Expose `get_truename_buffer' to
Elisp.
(Ffind_buffer): New subr searching for a live buffer with a given
value of buffer-local variable.
(syms_of_buffer): Register the new added subroutines.
* src/filelock.c (lock_file): Use the new `Fget_truename_buffer' name.
* src/lisp.h:
* test/manual/etags/c-src/emacs/src/lisp.h: Remove no-longer-necessary
extern declarations for `get_truename_buffer'.
* lisp/files.el (find-buffer-visiting): Refactor, using subroutines to
search for buffers instead of slow manual Elisp iterations.
2023-12-30 09:53:46 +02:00
Stefan Monnier
2a8e6c8c84 (require-with-check): New function (bug#67696)
* lisp/files.el (require-with-check): New function.
* lisp/progmodes/eglot.el: Use it (and prefer #' to quote function names).
2023-12-29 11:17:51 -05:00
Stefan Monnier
93dea9288a Merge branch 'no-ls-lisp-advice' 2023-12-21 09:37:12 -05:00
Stefan Monnier
62bf0b7a57 Merge commit 'new-fix-for-bug-60819' 2023-12-20 18:36:26 -05:00
Visuwesh
c4541a3577 Offer to show diff against auto-save in recover-file
* lisp/files.el (recover-file): Show diff against the selected auto
save file.  (Bug#52242)

* doc/emacs/files.texi (Recover): Document the new feature.

* etc/NEWS: Announce the new feature.
2023-12-16 14:34:55 +02:00
Michael Albinus
1d5028ad04 dired-listing-switches handles connection-local values if exist
* doc/emacs/dired.texi (Dired Enter):
* doc/misc/tramp.texi (Frequently Asked Questions):
* etc/NEWS: 'dired-listing-switches' handles connection-local
values if exist.

* doc/lispref/variables.texi (Applying Connection Local Variables):
Fix decription of connection-local-default-application.

* lisp/dired.el (dired-listing-switches): Adapt docstring.
(dired-internal-noselect, dired-mode):
* lisp/dired-x.el (dired-virtual):
* lisp/files.el (recover-file, recover-session):
* lisp/net/ange-ftp.el (ange-ftp-get-files): Use connection-local
value of `dired-listing-switches'.

* lisp/files-x.el (connection-local-value): Adapt docstring.

* lisp/man.el (Man-shell-file-name): Use `connection-local-value'.
2023-12-10 12:26:38 +01:00
Stefan Monnier
29957969e5 (insert-directory): Remove ls-lisp advice
Rather than have `ls-lisp` advise `insert-directory`, make
`insert-directory` call `ls-lisp.el` code directly when needed.

* lisp/files.el (files--use-insert-directory-program-p): New function.
(insert-directory): Use it to delegate to `ls-lisp--insert-directory`
when applicable.

* lisp/ls-lisp.el (ls-lisp--insert-directory): Remove `orig-fun` arg.
Don't test `ls-lisp-use-insert-directory-program` or check for a magic
file name handler; it is now the caller's responsibility.
(insert-directory): Don't add advice any more.

* lisp/dired.el (ls-lisp-use-insert-directory-program): Don't declare it.
(dired-insert-directory): Use `files--use-insert-directory-program-p` instead.
(dired-use-ls-dired): Adjust docstring to refer to
`insert-directory-program` rather than "ls".
2023-12-09 23:45:56 -05:00
Stefan Monnier
6cc1418fc3 (file-expand-wildcards): Handle patterns ending in "/"
The bug was encountered via the ls-lisp advice on Dired but
it actually affects all uses of `file-expand-wildcards`,
so better fix it there.

* lisp/files.el (file-expand-wildcards): Fix bug#60819.
* lisp/ls-lisp.el (ls-lisp--dired): Undo commit b365a7cc32.
* test/lisp/files-tests.el (files-tests--expand-wildcards): New test.
2023-12-09 19:49:33 -05:00
Stefan Monnier
1da0fccc64 * lisp/files.el (file-expand-wildcards): Fix sorting of subdirs
E.g. (file-expand-wildcards "/u*/*m*")
returned ("/usr/games" "/u/dummy" "/u/monnier" "/u/omnibook-disk")
instead of ("/u/dummy" "/u/monnier" "/u/omnibook-disk" "/usr/games").
2023-12-09 18:42:36 -05:00
Kévin Le Gouguec
53bd2d57f3 Recognize shebang lines that pass '-S/--split-string' to 'env'
* etc/NEWS: announce the change.

* lisp/files.el (auto-mode-interpreter-regexp): Add optional '-S'
switch to the ignored group capturing the env invocation.
Allow multiple spaces between #!, interpreter and first argument:
empirically, Linux's 'execve' accepts that.  (Bug#66902)

* test/lisp/files-tests.el (files-tests--check-shebang): New helper to
generate a temporary file with a given interpreter line, and assert
that the mode picked by 'set-auto-mode' is derived from an expected
mode.  Write the 'should' form so that failure reports include useful
context; for example:

    (ert-test-failed
     ((should
       (equal (list shebang actual-mode) (list shebang expected-mode)))
      :form
      (equal ("#!/usr/bin/env -S make -f" fundamental-mode)
	     ("#!/usr/bin/env -S make -f" makefile-mode))
      :value nil :explanation
      (list-elt 1 (different-atoms fundamental-mode makefile-mode))))

* test/lisp/files-tests.el (files-tests-auto-mode-interpreter): New
test; exercise some aspects of 'interpreter-mode-alist'.
2023-11-19 11:05:26 +02:00
Stefan Monnier
492920dd5b Use new derived-mode-all/set-parents functions.
Try and avoid using the `derived-mode-parent` property directly
and use the new API functions instead.

* lisp/emacs-lisp/derived.el (define-derived-mode):
Use `derived-mode-set-parent`.

* lisp/loadhist.el (unload--set-major-mode):
* lisp/info-look.el (info-lookup-select-mode):
* lisp/ibuf-ext.el (ibuffer-list-buffer-modes):
* lisp/files.el (dir-locals--get-sort-score):
* lisp/emacs-lisp/cl-generic.el (cl--generic-derived-specializers):
Use `derived-mode-all-parents`.
2023-11-08 23:24:35 -05:00
dalanicolai
95d56b92a6 Fix 'locate-dominating-file' when FILE is not a directory.
* lisp/files.el (locate-dominating-file): Handle FILE that is not
a directory.  (Bug#66542)
2023-10-25 16:12:24 +03:00
Jens Schmidt
8d2a04f4c0 Better handle errors when writing r-o files without backup
* lisp/files.el (basic-save-buffer-2): Restore file permissions when
writing read-only files without backup fails.  (Bug#66546)
2023-10-25 15:56:39 +03:00
Eli Zaretskii
484fc70a7a Fix "C-0 C-x C-s" with write-protected files
* lisp/files.el (basic-save-buffer-2): Call 'set-file-modes' to
try to make the file writable, even if
'set-file-extended-attributes' succeeded.  (Bug#66546)
2023-10-16 14:17:57 +03:00
Michael Albinus
1677a65554 Merge from origin/emacs-29
dc8b336d02 * lisp/files.el (file-name-non-special): Handle quoted ti...
2023-10-14 09:38:17 +02:00
Michael Albinus
dc8b336d02 * lisp/files.el (file-name-non-special): Handle quoted tilde.
(Bug#65685)

* test/lisp/files-tests.el
(files-tests-file-name-non-special-expand-file-name-tilde):
New test.
2023-10-14 09:34:40 +02:00
Paul W. Rankin
60f3e9f5c9 Improve find-sibling-rules option type
* lisp/files.el (find-sibling-rules): More helpful rules.
2023-10-05 10:45:31 +03:00
Stefan Kangas
9f91a1c3eb Make insert-directory-program a defcustom; use "gls" on *BSD
* lisp/files.el (insert-directory-program): Change into defcustom.
Default to "gls" on *BSD and macOS.  (Bug#64791)
2023-09-25 11:36:14 +02:00
Eli Zaretskii
6d8801ee73 Merge from origin/emacs-29
476933b235 ; * lisp/simple.el (shell-command-to-string): Fix quotation.
e27ec0e414 Improve remote-file-name-inhibit-cache :type
2023-09-23 09:41:11 -04:00
Basil L. Contovounesios
e27ec0e414 Improve remote-file-name-inhibit-cache :type
* lisp/files.el (remote-file-name-inhibit-cache)
(shell-highlight-undef-remote-file-name-inhibit-cache): Avoid
duplicated :tag string.  Try to clarify wording and
formatting (bug#66150).
* lisp/shell.el (shell--highlight-undef-exec-cache): Reference
correct user option in docstring.
2023-09-22 15:15:36 +02:00
Eli Zaretskii
0273914921 Merge from origin/emacs-29
bc56da92d8 ; Fix error in 'tex-recenter-output-buffer'
d17c5adc05 Fix regexp for recognizing PBM images
9e9f61866e Improve wording in ELisp manual
7427efa033 Fix typo (Bug#65764)
59c6624408 ; * lisp/ido.el (ido-completion-buffer): Fix :type (bug#6...
4ec4b18c2a Fix libgccjit build on Haiku
80bdcf8f35 (regexp-tests-backtrack-optimization): Mark it as failing
8a9e653cc8 ; Add regression test for bug#65726
6fad73d7cc * src/regex-emacs.c (mutually_exclusive_p): Fix inf-loop ...
1d3d419607 ; * lisp/files.el (save-some-buffers-functions): Doc fix ...
42b14c6e5b Bump seq version to 2.24
ff5190a174 Add note on ELPA to admin/notes/bug-triage
f1e4cbe72a ; * etc/PROBLEMS: Minor wording fix.
fd5593c7f2 * etc/PROBLEMS: Mention bug#65432 and its remedy.
dd896ea1e6 Ignore errors when checking for object initializers (bug#...
3550f44c17 ; Fix typos
5b246b9b81 * CONTRIBUTE: Document making ChangeLogs with Magit.
0bd4661941 Doc fixes for obsolete functions and variables
524c0c34f2 ; * lisp/ffap.el (ffap-rfs-regexp): Fix :type (bug#65698).
f48dccc467 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
71a85e2266 A revision to the Widget manual
dbbcf4a659 Fix fontification of " in edit-kbd-macro

# Conflicts:
#	test/src/regex-emacs-tests.el
2023-09-09 04:32:45 -04:00
Eli Zaretskii
1d3d419607 ; * lisp/files.el (save-some-buffers-functions): Doc fix (bug#65414). 2023-09-04 19:06:19 +03:00
Po Lu
91830b8bf3 Revise last change to copy-directory
* lisp/files.el (copy-directory): Instead of demoting errors
from set-file-times, refrain from setting them if newname is
located within /contents.
2023-08-26 16:37:31 +08:00
Po Lu
349798a9b8 Demote errors from utimensat copying directories
* lisp/files.el (copy-directory): Wrap set-file-times within
with-demoted-errors.

* src/fileio.c (Fcopy_file): Adjust commentary.
2023-08-26 09:57:32 +08:00
Michael Albinus
e4dc0d6c7e * lisp/files.el (file-remote-p): Simplify. 2023-08-23 11:00:34 +02:00
Eli Zaretskii
e3207b13ce Fix behavior of client frames when 'find-alternate-file' is used
* lisp/files.el (find-alternate-file-dont-kill-client): New var.
(find-alternate-file): Bind it to a special value when invoking
kill-buffer-hook.
* lisp/server.el (server-delete-client): If NOFRAME is
'dont-kill-client', don't kill the client and its terminals.
(server-buffer-done): Pass 'find-alternate-file-dont-kill-client'
to 'server-delete-client'.  (Bug#65277)
2023-08-19 10:34:07 +03:00
Mattias Engdegård
1ad318cf2a ob-tangle.el: fix unintended range in regexp
* lisp/org/ob-tangle.el (org-babel-interpret-file-mode):
Repair parts of regexp that should only match +, - and =.
* lisp/files.el (file-modes-symbolic-to-number):
Fix the same error in a doc string; this seems to be where
the mistake originated.
2023-08-16 16:55:38 +02:00
Eli Zaretskii
b289f0769f Merge from origin/emacs-29
4767f5eaee Better fix for bug#65156
dd1d8414b3 Fix insert-file-contents with pipes and /dev/stdin
50649a6d1a ; * etc/PROBLEMS: Fix wording.
f0dda682ff ; * etc/NEWS.28: Add deletion of levents.el.
f4acae842c Fix bug#65042
e1874c4e8b * configure.ac (HAVE_TREE_SITTER): Set NEED_DYNLIB=yes (b...
ef8838c3a5 * etc/NEWS: Mention tramp-show-ad-hoc-proxies.
495bee253f * test/lisp/net/tramp-tests.el (tramp-test42-utf8): Skip ...
de1effd73b ; Fix last change
7c7966862b * test/lisp/net/tramp-tests.el (tramp-test10-write-region...
16205e8db6 ; Improve help-echo in package.el
a95e700698 ; Filter packages available for upgrade via menu bar
adff72dd1d Fix reverting Rmail buffers
2023-08-12 13:42:14 -04:00
Stefan Kangas
6cc9910227 Make dired-move-to-filename-regexp obsolete
* lisp/dired.el (dired-move-to-filename-regexp): Make Emacs 21
compatibility alias obsolete.
2023-08-12 15:46:17 +02:00
Eli Zaretskii
4fa75771d1 ; * lisp/files.el (delete-file): Add expand-file-name back. 2023-08-11 15:03:48 +03:00
Po Lu
3fb2c174d3 Enable visiting FIFOs as files
* doc/lispref/files.texi (Reading from Files): Document new
`if-regular' value of REPLACE.

* etc/NEWS: Announce the new value.

* lisp/files.el (basic-save-buffer-2): Demote errors saving
backup files, since FIFOs cannot be copied.
(revert-buffer-insert-file-contents--default-function): Supply
`if-regular' instead of t as REPLACE.

* src/fileio.c (selinux_enabled_p): New function.
(Fcopy_file, Ffile_selinux_context, Fset_file_selinux_context):
Call that function to ascertain if SELinux applies to a file.
(read_non_regular): Don't assume `emacs_fd_read' always returns
int.
(Finsert_file_contents): If REPLACE is if-regular and FILENAME
is a special non-seekable file, fall back to erasing the buffer
before inserting the contents of that file.
(syms_of_fileio) <Qif_regular>: New symbol.
2023-08-08 13:37:00 +08:00
Po Lu
072a8a434e Merge remote-tracking branch 'origin/master' into feature/android 2023-08-07 07:56:44 +08:00
Eli Zaretskii
400df210ce Fix last change of 'delete-file'
* src/fileio.c (Fdelete_file_internal): Expand file name here, as
all primitives must.
(internal_delete_file): Adjust to the fact that Fdelete_file was
renamed.

* lisp/files.el (delete-file): Don't expand-file-name here, as
the called primitives already do.  Fix typo in doc string.
2023-08-06 17:03:26 +03:00
Po Lu
7ffc5f86e4 Merge remote-tracking branch 'origin/master' into feature/android 2023-08-06 21:45:44 +08:00
Eric S. Raymond
10a7615b5d Separate filename-deletion mechanism from policy.
src/fileio.c: (delete-file-internal) Renamed from delete-file,
              parallel to delete-directory-internal; policy
	      code moved to Lisp.
src/files.el: (delete-file) New function, holds policy logic.
              calls delete-file-internal.

This is a pure refactoring step, delete-file's behavior is
unchanged. But the C core is a little simpler now.
2023-08-06 09:31:39 -04:00
Eli Zaretskii
adff72dd1d Fix reverting Rmail buffers
This bug happened because rmail.el relied on 'revert-buffer' to
return non-nil when it succeeds to revert, but a recent change
in 'revert-buffer' broke that promise in Emacs 29.1.
* lisp/files.el (revert-buffer--default, revert-buffer): Doc fix.
(revert-buffer): Return whatever 'revert-buffer-function' returns.
(Bug#65071)
2023-08-06 09:33:44 +03:00
Po Lu
53023eba94 Merge remote-tracking branch 'origin/master' into feature/android 2023-07-17 20:44:00 +08:00
Eli Zaretskii
9d332c4993 ; * lisp/files.el (create-file-buffer): Add commentary. 2023-07-17 14:36:44 +03:00
Eli Zaretskii
5b6b95dbf8 ; * lisp/files.el (create-file-buffer): Fix last change (bug#62732). 2023-07-17 14:34:35 +03:00
Po Lu
a65960c5b9 Merge remote-tracking branch 'origin/master' into feature/android 2023-07-14 07:58:49 +08:00
Spencer Baugh
ee4cc106b8 Don't recalculate the buffer basename inside uniquify
Previously, uniquify--create-file-buffer-advice would use the filename
of the buffer to calculate what the buffer's basename should be.  Now
that gets passed in from create-file-buffer, which lets us fix several
bugs:

1. before this patch, if a buffer happened to be named the same thing
as directory in its default-directory, the buffer would get renamed
with a directory separator according to uniquify-trailing-separator-p.

2. buffers with a leading space should get a leading |, as described
by create-file-buffer's docstring; before this patch, uniquify would
remove that leading |.

* lisp/dired.el (dired-internal-noselect): Pass a directory name to
create-file-buffer.
* lisp/files.el (create-file-buffer): Do uniquify-trailing-separator-p
handling if passed a directory filename. (bug#62732)
* lisp/uniquify.el (uniquify-item):
(uniquify-rationalize-file-buffer-names, uniquify-rationalize,
uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist):
Remove uniquify-trailing-separator-p handling.
(uniquify--create-file-buffer-advice): Take new basename argument and
use it, instead of recalculating the basename from the filename.
2023-07-13 17:50:56 -04:00
Po Lu
dc7ecc6e31 Merge remote-tracking branch 'origin/master' into feature/android 2023-07-11 08:19:32 +08:00
Jim Porter
a6e88dc726 Add support for explicitly-remote commands in Eshell
* lisp/files.el (file-remote-p):
* doc/lispref/files.texi (Magic File Names): Document 'never' for
CONNECTED argument.

* lisp/net/tramp.el (tramp-handle-file-remote-p): Handle CONNECTED
value of 'never'.

* lisp/eshell/esh-ext.el (eshell-explicit-remote-commands): New
option.
(eshell-ext-initialize): Apply 'eshell-handle-remote-command' when
requested.
(eshell-handle-remote-command): New function.
(eshell-remote-command): Reimplement this function and dispatch to
'eshell-external-command', which can handle remote processes on its
own.

* test/lisp/eshell/esh-ext-tests.el
(esh-ext-test/explicitly-remote-command)
(esh-ext-test/explicitly-local-command): New tests.

* doc/misc/eshell.texi (Remote Access): Document explicitly-remote
commands.

* etc/NEWS: Announce this change.
2023-07-10 12:27:09 -07:00
Po Lu
af8232a150 Merge remote-tracking branch 'origin/master' into feature/android 2023-07-06 08:34:26 +08:00
Michael Albinus
2dc7798449 `remote-file-name-access-timeout' being 0 is equal to nil
* doc/lispref/files.texi (Testing Accessibility): Clarify the
value of remote-file-name-access-timeout.

* etc/NEWS: Clarify the value of remote-file-name-access-timeout.

* lisp/files.el (remote-file-name-access-timeout): Adapt docstring.

* lisp/net//tramp.el (with-tramp-timeout): Ensure, that the
timeout is a positive number, or nil.
(tramp-handle-access-file): Simplify code.
2023-07-05 10:05:44 +02:00
Po Lu
79207a055f Merge remote-tracking branch 'origin/master' into feature/android 2023-07-04 08:52:29 +08:00