Commit graph

2141 commits

Author SHA1 Message Date
Stefan Kangas
3631355dcb New user option auto-save-visited-remote-files
* lisp/files.el (auto-save-visited-remote-files): New user option.
(auto-save-visited-mode): Use above new variable to decide whether
or not to save remote files.  (Bug#41333)
2022-07-05 14:51:21 +02:00
Stefan Kangas
ac7f76528f New user option auto-save-visited-mode-predicate
* lisp/files.el (auto-save-visited-mode-predicate): New defcustom.
(auto-save-visited-mode): Use above new variable as a predicate to
decide whether or not to save a buffer.
2022-07-05 14:05:43 +02:00
Stefan Kangas
77d90ce79a Merge from origin/emacs-28
d5e1424174 Expand docstrings related to auto-saving
2022-07-05 06:30:40 +02:00
Stefan Kangas
d5e1424174 Expand docstrings related to auto-saving
* lisp/files.el (auto-save-visited-mode):
* lisp/simple.el (auto-save-mode): Expand docstring.
2022-07-05 00:30:09 +02:00
Eli Zaretskii
603de9a38e ; Fix documentation of 'file-parent-directory'
* doc/lispref/files.texi (Directory Names):
* lisp/files.el (file-parent-directory): Improve wording of the
documentation of 'file-parent-directory'.  (Bug#56355)
2022-07-04 14:59:58 +03:00
Daanturo
1ac383bcb6 Add file-parent-directory function
* doc/lispref/files.texi: Document the function.
* etc/NEWS: Add its entry.
* lisp/emacs-lisp/shortdoc.el: Add it to 'file-name' group.
* lisp/files.el: implementation (bug#56355).
2022-07-04 13:07:51 +02:00
Zachary Kanfer
772b189143 Add new command `rename-visited-file'
* doc/emacs/files.texi (Save Commands): Document it.

* lisp/files.el (rename-visited-file): New command (bug#56229).
2022-06-28 14:15:47 +02:00
Lars Ingebrigtsen
502e861af7 Don't create HOME if it doesn't exist
* lisp/files.el (locate-user-emacs-file): Don't create HOME if it
doesn't exist (bug#47298).  This returns us to Emacs 26.3
behaviour here.
2022-06-26 14:34:59 +02:00
Lars Ingebrigtsen
b6238a26c9 Revert "Fix some byte-compilation warnings about subr-x"
This reverts commit cd479aa8bd.

This led to build failures when doing bootstraps.
2022-06-25 00:19:23 +02:00
Lars Ingebrigtsen
cd479aa8bd Fix some byte-compilation warnings about subr-x
* lisp/term/haiku-win.el (require):
* lisp/replace.el (require):
* lisp/progmodes/elisp-mode.el (require):
* lisp/isearch.el (require):
* lisp/files.el (require): Require subr-x when compiling.
2022-06-24 14:35:23 +02:00
Lars Ingebrigtsen
03124c4201 Fix .dir-local.el caching for symlinks
* lisp/files.el (dir-locals-read-from-dir): We want the time stamp
of the actual file, not the time stamp of the symlink (if
.dir-locals.el is a symlink) (bug#46122).
2022-06-14 15:01:44 +02:00
Stefan Monnier
86f30c972b * files.el (auto-mode-alist): Add entry to .eld files 2022-06-13 08:58:09 -04:00
Lars Ingebrigtsen
980009e84c Make find-sibling-file-search non-private
* lisp/files.el (find-sibling-file-search): Rename to be non-private.
(find-sibling-file): Adjust call.
2022-06-12 12:08:41 +02:00
Eli Zaretskii
dc5f6dcee2 Fix "C-x C-d" with wildcard arguments
* lisp/files.el (list-directory): Make sure 'default-directory' is
set to a valid value if the argument DIRNAME included wildcards.
(Bug#55877)
2022-06-12 13:03:32 +03:00
Lars Ingebrigtsen
81a586282d Fix find-sibling-file doc string
* lisp/files.el (find-sibling-file): Remove incorrect statement
from doc string (bug#55879).
2022-06-10 11:45:28 +02:00
Lars Ingebrigtsen
7ee736a884 Allow specifying a wildcard argument to list-directory again
* lisp/files.el (list-directory): Allow specifying a wildcard
argument interactively again (bug#55877).
2022-06-10 10:22:33 +02:00
Stefan Kangas
1766609309 Merge from origin/emacs-28
d02c94090c Fix error reporting in process-async-https-with-delay
9a4862a973 * doc/misc/org.org: Remove spurious markup.
768ed1476a Make Tramp version check more robust
7f778c6943 Fix debugging with GDB when a breakpoint has multiple loca...
25e53e9391 ; * lisp/files.el (file-expand-wildcards): Doc fix.
3ea9357d10 Update documentation of 'aset' and 'store-substring'

# Conflicts:
#	lisp/files.el
2022-06-10 08:17:35 +02:00
Lars Ingebrigtsen
6a9ff1c638 Demote extended attribute errors in basic-save-buffer-2
* lisp/files.el (basic-save-buffer-2): Give demoted errors when
reading extended attributes that fail (bug#43723).
2022-06-07 20:03:41 +02:00
Lars Ingebrigtsen
7edf3d2902 Make find-file-noselect not pick buffers with broken symlinks
* lisp/files.el (find-buffer-visiting): Improve doc string.
(find-file-noselect): Don't pick buffers with broken symlinks,
because that's too confusing (bug#41414).
2022-06-06 15:49:36 +02:00
Lars Ingebrigtsen
5f12e288a5 Improve find-sibling-file error reporting
* lisp/files.el (find-sibling-file): Improve error reporting.
2022-06-06 14:34:50 +02:00
Stefan Monnier
5ee4209f30 cl-typep: Emit warning when using a type not known to be a type
`cl-typep` has used a heuristic that if there's a `<foo>-p` function,
then <foo> can be used as a type.  This made sense in the past where
most types were not officially declared to be (cl-)types, but nowadays
this just encourages abuses such as using `cl-typecase` with
"types" like `fbound`.  It's also a problem for EIEIO objects, where
for historical reasons `<foo>-p` tests if the object is of type
exactly `<foo>` whereas (cl-typep OBJ <foo>) should instead test
if OBJ is a *subtype* of `<foo>`.

So we change `cl-typep` to emit a warning whenever this "-p" heuristic
is used, to discourage abuses, encourage the use of explicit
`cl-deftype` declarations, and try and detect some misuses of
`<foo>-p` for EIEIO objects.

* lisp/emacs-lisp/eieio.el (defclass): Define as type not only at
run-time but also for the current compilation unit.

* lisp/emacs-lisp/eieio-core.el (class, eieio-object): Define as types.

* lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't abuse the
"-p" heuristic.

* lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies):
Add entries for frames, windows, markers, and overlays.
(cl-typep): Emit a warning when using a predicate that is not known to
correspond to a type.

* lisp/files.el (file-relative-name): Fix error that can trigger if
there's an(other) error between loading `files.el` and loading
`minibuffer.el`.
2022-06-06 00:04:00 -04:00
Lars Ingebrigtsen
408fa62148 Add new command find-sibling-file
* doc/emacs/files.texi (Visiting): Document it.
* lisp/files.el (file-expand-wildcards): Fix up the regexp expansion.
(find-sibling-rules, find-sibling-file): New user option and command.
(find-sibling-file--search): New helper function.
2022-06-05 15:49:29 +02:00
Eli Zaretskii
25e53e9391 ; * lisp/files.el (file-expand-wildcards): Doc fix. 2022-06-05 16:40:22 +03:00
Lars Ingebrigtsen
d8924e179e Extend file-expand-wildcards to allow regexps
* doc/lispref/files.texi (Contents of Directories): Document it.
* lisp/files.el (file-expand-wildcards): Extend to allow regexps.

* lisp/emacs-lisp/shortdoc.el (file): Expand the
file-expand-wildcards example.
2022-06-05 14:08:31 +02:00
Stefan Kangas
d46e94f23f Merge from origin/emacs-28
1b8719835a Update to Org 9.5.4
92c5faafd7 Clarify documentation of 'string-to-unibyte'
2848512654 ; * lisp/files.el (find-file): Avoid too short lines in do...
672f9f787f Improve keystrokes in doc strings in some find-file functions
ef5651cc77 Fix segfaults when starting on 80x26 TTY frames
bfa647972f ; Fix doc string of 'delete-selection-repeat-replace-region'
a95d46e00f Make it explicit that a couple of _s in lispref are unders...
5c74c25123 Remove from FAQ the MS-Windows info about BDF fonts
edb48646f2 Fix Display Property manual example
2022-06-05 06:30:25 +02:00
Eli Zaretskii
2848512654 ; * lisp/files.el (find-file): Avoid too short lines in doc string. 2022-06-02 16:04:38 +03:00
Ikumi Keita
672f9f787f Improve keystrokes in doc strings in some find-file functions
* lisp/files.el (find-file):
(find-file-other-window):
(find-file-other-frame): Include the correct keymap so that
keystrokes are displayed better (bug#55761).

Copyright-paperwork-exempt: yes
2022-06-02 14:29:53 +02:00
Lars Ingebrigtsen
1cfb89dc79 Allow extending 'save-some-buffers'
* lisp/abbrev.el (abbrev--possibly-save): Separated out from
`save-some-buffers'.
(save-some-buffers-functions): Add to the save function.

* lisp/files.el (save-some-buffers-functions): New variable.
(save-some-buffers): Use it.
(save-buffers-kill-emacs): Also use it to see if we have something
to save (bug#55579).
2022-05-23 09:45:35 +02:00
Lars Ingebrigtsen
1030cc1897 Fix regression with multiple mode: entries in the prop line
* lisp/files.el (hack-local-variables): Fix regression with multiple
mode: entries in the prop line.

Do not merge to master.
2022-04-19 18:08:20 +02:00
Lars Ingebrigtsen
e45abc832d Fix regression with multiple mode: entries in the prop line
* lisp/files.el (hack-local-variables--find-variables): Use the
final mode: line (which is the same as having several mode: bits
in the header line.
2022-04-19 18:06:31 +02:00
Lars Ingebrigtsen
35592141cc Allow several mode: elements in the local variable section
* etc/NEWS (mode): Fall back on outline-mode in older Emacsen.
* lisp/files.el (hack-local-variables--find-variables): Use the
final mode: line (which is the same as having several mode: bits
in the header line.
2022-04-19 16:22:37 +02:00
Lars Ingebrigtsen
4684b8e62f Fix major-mode setting regression when there's a mode: cookie
* lisp/files.el (hack-local-variables): Fix regression in setting
the major mode when there are mode: cookies in the file (bug#54993).

Do not merge to master.
2022-04-18 10:37:29 +02:00
Lars Ingebrigtsen
713a199705 Fix major-mode setting regression when there's a mode: cookie
* lisp/files.el (hack-local-variables): Fix regression in setting
the major mode when there are mode: cookies in the file (bug#54993).
2022-04-18 10:36:43 +02:00
Lars Ingebrigtsen
5be9a9cacf Add a new command `restart-emacs'
* doc/lispref/os.texi (Killing Emacs): Document it.

* lisp/files.el (save-buffers-kill-emacs): Add new RESTART parameter.
(restart-emacs): New function.

* src/emacs.c (terminate_due_to_signal, Fkill_emacs): Take an
optional RESTART parameter.

* test/lisp/files-tests.el
(files-tests-save-buffers-kill-emacs--confirm-kill-processes):
* src/xterm.c (x_connection_closed):
* src/xsmfns.c (Fhandle_save_session):
* src/keyboard.c (Fcommand_error_default_function, command_loop)
(command_loop_1, read_menu_command, read_event_from_main_queue)
(read_key_sequence, quit_throw_to_read_char):
* src/eval.c (process_quit_flag): Adjust Fkill_emacs callers.
2022-04-17 13:37:51 +02:00
Eli Zaretskii
44ba0270b7 Merge from origin/emacs-28
d53c999b4a Further vcs-cvs/rcs-responsible-p updates from master
dc3d1628ec ; * src/sysdep.c: Fix mistake in previous commit
855e15dbf1 Fix builds on older versions of macOS
9da744e450 Fix documentation of Outline minor mode options
a8bb12ab05 Improve discoverability of 'insert-directory-program'
3f166bdf44 ; * etc/PROBLEMS: Describe MS-Windows issues with fonts.  ...
803ac857ee Fix cursor motion under truncate-lines with Flymake fringe...

# Conflicts:
#	etc/PROBLEMS
#	lisp/outline.el
#	src/sysdep.c
2022-04-16 13:58:31 -04:00
Eli Zaretskii
a8bb12ab05 Improve discoverability of 'insert-directory-program'
* lisp/files.el (insert-directory-program): Mention 'dired' in the
doc string.
* lisp/dired.el (dired): Mention 'insert-directory-program' in the
doc string.  (Bug#54962)
2022-04-15 23:03:15 +03:00
Kien Nguyen
7eca680e54 Make file-name-split returns driver name as well in Windows
* lisp/files.el (file-name-split): Returns driver name as well in
Windows.
* lisp/net/browse-url.el (browse-url-file-url): Don't hexify colon
character in file path for Windows (bug#54721).
2022-04-06 11:58:02 +02:00
Robert Pluim
0e5f8e24af Report buffer-name when local mode-line is invalid
* lisp/files.el (hack-local-variables-prop-line): Add '(buffer-name)'
to the message reporting the malformed mode-line.
2022-03-16 19:05:17 +01:00
Stefan Monnier
20d9c4b59f Flocate_file_internal: Protect from .eln remapping
Don't use `openp`s functionality to remap `.elc` files to `.eln` files
since `locate-file` is not specific to ELisp files.
This should be not just simpler but more robust than the current
hack which tries to undo the damage after the fact.

* src/lread.c (Flocate_file_internal): Don't map `.elc` to `.eln`.
* lisp/files.el (locate-file): Simplify accordingly.
2022-03-12 23:51:22 -05:00
Lars Ingebrigtsen
49683652f8 Further locate-file fixes on nativecomp
* lisp/files.el (locate-file): Fix up previous locate-file change
-- don't unconditionally return .elc on nativecomp.
2022-03-12 22:54:38 +01:00
Lars Ingebrigtsen
f8bb6cca33 Return the same file from locate-file in nativecomp and non
* lisp/files.el (locate-file): Return the .elc file (if it exists)
in nativecomp, too, to mimic the behaviour from non-nativecomp
builds (bug#51308).
2022-03-12 22:32:08 +01:00
Eli Zaretskii
a6b7bb2dfd Speed up exiting "emacs -Q"
* lisp/files.el (files--buffers-needing-to-be-saved): Don't call
functions from seq.el.  Using seq.el has an annoying side-effect
of slowing down "C-x C-c" from "emacs -Q" due to the need to load
seq.el.
2022-02-17 15:26:37 +02:00
Eli Zaretskii
a90dc11e24 Improve format of values returned by 'file-size-human-readable'
* lisp/files.el (file-size-human-readable): Emit one digit of the
fractional part of the size only if there's just one digit before
the decimal point.
2022-02-14 18:59:38 +02:00
Stefan Monnier
d52c929e31 (with-demoted-errors): Warn on missing format arg
The `format` arg has been mandatory for a while, but the backward
compatibility code that handled the case of a missing `format` arg
made it hard to notice when using the old calling convention.

* lisp/subr.el (with-demoted-errors): Warn on missing `format` arg.

* lisp/emacs-lisp/smie.el (smie-indent--separator-outdent): Don't abuse
`with-demoted-errors`.
(smie-indent-line, smie-auto-fill):
* test/lisp/emacs-lisp/ert-tests.el (ert-test-with-demoted-errors):
* lisp/vc/vc-hooks.el (vc-refresh-state):
* lisp/vc/vc-annotate.el (vc-annotate-background-mode):
* lisp/vc/diff-mode.el (diff-syntax-fontify-hunk):
* lisp/textmodes/reftex-toc.el (reftex-re-enlarge):
* lisp/progmodes/sh-script.el (sh-smie-sh-rules):
* lisp/progmodes/octave.el (inferior-octave-startup):
* lisp/pcmpl-gnu.el (pcmpl-gnu-make-all-targets):
* lisp/org/org-refile.el (org-refile):
* lisp/org/org-capture.el (org-capture-store-last-position):
* lisp/nxml/nxml-mode.el (nxml-mode):
* lisp/notifications.el (notifications-notify):
* lisp/gnus/mm-view.el (mm-display-inline-fontify):
* lisp/finder.el (finder-unload-function):
* lisp/files.el (safe-local-variable-p, backup-buffer-copy
* lisp/autorevert.el (auto-revert-notify-handler):
Pass `format` arg to `with-demoted-errors`.
2022-02-04 19:39:53 -05:00
Lars Ingebrigtsen
ce220524fc Fix up previous "Quit Emacs" from menu logic
* lisp/files.el (files--buffers-needing-to-be-saved): Separated
out into its own function...
(save-some-buffers): ... from here.
(save-buffers-kill-emacs): Check that we have anything to save
before prompting the user.
2022-01-27 22:26:12 +01:00
Lars Ingebrigtsen
b8ddd94aac Make the save buffers prompt from Quit Emacs menu more understandable
* lisp/files.el (save-buffers-kill-emacs): Use a much simpler (and
more understandable) prompt when exiting Emacs from the menu bar
(bug#4980).

* lisp/subr.el (use-dialog-box-p): Separate out into its own
function for reuse...
(y-or-n-p): ... from here.
2022-01-27 19:56:29 +01:00
Daniel Nicolai
d633db5189 Add support for EPUB, CBZ, FB2 and (O)XPS extension to doc view
* doc/emacs/misc.texi (Document View): Add requirements for new
extensions (i.e. mutool).

* lisp/doc-view.el (doc-view): Additionally update preliminary comment
(doc-view-custom-set-epub-font-size): redraw image after setting
(doc-view-unoconv-program): Put code all on one line
(doc-view-doc-type): Update docstring.
(doc-view-kill-proc): Fix comment indentation
(doc-view-mode-p):
Add check for new extensions and alternative check for PDF
(doc-view-pdf/ps->png): Associate new extension with png converter
(doc-view-convert-current-doc): Handle new extensions like PDF's
(doc-view-set-doc-type): Set correct doc-type for new extensions.

* lisp/files.el (auto-mode-alist):
Associate new extension types with doc-view.
2022-01-27 17:03:38 +01:00
Stefan Kangas
8f9f1701f6 Don't discourage auto-mode-alist entries in autoloads
* lisp/files.el (auto-mode-alist, interpreter-mode-alist): Delete
comment discouraging entries in autoload directives.  (Bug#8158)
2022-01-27 03:57:45 +01:00
Lars Ingebrigtsen
ffb0e8c4ef Make anonymous functions work in auto-mode-alist
* lisp/files.el (set-auto-mode--apply-alist): Don't infloop on
anonymous functions in auto-mode-alist (bug#20709).
2022-01-24 15:06:39 +01:00
Lars Ingebrigtsen
21a3bd9f36 Make message in hack-local-variables-confirm clearer
* lisp/files.el (hack-local-variables-confirm): Mention the
.dir-locals.el file in the message to be slightly less confusing
(bug#27066).
2022-01-23 17:09:55 +01:00