Commit graph

5163 commits

Author SHA1 Message Date
Henrik Lissner
2e9997a3d5
fix(cli): void-variable doom-repo-* errors on 'doom upgrade'
Amend: 6c0b7e1530
2022-06-19 01:10:54 +02:00
Henrik Lissner
d5db9076af
fix(cli): wrong-number-of-args error on 'doom sync'
Amend: 6c0b7e1530
2022-06-19 01:07:01 +02:00
Henrik Lissner
81a52402b2
fix(cli): void-variable packages-only?
Amend: 6c0b7e1530
2022-06-19 01:05:26 +02:00
Henrik Lissner
daad6bc21d
feat(cli): add 'doom make completions' for zsh
'doom make completions' will generate a rudimentary ZSH completion
script for bin/doom. It can be used from your shell dotfiles, but I
recommend caching the output with a function like:
https://github.com/hlissner/dotfiles/blob/master/config/zsh/.zshenv#L1-L14.

Then add this to your .zshrc:

  _cache doom make completions --zsh && compdef _doom doom

Ref: https://github.com/hlissner/dotfiles/blob/master/config/zsh/.zshenv#L1-L14
2022-06-18 23:53:12 +02:00
Henrik Lissner
6c0b7e1530
refactor!(cli): rewrite CLI framework libraries
BREAKING CHANGE: this changes Doom's CLI framework in subtle ways, which
is listed in greater detail below. If you've never extended Doom's CLI,
then this won't affect you, but otherwise it'd be recommended you read
on below.

This commit focuses on the CLI framework itself and backports some
foundational changes to its DSL and how it resolves command line
arguments to CLIs, validates input, displays documentation, and persists
state across sessions -- and more. This is done in preparation for the
final stretch towarding completing the CLI rewrite (see #4273).

This is also an effort to generalize Doom's CLI (both its framework and
bin/doom), to increase it versatility and make it a viable dev tool for
other Doom projects (on our Github org) and beyond.

However, there is a *lot* to cover so I'll try to be brief:

- Refactor: generalize Doom's CLI framework by moving all bin/doom
  specific configuration/commands out of core-cli into bin/doom. This
  makes it easier to use bin/doom as a project-agnostic development
  tool (or for users to write their own).
- Refactor: change the namespace for CLI variables/functions from
  doom-cli-X to doom-X.
- Fix: subcommands being mistaken as arguments. "doom make index" will
  resolve to (defcli! (doom make index)) if it exists,
  otherwise (defcli! (doom make)) with "index" as an argument. Before
  this, it would resolve to the latter no matter what. &rest can
  override this; with (defcli! (doom make) (&rest args)), (defcli! (doom
  make index)) will never be invoked.
- Refactor!: redesign our output library (was core/autoload/output.el,
  is now core/autoload/print.el), and how our CLI framework buffers and
  logs output, and now merges logs across (exit! ...) restarts.
- Feat: add support for :before and :after pseudo commands. E.g.

    (defcli! (:before doom help) () ...)
    (defcli! (:after doom sync) () ...)

  Caveat: unlike advice, only one of each can be defined per-command.
- Feat: option arguments now have rudimentary type validation (see
  `doom-cli-option-arg-types`). E.g.

    (defcli! (doom foo) ((foo ("--foo" num))) ...)

  If NUM is not a numeric, it will throw a validation error.

  Any type that isn't in `doom-cli-option-arg-types` will be treated as a
  wildcard string type. `num` can also be replaced with a specification,
  e.g. "HOST[:PORT]", and can be formatted by using symbol quotes:
  "`HOST'[:`PORT']".
- Feat: it is no longer required that options *immediately* follow the command
  that defines them (but it must be somewhere after it, not before). E.g.
    With:
      (defcli! (:before doom foo) ((foo ("--foo"))) ...)
      (defcli! (doom foo baz) () ...)
    Before:
      FAIL: doom --foo foo baz
      GOOD: doom foo --foo baz
      FAIL: doom foo baz --foo
    After:
      FAIL: doom --foo foo baz
      GOOD: doom foo --foo baz
      GOOD: doom foo baz --foo
