Commit graph

134 commits

Author SHA1 Message Date
Henrik Lissner
df3c221c73 cli: don't repeat "Executing..." line on restart 2021-05-24 17:32:46 -04:00
Henrik Lissner
4b5cf7d46f bin/doom: polish output
Reduces the amount of "noise" included in bin/doom's output.

Also fixes an issue where warnings during autoloads generation would
sneak into Doom's autoloads file, producing weird void-variable errors,
like

  (void-variable . rainbow-delimiters:)
  (void-variable . diredfl:)
  (void-variable . company:)
2021-05-23 21:49:02 -04:00
Henrik Lissner
1e9870e13a Refactor bin/doom
So innocuous CLI command return values don't break the post-script
written to /tmp/doom.sh.
2021-05-17 22:29:50 -04:00
Henrik Lissner
6d2c6b44fa Refactor comp-effective-async-max-jobs advice
We only need this magic in CLI sessions. It's better to only use half
the CPUs in interactive sessions (if the user has enabled
comp-deferred-compilation for some reason).

Fixes #5042
2021-05-12 14:52:00 -04:00
Henrik Lissner
5b3f52f5fb Fix missing doom.error.log and silent straight errors 2021-03-22 21:11:22 -04:00
Henrik Lissner
e9c4c7471c Reorganize CLI libraries 2021-03-12 17:55:41 -05:00
Henrik Lissner
fc75573962 Include straight error in doom.error.log 2021-03-12 17:06:10 -05:00
Henrik Lissner
26319322b2 Remove redundant straight--build-compile advice
May address #4778 and #4783
2021-03-11 11:44:18 -05:00
Benjamin Tan
f151b3de45
Load autoload/system in core-cli
Fixes #4715.
2021-03-02 15:57:45 +08:00
Henrik Lissner
987da645c2 core/cli: show run duration in human-readable format
e.g. "Finished in 2h27m11s"

I pray for your soul if you ever see "h".
2021-02-13 09:47:13 -05:00
Henrik Lissner
2c4b5b2f93 Fix type error when printing straight errors 2021-01-26 22:38:53 -05:00
Henrik Lissner
fd7073240c Complete docstring for doom--straight-inject-load-path-a
Whoops. I pushed before finishing the
2021-01-23 22:37:28 -05:00
Henrik Lissner
eacbc5e36f Inject load-path when compiling straight packages 2021-01-23 18:50:21 -05:00
Henrik Lissner
9490d42cd3
Comment revision 2020-12-14 15:48:29 -05:00
Henrik Lissner
9edcdd0633
Mention supported envvars in 'doom help' 2020-10-08 17:07:36 -04:00
Henrik Lissner
2337f14563
bin/doom: enable-dir-local-variables = nil
So user .dir-locals.el doesn't interfere with our package manager.
2020-08-28 23:34:12 -04:00
Henrik Lissner
5de08af8da
bin/doom: improve error output
Show different message for straight errors (but log backtrace to
doom.error.log either way).
2020-08-28 04:34:56 -04:00
Henrik Lissner
098f10306d
Fix CLI error not including straight output 2020-08-27 03:11:46 -04:00
Henrik Lissner
a6dc9bf7e5
core-cli: minor refactors 2020-08-27 01:10:08 -04:00
Henrik Lissner
e459842a9b
Escape newlines in backtrace frames
And quote strings
2020-08-26 16:02:55 -04:00
Henrik Lissner
63a03848a3
Fix literate tangling on 'doom sync'
Relevant to #3746
2020-08-25 06:01:35 -04:00
Henrik Lissner
c0500df5fb
bin/doom: move debugger config to core-cli
And remove unnecessary path expansion.
2020-08-25 05:08:22 -04:00
Henrik Lissner
6e22a15e43
Fix 'doom help'
doom-cli-internal-p was accidentally removed in e632871a1, and the
psuedo CLI command :main was renamed to :doom.
2020-08-24 23:36:11 -04:00
Henrik Lissner
0dfee56e35
Fix string type error on 'doom upgrade' 2020-08-24 23:22:57 -04:00
Henrik Lissner
e632871a11
core-cli: backport more refactors from rewrite
Still a long way to go, but this introduces a few niceties for
debugging CLI failures:

+ The (extended) output of the last bin/doom command is now logged to
  ~/.emacs.d/.local/doom.log
+ If an error occurs, short backtraces are displayed whether or not you
  have debug mode on. The full backtrace is written to
  ~/.emacs.d/.local/doom.error.log.
