Commit Graph

47 Commits

Author SHA1 Message Date
0e851ace9b Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.

Fixes #2802, #2737, #2386

The big highlights are:

- Fix #2802: We now update recipe repos *before* updating/installing any
  new packages. No more "Could not find package X in recipe repositories".

- Fix #2737: An edge case where straight couldn't reach a pinned
  commit (particularly with agda).

- Doom is now smarter about what option it recommends when straight
  prompts you to make a choice.

- Introduces a new init path for Doom. The old way:
  - Launch in "minimal" CLI mode in non-interactive sessions
  - Launch a "full" interactive mode otherwise.
  The new way
  - Launch in "minimal" CLI mode *only* for bin/doom
  - Launch is a simple mode for non-interactive sessions that still need
    access to your interactive config (like async org export/babel).
  - Launch a "full" interactive mode otherwise.

  This should fix compatibility issues with plugins that use the
  async.el library or spawn child Emacs processes to fake
  parallelization (like org's async export and babel functionality).

- Your private init.el is now loaded more reliably when running any
  bin/doom command. This gives you an opportunity to configure its
  settings.

- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
  deferred activation of a number of packages. Users can remove these
  modes from these hooks; altogether preventing them from loading,
  rather than waiting for them to load to then disable them,
  e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
  'doom-first-buffer #'smartparens-global-mode)

  Hooks added to doom-first-*-hook variables will be removed once they
  run.

  This should also indirectly fix #2386, by preventing interactive modes
  from running in non-interactive session.

- Added `doom/bump-*` commands to make bumping modules and packages
  easier, and `doom/bumpify-*` commands for converting package!
  statements into user/repo@sha1hash format for bump commits.

