Commit graph

52 commits

Author SHA1 Message Date
Henrik Lissner
4c9df9bfc6
fix: partially revert OS detection changes
These changes snuck into ad6a3d0, but have not been implemented yet, so
some OS-specific functionality was orphaned.

Amend: ad6a3d0f33
2022-08-18 17:08:16 +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
a7e147088c
fix(cli): void-variable test error on Emacs 27.x
map.el integration for pcase wasn't introduced until 28.1; it was
premature to use it while we support 27.x.
2022-08-18 16:14:06 +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
e0385052a8
fix: void-function file-name-concat on Emacs 27
Amend: 05b344a852
2022-08-14 20:44:47 +02:00
Henrik Lissner
401a5aa530
refactor(docs): move doom-docs-dir to lib/docs.el
This is not an essential core variable, so it should be defined where it
used, instead.
2022-08-14 20:43:36 +02:00
Henrik Lissner
b943e4d73a
nit: add REVIEW tag for startup-redirect-eln-cache
startup-redirect-eln-cache adds the new directory and removes
$EMACSDIR/eln-cache from native-comp-eln-load-path, but it's not
available in 28.1, so we'll have to wait until Doom drops 28.1 support
to use it.
2022-08-14 20:43:36 +02:00
Henrik Lissner
aa54383b5d
refactor: deprecate doom-etc-dir for doom-data-dir
doom-etc-dir will be renamed to doom-data-dir, to better reflect its
purpose, and align it with XDG_DATA_HOME (where it will be moved to in
v3, where Doom will begin to obey XDG directory conventions more
closely).
2022-08-14 20:43:35 +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
ad6a3d0f33
refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00
Henrik Lissner
0407621aff
refactor: deprecate EMACS2[89]+, NATIVECOMP, MODULES
To reduce redundancy, remove the maintenance hassle that version
constants would impose later on, and rely on built-in
facilities (featurep) more over global variables or doomisms, these
global constants have been deprecated in favor of Emacs "features":

