Commit graph

2111 commits

Author SHA1 Message Date
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
Andrea Corallo
2fcb85c3e7 Merge remote-tracking branch 'savannah/master' into HEAD 2021-02-10 21:56:55 +01:00
Paul Eggert
4467073c50 Simplify and speed up after-find-file
Use newer primitives like file-accessible-directory-p to simplify
and speed up longstanding code in after-find-file.
* lisp/files.el (after-find-file):
Prefer file-exists-p + file-symlink-p to file-attributes +
file-symlink-p + file-chase-links + file-exists-p.
Prefer file-accessible-directory-p to directory-file-name +
file-attributes.
Prefer file-directory-p to file-name-directory + file-exists-p.
2021-02-10 10:58:40 -08:00
Stefan Kangas
58473dc660 Prefer defvar-local in preloaded files
* lisp/abbrev.el:
* lisp/bindings.el (mode-line-mule-info, mode-line-modified)
(mode-line-remote, mode-line-process)
(mode-line-buffer-identification):
* lisp/buff-menu.el (Buffer-menu-files-only):
* lisp/files.el (buffer-file-number, buffer-file-read-only)
(local-write-file-hooks, write-contents-functions)
(file-local-variables-alist, dir-local-variables-alist)
(save-buffer-coding-system, buffer-save-without-query):
* lisp/font-core.el (font-lock-defaults):
* lisp/font-lock.el (font-lock-keywords-case-fold-search)
(font-lock-syntactically-fontified)
(font-lock-extend-after-change-region-function)
(font-lock-extend-region-functions, font-lock-major-mode):
* lisp/menu-bar.el (list-buffers-directory):
* lisp/simple.el (next-error--message-highlight-overlay)
(next-error-buffer, next-error-function)
(next-error-move-function, goto-line-history)
(minibuffer-default-add-done, undo-extra-outer-limit):
* lisp/tab-bar.el (tab-switcher-column):
* lisp/term/ns-win.el (ns-select-overlay):
* lisp/window.el (window-size-fixed, window-area-factor)
(window-group-start-function, window-group-end-function)
(set-window-group-start-function)
(recenter-window-group-function)
(pos-visible-in-window-group-p-function)
(selected-window-group-function)
(move-to-window-group-line-function): Prefer defvar-local.
2021-01-31 20:08:25 +01:00
Andrea Corallo
a8b8d220b4 Merge remote-tracking branch 'savannah/master' into native-comp 2021-01-30 14:09:37 +01:00
Lars Ingebrigtsen
8f0a2c84b6 Make subdirs . nil in dir-locals in ~/ work
* lisp/files.el (dir-locals-collect-variables): Compare directory
names after expanding.  This makes a (subdirs . nil) in ~/ work as
expected (bug#17205).

Test case:

((nil . ((a .  "hallo")
         (subdirs . nil))))

in ~/
2021-01-26 01:12:45 +01:00
Andrea Corallo
b8d3ae78c5 Merge remote-tracking branch 'savannah/master' into native-comp 2021-01-24 21:05:33 +01:00
Lars Ingebrigtsen
75f6b264f5 Make (subdirs . nil) in .dir-locals.el work
* lisp/files.el (dir-locals-collect-variables): Don't
destructively modify the cached structure (bug#17205), because
that means that (subdirs . nil) doesn't work.
2021-01-23 23:12:05 +01:00
Andrea Corallo
5db5064395 Merge remote-tracking branch 'savannah/master' into HEAD 2021-01-02 10:11:15 +01:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Juri Linkov
cd4a51695f Add variables read-char-choice-use-read-key and y-or-n-p-use-read-key
* lisp/subr.el (read-char-choice-use-read-key): New variable.
(read-char-choice): Use read-char-from-minibuffer when
read-char-choice-use-read-key is nil.
(y-or-n-p-use-read-key): New variable.
(y-or-n-p): Restore old code that calls read-key to use it when
y-or-n-p-use-read-key is non-nil.

* lisp/dired-aux.el (dired--no-subst-ask, dired-query):
* lisp/files.el (files--ask-user-about-large-file)
(hack-local-variables-confirm):
* lisp/userlock.el (ask-user-about-supersession-threat):
* lisp/wid-edit.el (widget-choose): Revert to use read-char-choice
instead of read-char-from-minibuffer.

https://lists.gnu.org/archive/html/emacs-devel/2020-12/msg01919.html
2020-12-30 11:54:01 +02:00
Andrea Corallo
f244c21902 Merge remote-tracking branch 'savannah/master' into HEAD 2020-12-20 22:08:42 +01:00