- straight.el is now commit-pinned, like all other packages. We also
  more reliably install straight.el by cloning it ourselves, rather than
  relying on its bootstrap.el.

  This should prevent infinite "straight has diverged from master"
  prompts whenever we change branches (though, you might have to put up
  with it one more after this update -- see #2937 for workaround).

All the other minor changes:

- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
  simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
  already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
  trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
  doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
  1. Child instances will no longer inherit the process environment of
     the host instance,
  2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 01:33:52 -04:00
a2011232a2 Change envvar coding system buffer locally 2020-05-14 04:13:05 -04:00
21fda9af60 Read & write envvar file as utf-8 #3044 2020-05-14 02:54:56 -04:00
f61fa50336 Null-byte delimit envvar file lines
This prevents issues with multi-line envvar values.
2020-04-29 19:39:35 -04:00
9e5dd51ca4 doom env: ignore SSH_TTY 2020-04-15 14:20:00 -04:00
c095e7279a Update 'doom env' docs #2835 2020-04-15 00:14:08 -04:00
6bc0fcf714 Remove 'generated from X shell' from envvar file #2835
`doom env` no longer uses a sub-shell to scrape the environment.
2020-04-07 19:56:56 -04:00
8a7763337d doom refresh -> doom sync
refresh isn't going anywhere, but sync will be the canonical command
here on out, because it is more appropriate for kind of work it will be
doing in the future.
2020-02-19 23:34:16 -05:00
f9b3ad2bb1 Fix typo in env.el 2020-01-03 21:42:14 +01:00
b53703d527 General comment revision & reformatting 2019-12-21 15:01:05 -05:00
2afbbe392c Remove dotenv-mode package
Pruning packages that aren't strictly necessary.
2019-12-19 22:05:55 -05:00
24506f15bf cli/env: fix doom-env-ignored-vars not being ignored
And add HOME to ignored vars.
2019-12-02 20:22:00 -05:00
c9ae1f0a30 cli/env: ignore GPG_TTY & TERM envvars 2019-11-22 16:14:05 -05:00
35152fda67 Fix 'doom env -c'
Throwing "I don't understand 'doom env -c'" errors
2019-11-08 16:20:43 -05:00
873fc5c0db Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
  Regrafting repos is now opt-in with the -g/--regraft switches.
  Negation flags have been added for elpa/repos: -e/--no-elpa and
  -r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
  flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
  informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
  with 'doom update' (and 'doom upgrade') freezing indefinitely or
  throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
  must precede any subcommands. e.g.
    Do: 'doom -yd upgrade'
    Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
  integrated core/doctor.el into it, as to avoid naming conflicts
  between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
  arguments and descriptions.

Addresses #1981, #1925, #1816, #1721, #1322
2019-11-08 16:02:06 -05:00
018fc8318d cli/env: ignore TERM envvar 2019-09-30 16:47:32 -04:00
ab954439e8 Label 'doom env' errors as warnings
Because they can usually be ignored.
2019-09-12 17:25:54 -04:00
4045827d61 Mention doom env's -o switch in envvar file header 2019-09-09 13:51:36 -04:00
51e950cc5c Display absolute paths in 'doom env' output
To make it clearer where the envvar file is saved to.
2019-09-09 13:44:12 -04:00
f6b8807e83 Add -o option to 'doom env'
Now you can output envvar files where ever you like.
2019-09-05 14:20:50 -04:00
d298a8e71c Update envvar file comment header
Envvar files are now refreshed on `doom refresh`, if it exists. A while
back I removed the `doom env reload` step.
2019-08-15 17:29:08 -04:00
c8d6ab823b Update documentation for 'doom env' 2019-08-07 01:42:46 -04:00
4dc42de9e3 def-command! -> defcli!
And def-command-group! -> defcligroup!, to match our new convention for
naming definer macros.
2019-07-28 02:32:25 +02:00
0dfdbd471c Ensure envvars at top of envvar file are checked
The regexp expects there to be at least one newline at the top of the
file, otherwise the very first envvar is skipped.
2019-07-27 02:46:50 +02:00
597ef77c20 Ignore envvars prefixed with __
They are likely private. There are some public variables with single
underscore prefixes, however, like _FASD_DATA and _FASD_VIMINFO.
2019-07-27 02:46:49 +02:00
9311744f7f Restore comment header in envvar files
`shell-command` erases the target buffer before piping output to it.
Which means the envvar file comment header was wiped out. This causes
trouble for the envvar file parser, which expects the envvar list to
start with two newlines.
2019-07-26 13:38:13 +02:00
44c694da47 Make bin/doom options consistent & improve errors/docs 2019-07-26 03:12:07 +02:00
93f7520c79 Refactor Doom core init process (again)
- Eager-load all core autoloaded libraries if autoloads file isn't
  present.
- Renames functions to be more descriptive of their true purpose:
  - doom-initialize-autoloads -> doom-load-autoloads-file
  - doom-load-env-vars -> doom-load-envvars-file
- Use doom-module-p instead of featurep! for backend use (the latter is
  mainly syntax sugar for module use, and evaluates at compile/expansion
  time, which may cause hash-table-p errors early in the startup
  process).
- Reorder plist library to prevent load order race condition with the
  functions using the macros that haven't been defined yet.
2019-07-22 23:22:54 +02:00
b90dede1ab 💥 Replace package.el/quelpa with straight #374
There are a few kinks to iron out, but for the most part it's done. Doom
Emacs, powered by straight. Goodbye gnutls and elpa/quelpa issues.

This update doesn't come with rollback or lockfile support yet, but I
will eventually include one with Doom, and packages will be (by default,
anyway) updated in sync with Doom.

Relevant threads: #1577 #1566 #1473
2019-07-22 02:30:40 +02:00
dfa5324f3d cli/env: change how envvars are ignored
Improves the detection and omission algorithm of undesired envvars.
2019-07-10 15:06:45 +02:00
52f575d4d2 Exclude PROMPT & RPROMPT envvars from env file 2019-07-02 14:16:58 +02:00
275f499ce9 Exclude PS1 envvar from env file 2019-07-02 13:01:28 +02:00
5d0c408c38 cli/env: ignore PWD envvar 2019-06-30 09:48:54 +02:00
4f5f51237e cli/env: remove ignored vars retroactively
doom-env-ignored-vars is now treated as a list of regexps.

Also updates docstrings and announces ignored variables.
2019-06-26 14:31:06 +02:00
cdc41fc822 cli/env: reformat envvar file header
Places the generation command on line 2 for easier retrieval and
reformats explanation below.
2019-06-26 14:31:06 +02:00
47739698a8 Correct typo in doom env enable output #1499 2019-06-16 19:16:22 +02:00
84fd744e3f Minor, general refactor & comment revision 2019-06-14 11:08:59 +02:00
9d668791da Correct documentation of env_var file
Because of 3ed54e191b The `load-env-vars` advice is false now. Instead we can propose setting "doom-env-file" correctly, it seems to work for me.
2019-06-13 10:03:50 +02:00
5ec0c5ba3f cli/env: refactor 2019-05-17 21:34:21 -04:00
3ed54e191b Fix #1322: replace load-env-vars w/ custom loader
I've replaced load-env-var with our own custom parser. load-env-var
expects a well-formatted env file, which neither env nor set produces,
which is what doom env uses to dump the shell environment.

This should fix issues that arise when envvars (like PATH) contain
arbitrary whitespace.
2019-05-17 20:19:35 -04:00
7443669b1e Minor refactors & comment revision 2019-05-13 14:37:00 -04:00
d7bc99c3c3 Add deprecation warnings to doom patch-macos
And make "doom env enable" an alias for "doom env auto"
2019-05-09 18:43:32 -04:00
700cda370b Refactor doom env
- Limits process-environment during scraping
- Add `doom-env-executable` and `doom-env-switches` variables
- Announce what commands were run to produce your env var within env var
  file header
2019-04-03 00:09:22 -04:00
7b8a2fcff8 Don't capture INSECURE, DEBUG & YES envvars
They should be transient.
2019-03-28 14:47:31 -04:00
af37f9af58 Fix wrong-number-args error on doom env 2019-03-28 13:30:39 -04:00
9b97631ddf Fix typo in env file template 2019-03-28 02:25:28 -04:00
2dc52bc9be 💥 Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.

Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
  commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)

The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.

+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
  running `doom env enable` (`doom env clear` will reverse this and
  delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
  file. You won't need it if you're confident Emacs will always be
  started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
  doom/reload-env`. Note: this won't work if the Emacs session you're
  running it in doesn't have a correct SHELL set. i.e. don't use this to
  create your first env file!

The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.

This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 01:56:09 -04:00