- Refactor: CLI session state is now kept in a doom-cli-context struct (which
  can be bound to a CLI-local variable with &context in the arglist):

    (defcli! (doom sync) (&context context)
      (print! "Command: " (doom-cli-context-command context)))

  These contexts are persisted across sessions (when restarted). This is
  necessary to support seamless script restarting (i.e. execve
  emulation) in post-3.0.
- Feat: Doom's CLI framework now understands "--". Everything after it will be
  treated as regular arguments, instead of sub-commands or options.
- Refactor!: the semantics of &rest for CLIs has changed. It used to be "all
  extra literal, non-option arguments". It now means *all* unprocessed
  arguments, and its use will suppress "unrecognized option" errors, and
  tells the framework not to process any further subcommands. Use &args
  if you just want "all literal arguments following this command".
- Feat: add new auxiliary keywords for CLI arglists: &context, &multiple,
  &flags, &args, &stdin, &whole, and &cli.
  - &context SYM: binds the currently running context to SYM (a
    `doom-cli-context` struct). Helpful for introspection or passing
    along state when calling subcommands by hand (with `call!`).
  - &stdin SYM: SYM will be bound to a string containing any input piped
    into the running script, or nil if none. Use
    `doom-cli-context-pipe-p` to detect whether the script has been
    piped into or out of.
  - &multiple OPTIONS...: allows all following OPTIONS to be repeated. E.g. "foo
    -x a -x b -x c" will pass (list ("-x" . "a") ("-x" . "b") ("-x" .
    "c")) as -x's value.
  - &flags OPTIONS...: All options after "&flags" get an implicit --no-* switch
    and cannot accept arguments. Will be set to :yes or :no depending on which flag is
    provided, and nil if the flag isn't provided. Otherwise, a default
    value can be specified in that options' arglist. E.g.

      (defcli! (doom foo) (&flags (foo ("--foo" :no))) ...)

    When called, this command sets FOO to :yes if --foo, :no if --no-foo, and
    defaults to :no otherwise.
  - &args SYM: this replaces what &rest used to be; it binds to SYM a
    list of all unprocessed (non-option) arguments.
  - &rest SYM: now binds SYM to a list of all unprocessed arguments, including
    options. This also suppresses "unrecognized option" errors, but will render
    any sub-commands inaccessible. E.g.

      (defcli! (doom make) (&rest rest) ...)
      ;; These are now inaccessible!
      (defcli! (doom make foo) (&rest rest) ...)
      (defcli! (doom make bar) (&rest rest) ...)
  - &cli SYM: binds SYM to the currently running `doom-cli` struct. Can also be
    obtained via `(doom-cli-get (doom-cli-context-command context))`. Possibly
    useful for introspection.
- feat: add defobsolete! macro for quickly defining obsolete commands.
- feat: add defalias! macro for quickly defining alias commands.
- feat: add defautoload! macro for defining an autoloaded command (won't
  be loaded until it is called for).
- refactor!: rename defcligroup! to defgroup! for consistency.
- fix: CLIs will now recursively inherit plist properties from parent
  defcli-group!'s (but will stack :prefix).
- refactor!: remove obsolete 'doom update':
- refactor!: further generalize 'doom ci'
  - In an effort to generalize 'doom ci' (so other Doom--or
    non-doom--projects can use it), all its subcommands have been
    changed to operate on the current working directory's repo instead
    of $EMACSDIR.
  - Doom-specific CI configuration was moved to .github/ci.el.
  - All 'doom ci' commands will now preload one of \$CURRENT_REPO_ROOT/ci.el or
    \$DOOMDIR/ci.el before executing.
- refactor!: changed 'doom env'
  - 'doom env {-c,--clear}' is now 'doom env {clear,c}'
  - -r/--reject and -a/--allow may now be specified multiple times
- refactor!: rewrote CLI help framework and error handling to be more
  sophisticated and detailed.
- feat: can now initiate $PAGER on output with (exit! :pager) (or use
  :pager? to only invoke pager is output is longer than the terminal is
  tall).
