Commit graph

2072 commits

Author SHA1 Message Date
Eli Zaretskii
b575e44cbf Fix documentation of a recent changeset
* lisp/autorevert.el (auto-revert-mode):
* lisp/files.el (revert-buffer): Doc fix.  (Bug#49661)
2021-07-20 18:37:40 +03:00
Konstantin Kharlamov
61c1522dde Improve auto-revert-mode and revert-buffer doc strings
* lisp/autorevert.el (auto-revert-mode):
* lisp/files.el (revert-buffer): Mention that there is
revert-buffer-with-fine-grain that is better suited for markers
preservation (bug#49661).
2021-07-20 16:38:55 +02:00
Lars Ingebrigtsen
e02576c7eb Put command line file names and mouse dragging onto 'file-name-history'
* lisp/dnd.el (dnd-open-local-file): Add file to history.
* lisp/files.el (file-name-history--add): New function (bug#12915).

* lisp/startup.el (command-line-1): Add file to history.
2021-07-20 13:48:10 +02:00
Eli Zaretskii
bbce22337c Fix documentation of a recent changeset (bug#5003)
* lisp/files.el (safe-local-variable-values)
(ignored-local-variable-values): Doc fix.
(ignored-local-variable-values): Add :version tag.

* doc/emacs/custom.texi (Safe File Variables): Mention
'ignored-local-variable-values'.
* doc/lispref/variables.texi (File Local Variables): Fix wording.

* etc/NEWS: Improve wording of the 'ignored-local-variable-values'
entry.
2021-07-18 21:53:22 +03:00
Lars Ingebrigtsen
da200ab049 Allow ignoring local variable values permanently
* doc/lispref/variables.texi (File Local Variables): Document it.

* lisp/files.el (ignored-local-variable-values): New user option
(bug#5003).
(hack-local-variables-confirm): Allow ignoring permanently.
(hack-local-variables-filter): Ignore the permanently ignored
variables.
2021-07-18 17:18:22 +02:00
Michael Albinus
4200f091b0 ; Fix last change in files.el 2021-07-16 18:54:12 +02:00
Michael Albinus
553ad9c9e8 Add lock-file-mode
* doc/emacs/files.texi (Interlocking):
* doc/lispref/files.texi (File Locks):
* etc/NEWS: Add lock-file-mode.

* lisp/files.el (lock-file-name-transforms)
(remote-file-name-inhibit-locks): Move down.
(lock-file-mode): New minor mode.
2021-07-16 18:13:28 +02:00
Eli Zaretskii
d8d9504c5a ; Fix wording of recent changes in documentation
* lisp/files.el (query-about-changed-file):
* doc/emacs/files.texi (Visiting):
* etc/NEWS: Fix the wording of a recent change.  (Bug#10755)
2021-07-16 16:26:21 +03:00
Lars Ingebrigtsen
9b601d8537 Add new user option 'query-about-changed-file'
* doc/emacs/files.texi (Visiting): Document it.
* lisp/files.el (query-about-changed-file): New user option (bug#10775).
(find-file-noselect): Use it.
2021-07-16 14:30:24 +02:00
Lars Ingebrigtsen
561ef16fd0 Fix lock-file-name-transforms build problem
* lisp/files.el (lock-file-name-transforms): Remove
custom-initialize-delay to fix build problem (bug#49507).
2021-07-16 13:59:46 +02:00
Michael Albinus
cce84822f7 Add remote-file-name-inhibit-locks
* doc/emacs/files.texi (Interlocking):
* doc/lispref/files.texi (File Locks):
* doc/misc/tramp.texi (Auto-save File Lock and Backup):
Add remote-file-name-inhibit-locks.

* etc/NEWS: New user option 'remote-file-name-inhibit-locks'.

* lisp/files.el (remote-file-name-inhibit-locks): New defcustom.

* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Use `tramp-handle-make-lock-file-name'.

* lisp/net/tramp.el (tramp-allow-unsafe-temporary-files): Fix docstring.
(tramp-handle-make-lock-file-name): New defun.

* test/lisp/net/tramp-tests.el (tramp-test39-lock-file): Extend test.
2021-07-13 19:50:05 +02:00
Michael Albinus
a6a92e3ac5 Code cleanup wrt file locks
* lisp/files.el (make-lock-file-name): Fix docstring.

* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `make-lock-file-name'.

* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-lock-file-name'.
(tramp-handle-unlock-file): Call `userlock--handle-unlock-error'
in case of error.

* src/buffer.c (Frestore_buffer_modified_p):
* src/editfns.c (Freplace_buffer_contents):
* src/fileio.c (Finsert_file_contents, write_region): Call Funlock_file.

* src/filelock.c (unlock_file): Rename from unlock_file_body.
Remove the other declarations of unlock_file.  Move file name
handler check to ...
(Funlock_file): ... here.  Adapt argument numbers.  Call
unlock_file wrapped by internal_condition_case.
(Flock_file): Adapt argument numbers.
(unlock_all_files, Funlock_buffer, unlock_buffer): Call Funlock_file.

* src/lisp.h (unlock_file): Remove.
2021-07-08 21:13:40 +02:00
Michael Albinus
6d580b00e4 Some further adaptions wrt Tramp file name locks
* lisp/files.el (files--transform-file-name): Rename from
`auto-save--transform-file-name'.  Wrap with `save-match-data'.
(make-auto-save-file-name): Use it.
(make-lock-file-name): Use it.  Call file name handler.

* lisp/net/tramp.el (tramp-handle-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-write-region):
* lisp/net/tramp-sh.el (tramp-sh-handle-write-region):
* lisp/net/tramp-smb.el (tramp-smb-handle-write-region):
Suppress file lock for temporary file.

* lisp/net/tramp-compat.el (tramp-compat-make-lock-file-name):
New defalias.

* lisp/net/tramp.el (tramp-get-lock-file)
(tramp-handle-lock-file, tramp-handle-unlock-file): Use it.
(tramp-make-lock-name): Remove.

* test/lisp/filenotify-tests.el (file-notify-test03-events-remote):
Tag it :unstable temporarily.
2021-07-08 07:48:40 +02:00
Lars Ingebrigtsen
2ad34bcea4 Add new user option lock-file-name-transforms
* doc/emacs/files.texi (Interlocking): Mention
lock-file-name-transforms.

* doc/lispref/files.texi (File Locks): Document
lock-file-name-transforms.

* doc/misc/efaq.texi (Not writing files to the current directory):
Mention all the three variables needed to not having Emacs writing
files to the current directory in one place.

* lisp/files.el (lock-file-name-transforms): New user option (bug#49261).
(make-auto-save-file-name): Factor out the main logic...
(auto-save--transform-file-name): ... to this new function.
(make-lock-file-name): New function that also calls the
factored-out function.

* src/filelock.c: Remove MAKE_LOCK_NAME and fill_in_lock_file_name.
(make_lock_file_name): New utility function that calls out to Lisp
to heed `lock-file-name-transforms'.
(lock_file): Use it.  Also remove likely buggy call to
dostounix_filename.
(unlock_file_body, Ffile_locked_p): Also use make_lock_file_name.
2021-07-07 21:39:20 +02:00
Michael Albinus
fc3c00413a Doc cleanup
* doc/lispref/files.texi (File Locks, Changing Files)
(File Name Components, File Name Expansion, Magic File Names):
* lisp/files.el (locate-dominating-stop-dir-regexp)
(auto-mode-alist, set-auto-mode, file-name-with-extension)
(backup-directory-alist, wildcard-to-regexp)
(save-buffers-kill-terminal): Doc fixes.

* etc/NEWS: Fix typos.
2021-07-01 10:19:48 +02:00
Colin Woodbury
4f2765f6f1 Add new function file-name-with-extension
* doc/lispref/files.texi (File Name Components): Document it.
* lisp/emacs-lisp/shortdoc.el (file-name): Ditto.

* lisp/files.el (file-name-with-extension): New function.
2021-06-30 14:07:29 +02:00
Stefan Monnier
9060fbd3b5 * lisp/files.el (hack-one-local-variable): Allow add-function in eval:
Fixes: bug#49163
2021-06-27 18:01:13 -04:00
Lars Ingebrigtsen
0377737c9b Fix prompting for large files when loading literally
* lisp/files.el (find-file-noselect): Don't include "literally" in
the "large file" prompt if we're gonna load literally anyway
(bug#49144).
2021-06-21 14:58:15 +02:00
Lars Ingebrigtsen
a1fd11a28f Make find-file-literally ignore local variables again
* lisp/files.el (find-file-noselect-1): Re-inhibit local variables
when loading a file literally (bug#49143).  This was broken by
5bedbe6b1d.
2021-06-21 14:50:59 +02:00
Michael Albinus
284dfd3613 Revert "Add `file-name-set-extension'"
This reverts commit 4f1a5e456e.
2021-06-19 14:01:13 +02:00
Michael Albinus
4f1a5e456e Add `file-name-set-extension'
* lisp/files.el (file-name-with-extension): New defun.

* test/lisp/files-tests.el (files-tests-file-name-with-extension-good)
(files-tests-file-name-with-extension-bad): New tests.
2021-06-19 11:10:46 +02:00
Lars Ingebrigtsen
929adad22b Clarify file reversion prompt
* lisp/files.el (revert-buffer--default): Clarify prompt when the
buffer is modified (bug#43884).
2021-06-06 13:04:12 +02:00
Lars Ingebrigtsen
df17725c80 Handle syntactically invalid .dir-locals.el files better
* lisp/files.el (dir-locals-read-from-dir): Handle syntactically
invalid .dir-locals.el files more gently (bug#48568).  Give a
message instead of bugging out later.
2021-05-25 22:17:40 +02:00
Gregory Heytings
3f8b303ec0 Fix bug when moving directories to trash
* lisp/files.el (move-file-to-trash): Pass the correct dir-flag to
make-temp-file so that a directory is created when a directory is
being trashed (Bug#47960).
2021-05-25 00:24:57 +02:00
Michael Albinus
1b919004f6 Fix bug#48349 in file-name-non-special
* lisp/files.el (file-name-non-special): Use Tramp file name
handler only in case of	`copy-file', 'rename-file' and
`copy-directory'.  (Bug#48349)
2021-05-13 13:57:46 +02:00
Tom Gillespie
ec574a72f7 Fix evaluation order for hack-local-variables
* lisp/files.el (hack-local-variables): Fix the ordering which
local variables are evaluated by `hack-local-variables' so that
prop-line local variables are evaluated first. There is a hidden
nreverse lurking in `hack-local-variables-apply' which means that
the prop line variables must come second in order to be evaluated
before the end of file variables.
2021-05-12 23:31:23 +02:00
Michael Albinus
02c80307f1 Extend meaning of UNIQUIFY `auto-save-file-name-transforms'. (Bug#47493)
* doc/lispref/backups.texi (Auto-Saving): Explain UNIQUIFY being a
secure hash in auto-save-file-name-transforms.

* etc/NEWS: Mention change in `auto-save-file-name-transforms'.

* lisp/files.el (auto-save-file-name-transforms): Adapt docstring.
(make-auto-save-file-name): Care, if UNIQ is a secure hash symbol.
2021-05-10 13:42:48 +02:00
Lars Ingebrigtsen
5bedbe6b1d Always heed the `lexical-binding' local variable
* doc/lispref/variables.texi (File Local Variables): Document
`permanently-enabled-local-variables'.

* lisp/files.el (enable-local-variables): Mention the new variable.
(set-auto-mode): Always call `hack-local-variables'.
(hack-local-variables): Factor out the variable gathering into its
own function, and respect the new variable (bug#47843).
(hack-local-variables--find-variables): Factored out from
`hack-local-variables'.
(permanently-enabled-local-variables): New variable.
2021-05-10 12:40:11 +02:00
Lars Ingebrigtsen
a6757d10e8 Revert "Fix moving directories with the same name to trash"
This reverts commit f618cc5bc8.

This patch doesn't cover some corner cases, I think.
2021-05-08 13:42:51 +02:00
Codruț Constantin Gușoi
f618cc5bc8 Fix moving directories with the same name to trash
* lisp/files.el (move-file-to-trash): Allow moving several
directories with the same name to Trash (bug#48280).

Copyright-paperwork-exempt: yes
2021-05-08 13:40:03 +02:00
Michael Albinus
f50577ea07 Fix some annoyances wrt file-name-non-special
* lisp/files.el (file-name-non-special): Do not expand `file-truename'.

* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):
Use local `default-directory' for `start-process'.
2021-05-07 14:31:17 +02:00
Daniel Martín
b61c828ea3 Add a help option to the open large files prompt
* lisp/files.el (files--ask-user-about-large-file-help-text): New
function that returns information about opening large files in
Emacs.  (Bug#45412)
(files--ask-user-about-large-file): Use read-multiple-choice to
display the available actions.
* etc/NEWS: Advertise the new feature.
2021-05-06 10:27:03 +02:00
Lars Ingebrigtsen
e634130607 Fix inconsistent behaviour in find-file-noselect when using nowarn
* lisp/files.el (after-find-file): Behave the same in when
warning/not warning (bug#47850).  This fixes this test case:
(switch-to-buffer (find-file-noselect "non-existing-dir/test.el" t))
which would leave the buffer read-only.
2021-05-04 11:48:27 +02:00
Michael Albinus
824d1a57ec Fix unquoting of file names in subprocesses (Bug#48177)
* lisp/files.el (file-name-non-special):
Improve handling of inhibit-file-name-handlers.

* src/callproc.c (Fcall_process, call_process): Unquote infile,
error_file and output_file.  (Bug#48177)

* test/lisp/files-tests.el (files-tests-file-name-non-special--subprocess)
(files-tests-file-name-non-special-file-name-all-completions)
(files-tests-file-name-non-special-file-name-completion): Adapt tests.
2021-05-03 16:52:18 +02:00
Andrea Corallo
289000eee7 Merge branch 'feature/native-comp' into into trunk 2021-04-25 20:06:22 +02:00
Stefan Monnier
2868199564 * lisp/files.el (minibuffer-with-setup-hook): Fix bug#46326 2021-04-23 17:21:29 -04:00
Andrea Corallo
b5c76530fa Merge remote-tracking branch 'savannah/master' into native-comp 2021-04-19 18:46:50 +02:00
Basil L. Contovounesios
8ec1391ace ; Fix a couple of recent typos. 2021-04-14 12:41:49 +01:00
Andrea Corallo
b064ddd3f6 Merge remote-tracking branch 'savannah/master' into native-comp 2021-04-13 12:06:23 +02:00
Stefan Monnier
cf774fb8cc * lisp/files.el (file-modes-number-to-symbolic): Add filetype arg.
* lisp/tar-mode.el (tar-header-block-summarize): Use it.
(tar-grind-file-mode): Declare obsolete.
2021-04-12 12:46:47 -04:00
Andrea Corallo
6ca6c71cd0 Merge remote-tracking branch 'savannah/master' into native-comp 2021-03-19 15:28:00 +01:00
Lars Ingebrigtsen
a5197e2240 Fix problem of trashing files to an inconsistent trash directory
* lisp/files.el (move-file-to-trash): Allow moving files to trash
even if there's a file in trash with the same name (but no entry
in info) (bug#47135).
2021-03-18 07:36:15 +01:00
Andrea Corallo
82bd6d57d5 Merge remote-tracking branch 'savannah/master' into native-comp 2021-03-12 16:42:51 +01:00
Stefan Kangas
a412141c9d * lisp/files.el (cd): Improve error message. 2021-03-10 15:10:41 +01:00
Andrea Corallo
43b0df62cd Merge commit '9cbdf20316' into native-comp 2021-03-09 10:03:47 +01:00
Matt Armstrong
36440b15d3 Remove unecessary unlock-buffer calls
* lisp/files.el (revert-buffer-insert-file-contents--default-function):
Remove vestigial call to `unlock-buffer'.
* lisp/simple.el (primitive-undo): Assume unlock-buffer is always
bound.  (Bug#46701)
2021-02-27 16:19:37 +02:00
Andrea Corallo
5c922cc3a4 Merge remote-tracking branch 'savannah/master' into native-comp 2021-02-26 19:54:59 +01:00
Utkarsh Singh
4aa9db7337 Use sh-mode for PKGBUILD files
* lisp/files.el (auto-mode-alist): Use sh-mode for PKGBUILD files
(bug#46660).

Copyright-paperwork-exempt: yes
2021-02-24 17:06:53 +01:00
Andrea Corallo
f92bb788a0 Merge remote-tracking branch 'savannah/master' into native-comp 2021-02-17 22:26:28 +01:00
Lars Ingebrigtsen
b39ac4c85a Fix edebug spec for minibuffer-with-setup-hook
* lisp/files.el (minibuffer-with-setup-hook): Instrument the
:append form for edebug (bug#46531).
2021-02-16 23:32:04 +01:00