Commit Graph

207 Commits

Author SHA1 Message Date
2f39d3fced fix(cli): "Unknown terminal type" error on bin/org-capture
Fix: #5438
2021-11-24 22:03:21 +01:00
045ea7460d nit: revise and reformat code comments 2021-08-04 01:53:12 -04:00
06392a723f refactor: rename orig-fn arg in advice to fn
A minor tweak to our naming conventions for the first argument of an
:around advice.
2021-08-04 01:53:12 -04:00
44c8d3c8e4 Adding new line on string on how to upgrade Emacs
The current string presented breaks the address on how to upgrade Emacs:

```
❯ doom install
Detected Emacs 26.3 (at emacs).

Doom only supports Emacs 27.1 and newer. A guide to install a newer version
of Emacs can be found at:

  https://doomemacs.org/docs/getting_started.org#on-linuxAborting...
```

Just adding a `\n` at the end of the string would solve it.
2021-07-26 17:45:52 -07:00
044a1a5f2b Drop Emacs 26.x support
Emacs 27.x has been the stable version of Emacs for nearly a year, and
introduces a litany of bugfixes, performance, and quality-of-life
improvements that significantly reduce Doom's maintenance burden (like
XDG support, early-init.el, image manipulation without imagemagick, a
native JSON library, harfbuzz support, pdumper, and others).

With so many big changes on Doom's horizon, I like having one less (big)
thing to worry about.