- refactor!: changed semantics+conventions for global bin/doom options
  - Single-character global options are now uppercased, to distinguish them from
    local options:
    - -d (for debug mode) is now -D
    - -y (to suppress prompts) is now -!
    - -l (to load elisp) is now -L
    - -h (short for --help) is now -?
  - Replace --yes/-y switches with --force/-!
  - -L/--load FILE: now silently ignores file errors.
  - Add --strict-load FILE: does the same as -L/--load, but throws an error if
    FILE does not exist/is unreadable.
  - Add -E/--eval FORM: evaluates arbitrary lisp before commands are processed.
  - -L/--load, --strict-load, and -E/--eval can now be used multiple times in
    one command.
  - Add --pager COMMAND to specify an explicit pager. Will also obey
    $DOOMPAGER envvar. Does not obey $PAGER.
- Fix #3746: which was likely caused by the generated post-script overwriting
  the old mid-execution. By salting the postscript filenames (with both an
  overarching session ID and a step counter).
- Docs: document websites, environment variables, and exit codes in
  'doom --help'
- Feat: add imenu support for def{cli,alias,obsolete}!

Ref: #4273
Fix: #3746
Fix: #3844
2022-06-18 23:53:12 +02:00
Henrik Lissner
336e7f0087
perf(lib): use syntax table instead of major mode
Should speed up doom/info a bit, and reduce potential edge cases caused
by emacs-lisp-mode hooks.
2022-06-18 16:57:17 +02:00
Henrik Lissner
4c97de4163
refactor: remove custom projectile-mode-line-function
projectile guards its projectile-update-mode-line calls with
file-remote-p checks, so this is redundant.

Ref: 4d6da873ae/projectile.el (L5791-L5793)
2022-06-18 16:57:17 +02:00
Henrik Lissner
8ffd32b7c4
refactor: s/raxod502/radian-software
Amend: 77e9932966
2022-06-18 16:57:17 +02:00
Henrik Lissner
4bf49785fd
feat(lib): backport ensure-list from 28+
And deprecate doom-enlist, which it replaces.
2022-06-18 16:57:17 +02:00
Henrik Lissner
1402db5129
refactor: how Doom starts up
Restructures Doom's primary core files and entry points to prepare for
backports (from the new CLI) coming soon.

- Removes $EMACSDIR/init.el.
- Doom configures Emacs to ignore ~/.emacs and ~/_emacs files.
- Doom's bootstrapper for interactive sessions was moved out of core.el
  and doom-initialize into doom-start.el. This change is preparation for
  Doom's new profile system (coming soon™️), where this bootstrapper
  will be dynamically generated.
- core.el and early-init.el have been reorganized, comment headers moved
  around, and comments updated to reflect these changes.
2022-06-18 16:54:45 +02:00
Henrik Lissner
46844b55de
refactor: how doom prevents $EMACSDIR litter
I change `user-emacs-directory' because most (if not all) packages --
even built-in ones -- abuse it exclusively to build paths for
storage/cache files (instead of correctly using
`locate-user-emacs-file'). This ensures your $EMACSDIR isn't littered
with data files *and* saves us the trouble of setting every
directory/file variable under the sun.

