Commit graph

2277 commits

Author SHA1 Message Date
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
Stefan Monnier
2dad332a14 (hack-local-variables--find-variables): Use user-error
* lisp/files.el (hack-local-variables--find-variables):
Incorrect formatting are not coding errors.
2022-01-17 16:28:02 -05:00
Stefan Monnier
917a623a9d Merge remote-tracking branch 'origin/emacs-28' into trunk 2022-01-12 15:57:29 -05:00
Glenn Morris
6e55127e04 * lisp/files.el (lock-file-name-transforms): Doc tweaks. 2022-01-12 10:36:05 -08:00
Stefan Monnier
f4e0562a2c (hack-one-local-variable-constantp): Mark as obsolete
* lisp/files.el (hack-one-local-variable-constantp): Mark as obsolete.
(hack-one-local-variable-eval-safep): Use `macroexp-const-p` instead.
2022-01-10 22:37:16 -05:00
Stefan Monnier
73b15f45f9 Merge remote-tracking branch 'origin/emacs-28' into trunk 2022-01-10 22:34:55 -05:00
Stefan Monnier
74223bbdaf (save-some-buffers): Simplify the fix for bug#46374
* lisp/files.el (save-some-buffers): Only check the
`save-some-buffers-function` property on functions from
`save-some-buffers-default-predicate` since callers which provide
a `pred` argument can arrange to compute `pred` themselves if needed.

* test/lisp/files-tests.el (files-tests-buffer-offer-save): Don't test
with `pred` set to `save-some-buffers-root` since it's not an
appropriate function for that any more.
2022-01-09 22:17:45 -05:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Stefan Monnier
1a724cc2d2 Replace uniquify.el's advice with direct calls
This fixes bug#1338.

* src/buffer.c (Frename_buffer): Call `uniquify--rename-buffer-advice`.
* lisp/files.el (create-file-buffer):
Call`uniquify--create-file-buffer-advice`.

* lisp/uniquify.el (uniquify--rename-buffer-advice)
(uniquify--create-file-buffer-advice): Don't add them as advice any more.
Adjust their calling convention accordingly.
2021-12-27 20:59:16 -05:00
Lars Ingebrigtsen
9ea5a915bd Make `C-c C-w' copy the executable bits to the new file
* lisp/files.el (write-file): When visiting an executable file,
make the new file executable, too (bug#18915).
2021-12-02 13:21:53 +01:00
Lars Ingebrigtsen
1914d946d6 Change how Dired displays available space
* doc/emacs/dired.texi (Misc Dired Features): Document it (bug#23812).
* lisp/dired.el (dired-free-space): New user option.
(dired-insert-directory): Use it from here.
(dired--insert-disk-space): New function that uses the user option.

* lisp/files.el (insert-directory): Don't transform "total" here.
* lisp/ls-lisp.el (ls-lisp--insert-directory): Or here.  Instead
just leave the "total <num>" bit alone, and let Dired transform it.

* test/lisp/files-tests.el (files-tests): Move "available" tests
to dired-tests.
* test/lisp/dired-tests.el (data-dir): Moved here.
2021-12-01 23:27:19 +01:00
Lars Ingebrigtsen
ec3b6fa8e1 Make `C-x C-d' require either an existing directory or a wildcard
* lisp/files.el (list-directory): Require either an existing
directory or a wildcard (bug#25807).
2021-12-01 20:16:57 +01:00
Stefan Kangas
4a3ba8528b Use substitute-command-keys for literal key sequences
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-help-for-help):
* lisp/calc/calc-mode.el (calc-auto-why):
* lisp/calc/calc.el (calc-do):
* lisp/calculator.el (calculator-mode):
* lisp/dired-aux.el (dired-create-files)
(dired-do-create-files-regexp, dired-create-files-non-directory):
* lisp/dired-x.el (dired-virtual):
* lisp/dired.el (dired-mark-region, dired-unmark-all-files):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/epa-ks.el (epa-ks--display-keys):
* lisp/erc/erc.el (erc-toggle-debug-irc-protocol):
* lisp/files.el (save-some-buffers):
* lisp/gnus/gnus-dired.el (gnus-dired-find-file-mailcap)
(gnus-dired-print):
* lisp/gnus/gnus-group.el (gnus-keep-same-level):
* lisp/gnus/gnus-score.el (gnus-score-find-trace):
* lisp/gnus/gnus.el (to-list):
* lisp/gnus/message.el (message--send-mail-maybe-partially):
* lisp/mail/supercite.el (sc-set-variable):
* lisp/minibuffer.el (minibuffer-inactive-mode):
* lisp/progmodes/etags.el (select-tags-table):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-char-mode-loop):
* lisp/replace.el (query-replace-help):
* lisp/simple.el (set-variable):
* lisp/subr.el (read-char-from-minibuffer):
* lisp/textmodes/ispell.el (ispell-help, ispell-message):
* lisp/textmodes/reftex-global.el (reftex-find-duplicate-labels):
* lisp/textmodes/reftex-vars.el
(reftex-toc-include-file-boundaries)
(reftex-toc-include-labels, reftex-toc-include-index-entries)
(reftex-toc-include-context, reftex-toc-follow-mode)
(reftex-index-include-context, reftex-index-follow-mode)
(reftex-enable-partial-scans)
(reftex-auto-update-selection-buffers)
(reftex-highlight-selection):
* lisp/time.el (display-time-update):
* lisp/vc/ediff-help.el (ediff-help-for-quick-help):
* lisp/vc/ediff-init.el (ediff-keep-variants):
* lisp/vc/ediff-ptch.el (ediff-fixup-patch-map)
(ediff-patch-file-internal):
* lisp/windmove.el (windmove-delete-default-keybindings): Use
'substitute-command-keys' for literal key sequences.

* lisp/userlock.el (userlock--fontify-key): Remove function.
(ask-user-about-lock, ask-user-about-lock-help)
(ask-user-about-supersession-threat)
(ask-user-about-supersession-help): Use 'substitute-command-keys' for
literal key sequences.

* lisp/ibuffer.el (ibuffer-unmark-all): Use 'substitute-command-keys'
for command.
2021-11-22 12:04:19 +01:00
Stefan Monnier
64497fb8cc * lisp/files.el (file-has-changed-p): Index the cache with absolute file names 2021-11-18 22:06:50 -05:00