Also reverts bb677cf7a (#5232) as it is no longer needed.
2021-07-06 02:31:52 -04:00
ef7113d6c4 Fix #5071: don't always emit 128 exit code
Otherwise it always tries to execute /tmp/doom.sh, which won't exist on
certain code paths.
2021-05-20 11:01:28 -04:00
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
528657a426 bin/org-capture: fix hanging
The script's stdin check was too simplistic and would block forever
waiting for input. From now on, to pipe to the script, pass it a dash.
2021-05-15 14:09:08 -04:00
91573dd95f Fix site files not loading in batch session
Should help with loading Snap environment or packages installed via the
system package manager (like mu4e).

Fixes #4198
2021-05-09 20:50:23 -04:00
df10383a26 Use symbol plists instead of internal variables
More in line with Emacs' built-in practice of storing a variable's
standard-value in a symbol property of the same name, with the added
benefit of less global state.
2021-05-06 04:27:33 -04:00
18e1795a98 org-confirm-babel-evaluate = nil while tangling 2021-03-22 21:11:22 -04:00
e9c4c7471c Reorganize CLI libraries 2021-03-12 17:55:41 -05:00
3861225f0b Fix 'too many arguments' error on org-capture
org-capture foo bar baz

will fail with:

org/capture: line 33: [: too many arguments

Adding quotes to the expansion of $str will ensure that test -z has
only one argument.
2021-03-08 10:42:06 +01:00
269dab615c org-capture: text from args, else stdin
old behavior was to use stdin in non-interactive
This prevented binding eg in qutebrowser
2021-03-07 00:48:32 -08:00
1274de3d34 Minor reformatting & refactors across the board 2021-02-25 13:59:43 -05:00
3894611a8f Minor comment revision 2021-02-21 14:44:59 -05:00
eea4709354 cli: run post-script indirectly
Fixes cases where /tmp is mounted with noexec.
2020-12-12 15:56:36 -05:00
b5e948054c Refactor & reformat core.el
Backport a bit of core.el from our CLI rewrite.
2020-12-02 17:58:09 -05:00
b49c40bbb3 Minor refactors & comment revision 2020-11-29 14:37:32 -05:00
03c6a352bf Ensure site subdirs.el are loaded 2020-11-20 14:10:29 -05:00
4dab595ad3 Minor refactors & comment revision 2020-11-20 14:10:29 -05:00
5940d931f4 Fix "read only variable" errors on doom {sync,upgrade}
Relevant to #3844
2020-09-01 15:32:01 -04:00
e03824bf5e bin/doom: improve POSIX compliance
+ The bourne shell does not guarantee it'll understand the new $()
  subshell syntax.
+ Can't rely on set -e to short circuit the script. No avoiding the
  roundabout suppression of the postscript error with '&& true'.

Might fix #3844, but doubt it.
2020-08-27 14:42:48 -04:00
a2a5038b97 Fix #3844: bin/doom emits wrong-type-arg error on windows
For some reason __DOOMPOST isn't being exported into emacs' environment
on Windows (powershell and git bash).
2020-08-27 01:10:08 -04:00
a6dc9bf7e5 core-cli: minor refactors 2020-08-27 01:10:08 -04:00
47b42a9d08 Don't exec postscript #3746
Doesn't seem to persist exported environment variables (like __DOOMPOST)
in some windows environments.
2020-08-25 20:22:06 -04:00
239516a7db Fix #3831: integer expression expected error on bin/doom
Also mentioned in #3746
2020-08-25 13:24:45 -04:00
63a03848a3 Fix literate tangling on 'doom sync'
Relevant to #3746
2020-08-25 06:01:35 -04:00
c0500df5fb bin/doom: move debugger config to core-cli
And remove unnecessary path expansion.
2020-08-25 05:08:22 -04:00
93ac32d082 bin/doom: refactor shebang preamble
Indirectly fixes folks' ability to set EMACS to more complex
commands (like 'flatpak run org.gnu.emacs').
2020-08-25 05:08:14 -04:00
4fa0241134 bin/doom: allow script to be symlinked #3746 2020-08-24 23:19:42 -04:00
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
394c9b5a70 Fix string comparison in TERM check
Script was using -eq, which is a numeric comparison, and was producing
an "integer expression expected" error. Changed to =, the string
comparison operator.
2020-08-24 14:42:45 +02:00
10d25be4ed bin/org-capture: TERM=xterm-256color in alacritty 2020-08-21 15:49:36 -04:00
9b991fc29f Fix #3781: revert 55b87b3a9 2020-08-19 12:10:14 -04:00
55b87b3a94 bin/doom: source postscript instead
This way the postscript can refer to the doom script via "$0" and its
arguments via "$@" (making it easier for cli commands to rerun the last
command).
2020-08-18 20:32:34 -04:00
d9739a2d10 Fix #3727: 'doom: command not found' error on 'doom upgrade' 2020-08-11 14:26:49 -04:00
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
4b96039374 bin/org-tangle: expand #+INCLUDE directives
See 711e68770 for details.
2020-07-25 22:57:22 -04:00
1270933f44 Remove --{emacs,doom,local}dir options
These options aren't properly supported in this version of the CLI.
Changing the localdir, for instance, doesn't affect when straight is first
bootstrapped. Chaning emacsdir doesn't matter for the first run. I'm
working on a CLI rewrite that will reimplement --doomdir and --localdir
at least, but for now it's best I just remove these.

They can still be customized using the EMACSDIR, DOOMDIR, and
DOOMLOCALDIR envvars.

Closes #3367
2020-06-12 16:43:46 -04:00
ba817cb1ff Speed up bin/doom by staving off GC
This effectively halves the runtime of 'doom sync' and 'doom doctor',
and shaves 5-10% off other commands.
2020-05-27 02:55:22 -04:00
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
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
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
98d7b97d33 Fix 'doom run' not (re)executing startup hooks
Makes leader keys (among other things) unable to function.
2020-05-17 06:14:37 -04:00
805976b8bd Handle the case where EMACSDIR has no trailing slash 2020-05-15 04:53:59 -04:00
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
aa64ece46d Silence deprecation & site-file loading messages in CLI 2020-05-04 16:51:21 -04:00
cdaa55b4db Rename org-capture frame to doom-capture
To reduce likelihood of conflicts.
2020-03-01 01:39:14 -05:00
413171cfc9 bin/org-capture: Suppress output for initial emacsclient call 2020-02-29 17:57:44 -08:00