Commit graph

27 commits

Author SHA1 Message Date
Henrik Lissner
9c4a4cf058
fix(lib): remove-recent-file: improve completion UI
Integrates with completion frameworks (particularly vertico) that read
capf metadata.
2024-05-21 17:17:13 +02:00
Henrik Lissner
5bdfecfa92
feat(lib): sudo-{find,this}-file: invoke save-place
After switching to the sudo-ed tramp buffer, this restores the point and
scroll position of the window to match the source buffer.

I exploit save-place here instead of simply saving/restoring (point)
and (window-start), because I believe it's better UX that save-place
treat the two buffers as effectively the same now and in the future, and
record the last cursor position equally between them, even if the
implementation is messier. This *could* be generalized into an advice
for save-place-find-file-hook and save-place-to-alist, but that's an
experiment for another day.

This is an experimental implementation and may change later.

Close: #7181
Co-authored-by: YourFin <YourFin@users.noreply.github.com>
2024-05-21 17:17:12 +02:00
Henrik Lissner
d792f0dbb1
fix(lib): sudo-{find,this}-file: disable auto-save
auto-save can trigger processes that hang silently in the background,
making those buffers inoperable (hanging Emacs) for the rest of the
session, even if they are killed (tramp caches them), so I suppress them
solely for these temporary tramp buffers created by doom/sudo-find-file
and doom/sudo-this-file.
2024-05-21 17:17:11 +02:00
Henrik Lissner
a37d801a48
fix(lib): find-subling-file-search: wrong-number-of-args error
I backported `find-sibling-file` from Emacs 29+ in 198fe82, but it
passes a third argument (REGEXP) to `file-expand-wildcards` which wasn't
introduced until 29, so users on 28 or earlier would see a
wrong-number-of-arguments error (see #7795).

Rather than backport the entire `file-expand-wildcards`
function (risking other edge cases), I've advised its usage in
`find-sibling-file-search` to behave as it would in 29+ with a non-nil
REGEXP argument.

Amend: 198fe82b6d49
Fix: #7795
2024-05-21 17:17:10 +02:00
Henrik Lissner
48e62928e4
fix(lib): sudo-{this,save}-file: file path for indirect clones
If the buffer is an indirect clone, it may not have a buffer-file-name.

Also changes the command to throw an error if the current file has no
file path *and* is not a dired buffer.
2024-05-21 17:17:08 +02:00
Henrik Lissner
51dcf7da6a
feat(lib): backport find-sibling-file
I will slowly phase out projectile in favor of project.el, starting with
projectile-find-other-file, which -- as of Emacs 29 -- has a native
alternative: `find-sibling-file`.

Ref: doomemacs/community#1
2024-05-21 17:16:52 +02:00
Mathew
e3deab3e21
fix(lib): doom/sudo-find-file: expand given path
It's possible for the user to type shell variables (something like
`$MYVAR/dir/filename`) as part of the filepath, so we need to call
`expand-file-name`.
2024-05-21 17:16:44 +02:00
Henrik Lissner
13b1f06c13
feat(lib): doom-file-write: separate :mode for directories
doom-file-write's :mode parameter now accepts a cons cell, whose CDR
will determine the file mode for directories that get implicitly created
by the function.
2024-05-21 17:16:31 +02:00
Tim Ruffing
ef27b3da12
tweak(lib): write elisp in escaped form to files 2024-05-21 17:16:29 +02:00
Tim Ruffing
cb8163a262
fix(lib): use unibyte in binary temp buffers 2024-05-21 17:16:29 +02:00
Tim Ruffing
ce0882b053
docs(lib): improve docs of doom-file-read/-write 2024-05-21 17:16:29 +02:00
Henrik Lissner
2c652259a5
tweak(lib): open file after doom/copy-this-file
As mentioned in #6964, it's rare for anyone to want to copy a file
without opening the new file.

Close: #6964
2023-02-18 15:27:48 -05:00
Ivan
850907ed9a
fix(lib): doom/delete-this-file nil path handling
Fix the handling of a nil path within doom/delete-this-file.

If path is nil (e.g. called interactively when buffer is not visiting a
file), avoid calling abbreviate-file-name on nil, otherwise an error
will be signaled:

  (wrong-type-argument stringp nil)

Additionally, fix the subsequent path checks. These were treating two
distinct scenarios as a "Buffer is not visiting any file" user-error:

- nil path
- non-existent path
- Only the first should result in that error. The second should proceed
  to the next path check (which was previously unreachable), to signal
  the appropriate error, "File doesn't exist: %s".
2022-09-30 22:48:59 +02:00
Henrik Lissner
4efaf6837b
refactor: introduce doom-module-context
Where f9201eb introduced a general context system, this one introduces
one for modules, to simplify our let-bind game when interacting with
modules, and to more efficiently expose module state to modulep! (which
gets called at runtime a great deal, so its performance is important).