- EMACS28+   -- replace with (> emacs-major-version 27)
- EMACS29+   -- replace with (> emacs-major-version 28)
- NATIVECOMP -- replace with (featurep 'native-compile)
- MODULES    -- replace with (featurep 'dynamic-modules)

(These constants will be formally removed when v3 is released. The IS-*
constants are likely next, but I haven't decided on their substitutes
yet)

I also decided to follow native-compile's example and provide features
for Emacs' system features (since system-configuration-features' docs
outs itself as a poor method to detect features):

- dynamic-modules
- jansson
- native-compile -- this one already exists, but will instead be removed
  if it's non-functional; i.e. (native-comp-available-p) returns nil.

These are now detectable using featurep, which is fast and built-in.
2022-08-14 20:43:35 +02:00
Henrik Lissner
c540f1b515
perf(lib): memoize doom-system-* functions 2022-08-14 20:43:35 +02:00
Henrik Lissner
3239ab8b2e
nit(mu4e): neutralize comments
Some of our comments/docs can come off as disparaging or snide. They're
glimpses of unfiltered frustration or snarky rubber ducking gone too
far, something I can totally sympathize with, as a scatterbrained
tinkerer, unwittingly made responsible for a lot of work that isn't mine
because of Doom's position as a middleman. But now that Doom has a
veritable userbase, I'd like to hold it to a higher standard.

Light-hearted banter and aired grievances in our source code,
documentation, or community are fine if focused on the problem or the
personal/shared experiences of the community (things that offer value or
amusement to others), but it is never acceptable to attack people or
their efforts. Especially not the very people on whose shoulders Doom
stands.

I sincerely apologize if these have offended you.

Amend: b07614037f
2022-08-14 20:36:42 +02:00
Henrik Lissner
12bf6baa21
fix: void-function doom-reset-file-handler-alist-h
A regression introduced in 1d8c61698b. Doom disables its
file-name-handler-alist optimization if in a daemon session or if debug
mode is active.

Fix: #6657
Amend: 1d8c61698b
2022-08-10 17:29:01 +02:00
Henrik Lissner
05b344a852
refactor: move nativecomp deny-list to doom-packages
Also removes $EMACSDIR/eln-cache from native-comp-eln-load-path, to
reduce any chance of this taking precedence later.
2022-08-10 14:13:46 +02:00
Henrik Lissner
61ff5a4421
refactor(cli): set __DOOMCONTEXT at runtime
Addresses the edge case where the user sets (or unsets) __DOOMCONTEXT in
their CLI config.
2022-08-10 14:10:08 +02:00
Henrik Lissner
8191607093
refactor(cli): use more reliable means to assemble paths
Use filesystem to build or check paths, rather than regexps and string
concatenation.
2022-08-10 14:02:47 +02:00
Henrik Lissner
25ac752de2
fix(cli): file-missing error on comp-el-to-eln-filename
If you've moved $EMACSDIR, comp-el-to-eln-filename will throw errors
about missing directories/files, rendering 'doom sync' ineffective and
forcing the user to delete $EMACSDIR and reinstall Doom.
2022-08-10 13:18:34 +02:00
Henrik Lissner
2ff8228133
fix(docs): handle missing autoloads file in core doctor
Instead of a long winded backtrace about a missing autoloads file, let
the user know a 'doom sync' is needed.
2022-08-10 13:18:08 +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
1d8c61698b
fix: "symbol's value as variable is void: \213" error (part 2)
See 6f1c0f7cc7 for part 1.

Turns out startup.elc likely exists on most Emacs installations (and,
since it's so integral to Emacs, it likely gets special treatment), so
it was a poor heuristic for this fix. Instead, a more variable target
would be calc-loaddefs.el.

On some systems, only calc-loaddefs.el.gz exists (in which case, we
should turn off the optimization). On others, calc-loaddefs.el
exists (so I'll assume it's safe to leave them on). I won't check for
calc-loaddefs.elc because it doesn't matter; calc.el explicitly
calls (load "calc-loaddefs.el") so it is never loaded.

Of course, you can sidestep the entire issue by building Emacs with
--without-compress-install, but it's not practical for users to
know/want to do that.

Amend: 6f1c0f7cc7
2022-08-08 22:19:18 +02:00
Henrik Lissner
6f1c0f7cc7
fix: "symbol's value as variable is void: \213" error
Some installs of Emacs do not come with byte-compiled versions of its
bundled elisp files, so when loading them, Emacs falls back to loading
its *.el.gz files. This would be fine if it were not for a  startup
optimization Doom employs, where it sets file-name-handler-alist to
nil (and by doing so, robs Emacs of the ability to read compressed
elisp). This causes "symbol's value as variable is void: \213" errors at
startup.

With this commit, Doom now disables this optimization early if it
suspects this applies to your install. But time will tell if it's early
enough.

Ref: https://mail.gnu.org/archive/html/emacs-devel/2022-08/msg00234.html
2022-08-08 18:52:32 +02:00
Henrik Lissner
9c80b33b89
tweak: suppress defvaralias warnings 2022-08-08 18:23:47 +02:00
Henrik Lissner
232e9d4b91
fix: use --strip-cwd-prefix only if fd >=8.3.0
Since fd 8.3.0 has low availability across distros (see repology link
below), I don't want to make it Doom's minimum supported version.
Instead, I do a quick version check and adjust accordingly. I'll think
up a more elegant solution after v3.

Ref: https://repology.org/project/fd-find/versions
Fix: #6618
Fix: #6600
Close: #6597
2022-08-08 18:23:46 +02:00
Henrik Lissner
0f43c3eed5
fix(docs): org-glossary init
- Set org-glossary-global-terms buffer-locally,
- Move org-glossary init into a hook.
- Remove unneeded (require 'ox) (see tecosaur/org-glossary#6),

Ref: tecosaur/org-glossary#6
2022-08-07 19:43:28 +02:00
Henrik Lissner
8ec9e7ea0d
nit(docs): reformat and annotate
- Rename doom-docs--display-header-h -> doom-docs--display-menu-h to
  better represent what it does.
- Add comments to describe the purpose of lib/docs, and TODO annotations
  to hint at its future and remind me later.
2022-08-07 19:43:28 +02:00
Henrik Lissner
034ade0468
fix(lib): doom-debug-mode forgetting initial values
Of the variables that it changes (see doom-debug-variables).
2022-08-07 19:43:28 +02:00
Henrik Lissner
9b8ed397e8
feat!(cli): load project .doomrc instead of ci.el
BREAKING CHANGE: Before, 'doom ci' would load
$GIT_WORKING_TREE/.github/ci.el, to give users/projects an opportunity
to provide project-local configuration for bin/doom (mainly for CI/CD).
Now, this ci.el file is no longer loaded and instead, *all* bin/doom
sessions will walk up the file tree and load the first .doomrc it finds.

This gives bin/doom users a more general place configure all of its
commands, and not just 'doom ci' commands.

Extras:
- Adds .doomrc to auto-mode-alist (so that it starts in
  emacs-lisp-mode).
2022-08-07 19:43:28 +02:00
Henrik Lissner
422baedad7
refactor(cli): load cli libs from doom.el
This simplifies the entry point for loading Doom (and/or its CLI
framework).
2022-08-07 19:43:28 +02:00
Henrik Lissner
50f0cebe92
feat(cli): generalize 'doom make codeowners'
- Adds -o/--file option,
- If -o/--file is passed a dash, print codeowners to stdout,
- Adds --dryrun option,
- Will accept literal string entries in doom-make-codeowners as
  standalone lines (useful for comments).
2022-08-07 19:43:28 +02:00
Henrik Lissner
d92a81bf2d
feat(lib): add lib/git
Where future git wrappers will live.
2022-08-07 19:43:28 +02:00
Henrik Lissner
b7b2563f7b
feat(cli): add implicit date, time, duration, & size types 2022-08-07 19:43:28 +02:00
Henrik Lissner
e5acbd7c40
docs(cli): make file/dir/stdout type errors consistent 2022-08-07 19:43:27 +02:00
Henrik Lissner
d53e08767d
feat(cli): add stdout implicit arg type
CLIs can now use this for implicit validation for options that take a
file path or - to signal "print to stdout", like so:

  (defcli! (doom command) ((outfile ("--out" (file stdout))))
    (if (equal outfile "-")
        (print! "output")
      (with-temp-file outfile
        (insert "output"))))

If OUTFILE is not an existing file path or a -, you'll see an this
helpful error:

  Error: -o/--file received invalid value "FOO"

  Validation errors:
  - Must be a dash to signal stdout.
  - File does not exist.

  See 'doom h[elp] make codeowners' or 'doom make codeowners {-?,--help}' for documentation.
2022-08-07 19:43:27 +02:00
Henrik Lissner
26bc4ea150
feat(cli): allow multiple implicit types for options
Now you can specify more than one allowed (implicit) for a CLI option:

  (defcli! (doom somecommand) ((foo ("--foo" (file int)))))

This will test FOO to ensure it is either an existing file path or an
integer. If neither is true, you'll see this helpful error:

  Error: -o/--file received invalid value "FOO"

  Validation errors:
  - Not an integer.
  - Not a valid path to an existing file.
2022-08-07 19:43:27 +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
0ed2b95dba
refactor(cli): include envvars in _doomrun debug logs 2022-08-06 18:43:14 +02:00
Henrik Lissner
725de1ca35
perf(docs): disable gc for doom-docs-org-mode 2022-08-05 21:44:09 +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
2254b8c561
fix(cli): doom-cli-context persistence
20d5440 introduced a regression where options would be lost when a CLI
session is restarted. :config literate users, for example, would run
'doom sync -u' only for the -u option to be ignored, because it was
discarded after the literate module restarts the session.

Amend: 20d5440023
2022-08-05 00:49:17 +02:00
Henrik Lissner
55544200be
release(modules): 22.08.0-dev
Ref: 2b39e41368
2022-08-04 01:29:37 +02:00
Henrik Lissner
d6ffd2bfaa
fix(file-templates): update doom doc templates
To reflect the new mode: line added in 7e400ab, and add an ID property.
Also corrects heading level in __doom-readme file template.

Ref: 7e400abdc0
2022-08-04 01:15:23 +02:00
Henrik Lissner
c1512feea1
fix(docs): disable doom-docs--hide-stars-h
Hiding the stars with org-fold breaks org-cycle, so until I have time to
fix it, I'll disable this hook altogether.
2022-08-03 04:20:52 +02:00
Henrik Lissner
1f8bf7accb
merge: rewrite-docs
I've omitted docs/*.org from this merge, as there is still work left to
do there, but I am pushing the module docs early so folks can benefit
from the new docs sooner.
2022-08-03 03:27:50 +02:00
Henrik Lissner
52bda5f4e7
fix: move bookmark-default-file to doom-etc-dir
A regression introduced in 46844b55de moved bookmarks to
doom-cache-dir, which is not where user data belongs.

Fix: #6540
Amend: 46844b55de
2022-08-03 03:09:27 +02:00
Henrik Lissner
2d53fe6123
refactor: resolve doom-core-dir relative to source file
Instead of relative to doom-emacs-dir, which may or may not be where
this core lives (made more of a possibility once core has a repo to
itself).
2022-08-02 20:19:03 +02:00
Henrik Lissner
2bb052ac17
tweak(lib): fix doomemacs URLs in help commands 2022-08-02 20:15:29 +02:00
Henrik Lissner
4ee7f0113e
fix(cli): show straight logs after straight error
Instead of displaying an unhelpful backtrace about failed git commands,
show the tail of the *straight-process* buffer.
2022-07-31 23:44:10 +02:00
Henrik Lissner
55736ac2a6
fix(lib): prevent autoload failure at startup
In some edge cases, an early call to doom-log will cause an autoload
error because of one or more of the following is true:

- The autoloads file hasn't been generated or loaded,
- The autoloads file is out of date (especially relevant after
  b9933e6),
- doom-cli hasn't loaded lib/files eagerly yet.

To avoid this, and due to how prolific doom-log's uses are, and how
trivial the dependency is, I simply remove the dependency.

Amend: b9933e6637
2022-07-31 13:31:21 +02:00
Henrik Lissner
615848e3a7
fix(cli): more future resistant 'doom upgrade'
In the future, should doom-core-dir or {doom-core-dir}/packages.el
change, 'doom upgrade' won't leave the repo in a broken state.
Unfortunately, this cannot retroactively prevent the issue; users will
experience this as soon as they update to b9933e6 or beyond, so users
will have to upgrade manually to overcome it:

  cd ~/.emacs.d
  git reset --hard 35a89bdfa6
  git pull origin master
  doom sync -u

Fix: #6598
Amend: b9933e6637
2022-07-31 00:58:36 +02:00