+ bin/doom now aborts with a warning if:
  - The script itself or its parent directory is a symlink. It's fine if
    ~/.emacs.d is symlinked though.
  - Running bin/doom as root when your DOOMDIR isn't in /root/.
  - If you're sporting Emacs 26.1 (now handled in the elisp side rather
    than the /bin/sh shebang preamble).
+ If a 'doom sync' was aborted prematurely, you'll be warned that Doom
  was left in an inconsistent state and that you must run `doom sync`
  again.

May address #3746
2020-08-24 23:00:32 -04:00
Henrik Lissner
b4431dcd49
Fix #3746 (part 3): use correct PATH separator on Windows
An IS-WINDOWS check would be too naive, because cygwin and git-bash use
: as the path separator, while powershell and cmd.exe use ;
2020-08-19 15:00:25 -04:00
Henrik Lissner
8402f8aecc
Fix #3781 (part 2): error reading from stdin
Possibly addresses #3746
2020-08-19 13:57:24 -04:00
Henrik Lissner
9b991fc29f
Fix #3781: revert 55b87b3a9 2020-08-19 12:10:14 -04:00
Henrik Lissner
b2120e21eb
bin/doom: fix heredoc delimiter in postscript 2020-08-18 19:02:17 -04:00
Henrik Lissner
9f45561825
bin/doom: inhibit POSIX errors during postscript
Some doom commands will generate a temporary script at
~/.emacs.d/.local/.doom.sh so that it can run an arbitrary shell command
after the current invocation of bin/doom ends. Very useful for, say,
restarting the currently running doom command after a destructive
operation, like updating Doom's source code, tangling your literate
config, or for launching arbitrary programs, like a new instance of
Emacs. This is necessary because elisp lacks an execv implementation.

However, for some folks, .doom.sh wasn't executing at all. This meant:

1. Some `doom upgrade`s would upgrade Doom itself but never move on to
   the second step of the process: updating its packages.