* lisp/doom-lib.el (doom-log): simplify macro and introduce
  doom-inhibit-log variable.
* lisp/doom-modules.el (modulep!): fix reported file path if modulep!
  fails to find the local module.
* lisp/lib/debug.el (doom-debug-variables): disable doom-inhibit-log
  when debug mode is on.

Ref: f9201eb218
2022-09-24 22:09:46 +02:00
Henrik Lissner
dde728d847
fix(lib): void-function insert-into-buffer on Emacs 27
insert-into-buffer was introduced in 28.1
2022-09-16 01:14:20 +02:00
Henrik Lissner
0ce2989d86
refactor(lib): remove redundant full? arg in doom-glob
file-expand-wildcards already does this check, internally.
2022-09-12 11:45:59 +02:00
Henrik Lissner
45a66cda60
fix: ensure module state is in scope for modulep!
Otherwise, doom-module-from-path (and modulep!) would fail to detect the
module they're in, or at least, modulep! would incorrectly return nil,
even for enabled modules.

This issue is what would've caused the package list or the doctor to
include/consider packages in disabled modules or behind disabled flags.
2022-09-10 19:11:03 +02:00
Henrik Lissner
cd269753cf
fix(lib): leave point at bob in with-file-contents!
with-file-contents!'s docstring promises that point will end up at the
beginning of the buffer, but this promise wasn't kept until now.
2022-09-08 00:24:16 +02:00
Henrik Lissner
b121c5e1c6
refactor(lib): provide doom-libs as subfeatures
This allows us to load them via doom-require. Why not use normal
features? Because Doom's libraries are designed to be loaded as part of
Doom, and will openly rely on Doom state if needed; this is a contract I
want to enforce by ensuring their only entry points are through
`doom-require` or autoloading.

I will add them to the rest of the libraries later.

Site-node: this also adds Commentary+Code to the comment headings, as I
want a space to use that space to describe the library, when I get
around to it.
2022-09-08 00:20:26 +02:00
Henrik Lissner
b93f398568
refactor(lib): enforce namespace for helpers 2022-09-06 23:26:05 +02:00
Henrik Lissner
83f18402e3
feat(lib): add with-file! & with-file-contents! macros
Convenience macros to express more succinctly the with-temp-buffer +
insert-file-contents + write-region idiom for file IO in elisp.
2022-09-06 22:55:48 +02:00
Henrik Lissner
8d4b6b3028
feat(lib): add doom-file-{read,write} functions
A concise alternative to the file IO elisp idioms we're used to,
involving some combination of with-temp-file, with-temp-buffer,
insert-file-contents, coding-system-for-{read,write}, write-region, read
loops, print-to-current-buffer loops, etc.

These were engineered to make reading/writing text and lisp data from/to
files simpler, and will be used extensively in the v3 CLI.
2022-09-06 22:55:48 +02:00
Henrik Lissner
e986d6bef9
refactor(lib): deprecate doom-dir
This function never really added much value over doom-path or
file-name-concat, so I'm phasing it out.
2022-09-06 22:55:48 +02:00
Henrik Lissner
f66d9e1f0e
feat(lib): only return dirs if doom-glob SEGMENTS end with /
Also, doom-glob will return relative paths if SEGMENTS don't form an
absolute path.
2022-09-06 22:55:48 +02:00
Henrik Lissner
cadc778a03
perf(lib): optimize doom-path
Consecutive expand-file-name and recursive apply's can be expensive, so
the function has been simplified to rely more on file-name-concat. This
does change one trait about it, however: absolute paths in SEGMENTS no
long reroot the whole path, and are concatenated as ordinary file
segments.

The performance benefit is more pronounced on Emacs 28+, and will be
even more so when Doom later starts byte-compiling its libraries.
2022-09-06 22:55:48 +02:00
Henrik Lissner
057e6c531c
refactor: replace doom-enlist with ensure-list
doom-enlist is now a deprecated alias for ensure-list, which is built
into Emacs 28.1+ and is its drop-in replacement. We've already
backported it for 27.x users in doom-lib (in 4bf4978).

Ref: 4bf49785fd
2022-08-07 19:43:13 +02:00
Henrik Lissner
b9933e6637
refactor!: restructure Doom core
BREAKING CHANGE: This restructures the project in preparation for Doom
to be split into two repos. Users that have reconfigured Doom's CLI
stand a good chance of seeing breakage, especially if they've referred
to any core-* feature, e.g.

  (after! core-cli-ci ...)

To fix it, simply s/core-/doom-/, i.e.

  (after! doom-cli-ci ...)

What this commit specifically changes is:
- Renames all core features from core-* to doom-*
- Moves core/core-* -> lisp/doom-*
- Moves core/autoloads/* -> lisp/lib/*
- Moves core/templates -> templates/

Ref: #4273
2022-07-30 22:41:13 +02:00
Renamed from core/autoload/files.el (Browse further)