Commit graph

21 commits

Author SHA1 Message Date
Henrik Lissner
6cac7b05b6
refactor(lib): tidy doom-log output
This commit reduces the debug log noise, makes it easier to
read/parse/search, and soft-introduces a convention for doom-log
messages, where they are prefixed with a unique identifier loosely named
after it's running context or calling function.

I haven't enforced it everywhere doom-log is used yet, but this is a
start.
2022-09-12 16:01:43 +02:00
Henrik Lissner
3505e666a8
fix: failure to load doom libs on 27.x
Emacs 27.x does not collapse consecutive slashes in a file path when
trying to load them, and instead discards everything before it and
treats the rest as an absolute path, e.g. "~/some//path/foo/" ->
"/path/foo". This is not the case in 28.1, but Doom's backport of
file-name-concat did not take this into account, so it's been modified
to trim trailing slashes.

Fix: #6766
Amend: 433c9e344d
2022-09-10 18:33:02 +02:00
Henrik Lissner
eb80d461df
fix(lib): void-function macroexp-file-name error
This function was introduced in Emacs 28.1, so 7e0c2ed was a breaking
change for 27.x users.

Fix: #6766
Amend: 7e0c2ed8a3
2022-09-10 13:03:53 +02:00
Henrik Lissner
f3e85afc7e
fix(lib): ensure after! body gets expanded
Relying on eval-after-load's compiler-macro magic (after 8b4f722) can
cause scope issues with nested macros (like file! and dir! running in
the context of a temp buffer), so best we use with-eval-after-load
directly.

Ref: 8b4f722fa3
2022-09-10 11:59:48 +02:00
Henrik Lissner
7e0c2ed8a3
fix(lib): convert file! and dir! to macros
To ensure that they're expanded at a file's top-level, while expanded,
where they're used. It also fixes a few inlined uses of the file!
macro (e.g. in `load!`, as reported in #6764), which was prematurely
committed ahead of this change.

Close: #6764
Amend: a179b8d262
2022-09-10 11:59:17 +02:00
Henrik Lissner
a179b8d262
feat(lib): add doom-{require,load}
These functions are light wrappers around require and load, such that
Doom will catch (and decorate) any errors from the target file, and is
also capable of loading Doom's subfeatures.
2022-09-07 23:19:37 +02:00
Henrik Lissner
0a51fdff53
refactor(lib): move doom-log to doom-lib
This is such an essential macro that it should be universally available,
and not stowed away in the print library.
2022-09-06 23:46:42 +02:00
Henrik Lissner
4009509db5
feat(lib): add eval-when-compile! macro
Unlike eval-when-compile, the body of this macro's calls will only be
evaluated while byte-compiling.
2022-09-06 22:55:48 +02:00
Henrik Lissner
338f59c456
feat(lib): backport bol & eol from 29
Ref: emacs-mirror/emacs@f117b5df4d
2022-09-06 22:55:46 +02:00
Henrik Lissner
2b01166d1d
feat(lib): backport with-memoization from 29
Ref: emacs-mirror/emacs@3c972723e4
2022-09-06 22:55:46 +02:00
Henrik Lissner
edaa887bd9
refactor(lib): add + use defbackport! macro
In the future, doom-lib (among other things) will be byte-compiled as
part of 'doom sync'. To spare runtime the overhead of checking for these
functions, I've wrapped these in a macro. It also makes their
definitions a tad simpler.
2022-09-06 22:55:46 +02:00
Henrik Lissner
5ebc2528d8
perf(lib): use symbol plist for fn! lookup table
A good deal faster than alists at this scale.
2022-09-06 22:55:46 +02:00
Henrik Lissner
65c86ea3ff
feat(lib): backport with-environment-variables from 28.1
And alias letenv! to it. Not sure if I want to deprecate it though,
given the length of the macro it's linked to...
2022-09-06 22:55:46 +02:00
ivanbrennan
c44bc81a05 fix(lib): defer-feature! fallback FNS
If defer-feature! was called with one argument (as is the case in the
:lang common-lisp module), FNS defaulted to an empty list. As a result,
FEATURE was deferred but never re-added to the features list, and after!
blocks were never triggered.

Instead of defaulting to an empty list, fallback to a singleton list
containing just (FEATURE). This aligns with the behavior this macro had
prior to 5b8b04f0c8, which generalized FNS
to support a list of functions rather than just one.
2022-08-19 11:24:34 +02:00
Henrik Lissner
8b4f722fa3
docs(lib): update after! to reflect changes upstream
It used to be that after! suppressed macro expansion, but at some point
around 28.1, the elisp interpreter started recognizing the
compiler-macro hint in eval-after-load's definition; implicitly wrapping
quoted forms in a function. Therefore, we can no longer rely on
eval-after-load to hide macros from the byte-compiler. Instead, modules
will need to take care to wrap macro calls in `eval` or similar, on a
case-by-case basis.
2022-08-18 16:27:57 +02:00
Henrik Lissner
050624d475
fix(lib): nested interpolation & order of args for fn! macro
This fixes a couple bugs with this macro:

- Nested %-refs (in nested fn!'s) were interpolated as arguments of the
  outer-most fn!. E.g. (fn! (fn! %2)) would expand to:

  Before this fix:

    (lambda (_%1 %2)
      (lambda (_%1 %2)
        %2))

  After this fix:

    (lambda ()
      (lambda (_%1 %2)
        %2))

- Unused arguments were not only listed in the wrong order, they were
  off-by-one. E.g.

    (fn! %3 %5) expands to (lambda (_%4 _%3 %3 _%1 %5) %3 %5)

  This never caused any actual issues, but it was unexpected.

I've also moved the lookup table to `fn!`, and removed unnecessary
entries from it.
2022-08-15 22:12:45 +02:00
Henrik Lissner
a5c80fcb4b
refactor: deprecate doom-private-dir for doom-user-dir
- Deprecates the doom-private-dir variable in favor of doom-user-dir.
- Renames the pseudo category for the user's module: :private -> :user.
- Renames the doom-private-error error type to doom-user-error.

Emacs uses the term "user" to refer to the "things" in user space (e.g.
user-init-file, user-emacs-directory, user-mail-address, xdg-user-dirs,
package-user-dir, etc), and I'd like to be consistent with that. It also
has the nice side-effect of being slightly shorter. I also hope
'doom-user-error' will be less obtuse to beginners than
'doom-private-error'.
2022-08-14 20:43:35 +02:00
Henrik Lissner
b763c5b992
fix: file-name-handler-alist ignoring user changes
Unsetting file-name-handler-alist around a `load` call prevents any
change to this variable from surviving that file's evaluation (e.g. by
packages loaded therein). Since the user's config files are loaded with
this macro, this affects users' configs, which is unacceptable.

Since this optimization is already done in early-init.el, we can get
away with being more selective here.
2022-08-08 22:20:11 +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
433c9e344d
feat(lib): backport file-name-concat from 28.1
May replace doom-path in the future.
2022-08-05 17:35:46 +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/core-lib.el (Browse further)