Granted, this introduces an edge case for any legitimate uses of the
variable (e.g. where the caller seeks to locate the user's initfiles),
but I've found no such uses in any of the packages I've audited for Doom
or elsewhere.
2022-06-18 08:26:01 +02:00
Henrik Lissner
196adfb28d
tweak: disable gnutls-verify-error in interactive sessions
NSM has better UX when an invalid/expired certificate is encountered: it
prompts the user to decide what to do with it. If gnutls-verify-error is
non-nil, gnutls either kills or hangs the connection. This is (mostly)
acceptable in noninteractive sessions, where I can more tightly control
outgoing connections, but not in interactive sessions where I stand a
higher chance of stepping on the user's toes instead.

Ref: emacs-circe/circe#405
2022-06-17 20:28:07 +02:00
Henrik Lissner
c4ac2ab384
fix: void-function doplist! in package!
The macro was removed a short while ago, and I forgot to include this
change with it.

Amend: cb03d3258d
2022-06-17 18:59:11 +02:00
Henrik Lissner
77e9932966
bump: :core
Fuco1/smartparens@37f77bf2e2 -> Fuco1/smartparens@ec15aaa748
Wilfred/helpful@67cdd1030b -> Wilfred/helpful@209971ba9f
bbatsov/projectile@f3468e8d20 -> bbatsov/projectile@4d6da873ae
domtronn/all-the-icons.el@65c496d3d1 -> domtronn/all-the-icons.el@ca1ef30004
emacs-straight/project@4fe1eec803 -> emacs-straight/project@c52ec93689
jscheid/dtrt-indent@66fc30af02 -> jscheid/dtrt-indent@57f4072fa8
justbur/emacs-which-key@1217db8c63 -> justbur/emacs-which-key@1ab1d0cc88
raxod502/straight.el@e2de88ea0e -> radian-software/straight.el@0e204d418d

Includes a fix for #5207 (see radian-software/straight.el#955), which
occasionally caused arrayp errors when installing/upgrading packages.

Fix: #5207
Ref: radian-software/straight.el#955
2022-06-17 18:21:23 +02:00
Henrik Lissner
2f7171bf8a
refactor(lib): remove doom-apply-ansi-color-to-compilation-buffer-h
Is redundant with ansi-color-compilation-filter.

Ref: aec4fbe590
2022-06-17 18:21:23 +02:00
Henrik Lissner
cb03d3258d
refactor!(lib): remove {doplist!,plist-delete!,doom-plist-delete}
BREAKING CHANGE: With 26.x support dropped, I've dropped:

- doom-plist-delete: use map-delete instead
- plist-delete!: use cl-callf + map-delete instead
- doplist: use (cl-loop for X on PLIST by #'cddr ...) instead

These were removed as part of an ongoing effort to eliminate
redundancies with built-in packages and reduce Doom's overall footprint.
2022-06-17 18:21:22 +02:00
Henrik Lissner
fd12794930
refactor(lib): use cl-callf instead of plist-{put,delete}!
I rediscovered cl-callf and decided to cut down on redundancies.
2022-06-17 18:20:45 +02:00
Henrik Lissner
dea74acb7a
fix(lib): void-variable error in doom/add-directory-as-project
And clarify how it differs from projectile-add-known-project in the
command's docstring.
2022-06-10 13:13:10 +02:00
Henrik Lissner
c78a3dc1f5
fix(lib): unknown type: consp on Emacs 29+
This was removed from cl-lib's known datatypes (in favor of "cons") in
Emacs 29.
2022-06-10 13:12:22 +02:00
Henrik Lissner
bea3cc161c
fix: find-function-search-for-symbol moving cursor
For symbols defined in the current buffer, for Emacs 29+ users.
2022-06-04 15:02:06 +02:00
Henrik Lissner
f96c666460
tweak: add $XDG_RUNTIME_DIR to recentf-exclude
Ref: eb170a7a38
2022-06-04 15:02:06 +02:00
Henrik Lissner
60df67de34
release(modules): 22.06.0-dev
Ref: 2b39e41368
2022-06-04 15:02:06 +02:00
Henrik Lissner
797866b596
fix(cli): doom run not launching from parent dir
'doom run' was launching out of Emacs' default
directories (~/.config/emacs and ~/.emacs.d) instead of the parent
directory of bin/doom. This commit corrects that, but is a temporary
measure until the CLI rewrite. I'm also not totally sure this will work
on Windows...

Fix: #6389
2022-06-04 15:01:49 +02:00
Henrik Lissner
eb170a7a38
tweak: add /run to recentf-exclude 2022-05-27 00:35:37 +02:00
Henrik Lissner
76e6dcd550
refactor: replace yes-or-no-p advice w/ use-short-answers
This option was introduced in 28.1.
2022-05-27 00:35:37 +02:00
Henrik Lissner
0e2fa0ba19
fix(lib): type error on doom/restart-and-restore
On Windows, restart-emacs doesn't escape its arguments properly (#6219).
56686f677a attempted to fix this, but ended up breaking it for
everyone else as well, causing the type error:

  Wrong type argument: listp, "--eval \"(add-hook 'window-setup-hook #'doom-load-session 100)\""

This commit fixes both the regression and the original issue.

Amend: 56686f677a
Fix: #6219
2022-05-09 15:36:20 +02:00
Henrik Lissner
80cd7557e1
fix(lib): doom-files-in's :map causing type errors
This regression was introduced in 10d00b7cc4, causing
"wrong-type-argument: stringp (X . Y)" errors. It is triggered when
doom-files-in is used with a non-nil :map on a nested directory
tree (like our module tree).

Fix: #6370
Amend: 10d00b7cc4
2022-05-05 20:32:54 +02:00
Henrik Lissner
f281971206
feat(ci): generalize 'doom ci deploy-hooks'
By default, 'doom ci deploy-hooks' would deploy Doom's git hooks in
$EMACSDIR (~/.emacs.d/.git/hooks). Now it deploys in the local repo its
run in. This is part of an effort to generalize Doom's CI for use
outside this repo.

Ref: 4bae9ffa47
2022-05-05 15:35:33 +02:00
Henrik Lissner
4bae9ffa47
refactor(ci): generalize commit linter api
Continues from 47d1b82 as part of an effort to generalize Doom's CI for
use outside this repo:

- 'doom ci ...' commands now:
  - Run in the context of the local repo where they're run, rather than
    from Doom's install directory ($EMACSDIR).
  - Load the first of $REPO_ROOT/.github/ci.el, $DOOMDIR/cli.el, or
    $DOOMDIR/cli.el, before executing CI commands. This allows for
    per-project configuration, for example:
    - https://github.com/doomemacs/doomemacs/blob/master/.github/ci.el
    - https://github.com/doomemacs/themes/blob/master/.github/ci.el
    (Details may change post-3.0)
- Scopeless commit types are now enforced in `doom-cli-commit-scopes`,
  rather than `doom-cli-commit-rules`. This lets you specify exceptions,
  like 0597466261.
- `doom-cli-commit-scopes` now supports sub-lists, as an easy way to
  permit type-local scopes. E.g. To allow 'install' and 'faq' scopes
  only for 'docs:' commits.

    (add-to-list 'doom-cli-commit-scopes '(docs "install" "faq"))

  These sublists accepts predicates too.
- Fixed the link to git conventions in the linter's failure/warning
  output, to point to our Discourse post.

Ref: https://github.com/doomemacs/doomemacs/blob/master/.github/ci.el
Ref: https://github.com/doomemacs/themes/blob/master/.github/ci.el
Ref: 0597466261
Amend: 47d1b82382
2022-05-05 15:32:35 +02:00
Henrik Lissner
10d00b7cc4
fix(lib): unused :map property in doom-files-in 2022-05-05 15:20:07 +02:00
Henrik Lissner
47d1b82382
tweak(ci): generalize commit linter defaults
So Doom can be used for general CI/CD (as part of doomemacs/ci). These
settings can be configured in .github/ci.el by default.

Ref: 0f6a653a13
2022-05-04 22:44:28 +02:00
Henrik Lissner
3b789752a3
fix: user/system git config breaking straight installer
Fix: #6346
2022-05-02 02:12:59 +02:00
Henrik Lissner
0597466261
release(modules): 22.05.0-dev
Ref: 2b39e41368
2022-05-02 01:39:15 +02:00
Henrik Lissner
56686f677a
fix(lib): improper quoting in restart-emacs command
Should be addressed upstream, but restart-emacs hasn't been updated in
nearly two years, so I temporarily fix it here.

Fix: #6219
2022-05-02 01:39:10 +02:00
Henrik Lissner
fbfc635300
fix(cli): GIT_CONFIG* envvars leaking child processes
When launching Doom via 'doom run', the child process inherits
bin/doom's environment. This change restricts this sub-environment to
the intended target: straight and its use of git.

Fix: #6320
2022-04-21 22:36:36 +02:00
Henrik Lissner
8c03fa0e3d
fix: set face :font instead of frame font parameter
Information is lost when converting font-spec's to xlfd strings (mainly,
DPI), in order to make them compatible with the face frame parameter. To
avoid this, we set the faces' :font attribute instead, which natively
accept font specs, xlfd strings, font objects, and xft strings; no
conversion necessary.

Fix: #6131
2022-04-21 22:36:36 +02:00
Itai Y. Efrat
3a3c66df18 docs: add doctor warning about lack of nativecomp 2022-04-12 02:32:53 +02:00
Itai Y. Efrat
5cef63658d docs: update doctor living on the edge check to 29+ 2022-04-12 02:32:53 +02:00
Henrik Lissner
f2f583bfb7
fix: :load-path throwing error in org-src blocks
Because src blocks don't provide a valid load-file-name or
buffer-file-name, dir! cannot resolve the current file's path.

Fix: #6241
2022-04-08 02:51:50 +02:00
Henrik Lissner
fd991026ff
fix: void-function doom-partial
Fix: #6259
2022-04-06 18:45:06 +02:00
Henrik Lissner
d35157ce50
fix(lib): void-variable var
Caused by a typo introduced in cf362bc.

Fix: #6240
Amend: cf362bc1a0
2022-04-03 20:06:58 +02:00
Henrik Lissner
2b39e41368
release(modules): 22.04.0-dev
Eventually, our modules will move to their own repos (doomemacs/modules
and doomemacs/contrib-modules). Once done, it will formally adopt the
CalVer versioning scheme (Doom's core will stick to SemVer -- these
decisions will be better explained later). These mini-releases won't
mean much until this happens, hence the -dev suffix.
2022-04-01 19:12:35 +02:00
Henrik Lissner
cf79616202
fix(cli): remove debug error call in 'doom version'
Accidentally snuck into dcae7187b4.

Amend: dcae7187b4
2022-04-01 19:12:35 +02:00
Henrik Lissner
14ebfc02a5
fix(lib): wrong-number-of-args error on doom/info
- Fixes a wrong-number-of-args error, due to outdated interactive
  spec (#6227).
- Fixes a regression (caused by the refactor in dcae7187b4) where the
  doom-info buffer is initially too short (~3 lines tall) to display all
  of its contents.

Fix: #6227
Amend: dcae7187b4
2022-03-31 21:08:31 +02:00
Henrik Lissner
a48cd27d79
tweak(lib): always suppress doom-log output
It will still be logged to *Messages*, but won't spam the echo area.
2022-03-31 19:25:50 +02:00
Henrik Lissner
806d9c0116
fix(cli): remove bufler from excluded autoloads
I was discussing issues generating autoloads files from some packages
with someone on Discord, and they mentioned issues with
alphapapa/bufler.el, so I added doom-autoloads-excluded-files in
5d0f781062, and also added bufler to it by default. In hindsight, that
doesn't make much sense as a default when Doom and its modules don't
even install bufler (and even if they did, this shouldn't be done in
core).

Ref: 5d0f781062
2022-03-31 19:25:49 +02:00
Henrik Lissner
1f0b74a7c5
fix(lib): cases where doom/bumpify-diff fails
...to crawl the package! forms in the magit diff buffer.
2022-03-31 19:25:49 +02:00
Henrik Lissner
da1eb4d107
refactor(cli): minor refactors and comment revision 2022-03-31 19:25:49 +02:00
Henrik Lissner
cf362bc1a0
fix(lib): update doom/set-indent-width for dtrt-indent
dtrt-indent-hook-mapping-list entries now accept lists of variables.
This updates doom/set-indent-width to accommodate that.

Ref: jscheid/dtrt-indent@1986ad4e60
2022-03-31 16:35:37 +02:00
Henrik Lissner
6185767c41
refactor(eshell,term): move hscroll-margin settings
...out of core and into their respective modules. A tiny step toward
thinning out core.
2022-03-31 14:05:45 +02:00