2. Literate config users could tangle their configs on `doom sync`, but
   the actual syncing process would never happen (#3746).
3. `doom run` would do nothing.

I hadn't realized /bin/sh runs bash in POSIX mode (at least, on systems
where /bin/sh = bash, like nixOS or macOS). In POSIX mode the script
will abort the if a builtin command (like export) returns a non-zero
exit code. Since .doom.sh is basically a bunch of exports followed by an
arbitrary command, and there are some environment variables
that can trigger validation errors (like UID triggering a "read-only
variable" error), we have a problem.

Hopefully addresses #3746
2020-08-18 18:59:50 -04:00
Henrik Lissner
9a8fc46c74
bin/doom: escape envvars in post-script
Might address #3746
2020-08-15 15:13:50 -04:00
Henrik Lissner
d9739a2d10
Fix #3727: 'doom: command not found' error on 'doom upgrade' 2020-08-11 14:26:49 -04:00
Henrik Lissner
050ac73789
Prevent illegal envvars causing bash syntax errors 2020-08-10 23:07:21 -04:00
Henrik Lissner
eb9cb0c6e9
Fix org version conflicts due to literate config #3649
Tangling would load org libraries. If org hasn't been installed yet,
this means the older version is loaded, later interfering with the
installation and byte-compilation of the new package, causing down the
road.
2020-08-09 01:50:42 -04:00
Henrik Lissner
d2bc2ff44b
config/literate: improve tangling algorithm
- Tangling no longer adds temp files to recentf (#3685)
- If :tangle yes is used, the result is no longer tangled to
  /tmp/config.org.*.el
- In interactive sessions the org buffer is no longer interfered with
  when tangling (by scrolling up to the top of the page, or undoing
  overlays/markers).
- Tangling no longer triggers formatters (or any save/write hooks).
- Appease byte-compiler sama, complaining about free variables.
2020-08-08 02:57:04 -04:00
Henrik Lissner
f4e6d36574
Move 'restart Emacs to see changes' message to 'doom sync'
It isn't the autoloads generator's responsibility to do this. The
"changes" referred to consist of more than just the regenerated
autoloads file.
2020-05-26 04:09:11 -04:00
Henrik Lissner
a814239ec7
Implement daisy-chaining for CLI sessions
elisp lacks an execv implementation (or mature subprocess library), so
we exploit some splenderiffic hackery to get Emacs to execute arbitrary
shell commands after a 'doom ...' command completes. This allows us to
daisy chain doom commands in distinct sessions (wonderful for reloading
doom after a 'doom upgrade', which we do). This minimizes errors when a
'doom upgrade' pulls in breaking changes to Doom's CLI.

We also bring 'doom run' into elisp, since this new functionality
enables us to.
2020-05-26 02:30:54 -04:00
Henrik Lissner
16d44de0db
Add/improve docs for doom sync's -u & -p switches 2020-05-25 16:26:16 -04:00
Henrik Lissner
8c37928de2
Disable 'doom refresh'
That 'doom refresh' and 'doom sync' do the same thing has been a point
of confusion for a while. By phasing out 'doom refresh' we can finally
put that to rest.
2020-05-25 16:23:17 -04:00
Henrik Lissner
5cba174bd9
Add doom-sync-{pre,post}-hook 2020-05-25 16:03:16 -04:00
Henrik Lissner
e6c88e4384
Refactor autoloads generator & reduce to one generated file
We no longer need two separate autoloads files, so I merged them and
optimized its generation logic.

Other changes
- Doom will refuse to start up (with a helpful error) if it's in an
  incomplete state. This should hopefully reduce the number of bug
  reports from folks that have done something weird, e.g.
  1. You've changed Emacs versions without running 'doom sync -b'.
  2. You've updated Doom outside of `doom upgrade` and didn't run `doom
     sync -u`.
  3. You've forgotten to run 'doom sync' in the first place!
  4. If a previous 'doom ...' command was aborted midway without running
     'doom sync' afterwards.
- 'doom sync' will emit reminders that you need to reload/restart Emacs
- Autoloads API now uses the `doom-autoloads-` prefix, intead of
  'doom-cli-autoloads-', as will be the new convention in the coming
  rewrite.
- Errors from within the package autoloads should be easier to invoke
  the debugger on.
- `doom-modules` is now stored in your autoloads file. Your module list
  will soon be frozen between calls to 'doom sync' to allow for our new,
  atomic CLI I'm working on. This will also means the `doom!` block
  won't cost anything in interactive sessions.
2020-05-25 15:55:29 -04:00
Henrik Lissner
be889d09e8
Rename doom-format lib -> doom-output
`format` isn't an appropriate for this library, considering it (and
future additions to it) will be mainly concerned with printing or
capturing output.
2020-05-25 15:55:29 -04:00
Henrik Lissner
cc5f498586
Add magic cli.el in modules & refactor module init
Doom now looks for cli.el files in your private directory or modules,
giving them an opportunity to customize the CLI (add commands or
reconfigure existing ones) to suit their purposes.
2020-05-25 15:55:28 -04:00
Henrik Lissner
3a38fc633c
Change doom-{interactive,debug}-mode suffix to -p
Because these are not really modes.

Also makes `doom-debug-mode` an actual (global) minor mode.
2020-05-25 03:43:40 -04:00
Henrik Lissner
e00bfc7612
Minor refactors & reformatting 2020-05-25 03:43:40 -04:00
Henrik Lissner
ebdb3399b5
Recommend the correct option for changes in package origin
For prompts like these

  > In repository "org-roam", remote "origin" has URL
    "https://github.com/jethrokuan/org-roam.git"
  but recipe specifies a URL of
    "https://github.com/org-roam/org-roam.git"

       1) Abort
       2) Rename remote "origin" to "origin-1", re-create "origin" with correct URL, and fetch
       3) Rename remote "origin" manually, re-create it with correct URL, and fetch (Recommended)
       4) Delete remote "origin", re-create it with correct URL, and fetch
       5) Delete remote "origin", re-create it with manually set URL, and fetch

    How to proceed? (1, 2, 3, 4, 5)

4 should be recommended, not 3.
2020-05-18 03:37:42 -04:00
Henrik Lissner
10d9ca87e9
Correct regexps for recommended straight options
When you're being prompted, these regexps control what option is
highlighted as the recommended option, and two of them were definitely
wrong, and another two *might've* been wrong.
2020-05-15 22:58:00 -04:00
Henrik Lissner
2884dd9ea7
Fix 'recreate repo' option not being recommended
When updating a package with a changed recipe (e.g. it's branch).
2020-05-15 02:29:22 -04:00
Henrik Lissner
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
Henrik Lissner
1fb5981ba6
Highlight recommended straight prompt option in green 2020-05-02 14:41:18 -04:00