Commit Graph

59 Commits

Author SHA1 Message Date
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
ca0dbc798d
Use shorter seq.el alternatives 2020-05-26 04:18:20 -04:00
Henrik Lissner
22c7eac897
Add doom-autoloads-files option
So users can scan additional files for autoloads during 'doom sync'.
2020-05-26 04:16:42 -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
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
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
2c70b75c6c
Warn user to sync+rebuild on emacs' major version change
Byte-code is not generally compatible across major releases of Emacs,
and packages may have changed in that time. Best throw a more helpful
error than leave users to deal with the obscure errors that this can
cause.
2020-05-03 16:31:06 -04:00
Henrik Lissner
d3c2e4829b
Disable byte-compile-dynamic for autoloads files
Its deprecated and more trouble than its worth.
2020-04-17 15:47:05 -04:00
Henrik Lissner
f7445a10db
General refactor & reformatting across the board 2020-02-18 22:56:47 -05:00
Henrik Lissner
53d799f377
Reduce file init work when reading autoloads
Should suppress Emacs trying to read file-local variables and/or
attempts to open TAGS files for the current project.
2020-01-30 19:39:36 -05:00
Henrik Lissner
c3734603f5
Don't strip out vars from doom module autoloads
Doom's autoloads generator will strip out forms that modify variables in
doom-autoload-cached-vars (load-path, auto-mode-alist, etc). These are
undesireable in package autoloads, but may be desireable in Doom module
autoloads.
2020-01-24 18:16:11 -05:00
Henrik Lissner
9eb3a74a57
Save interpreter-mode-alist to autoloads 2020-01-14 02:59:16 -05:00
Henrik Lissner
cf04a44ca7
Refactor comment/string check in autoloads generator 2020-01-04 17:13:05 -05:00
Henrik Lissner
11676b0153
Fix #2299: void-function sp-point-in-string during 'doom refresh'
Due to use of third-party code before it is installed. Since we can be
sure that elisp has a sane syntax-table we do not need sophisticated
comment/string detection.
2020-01-03 05:22:10 -05:00
Henrik Lissner
4f676bd218
Refactor autoload generator bootstrappers 2020-01-01 13:31:40 -05:00
Henrik Lissner
4a53f0818d
Don't insert autoloads literally #2281
It causes encoding issues.
2020-01-01 03:02:05 -05:00
Henrik Lissner
7c968a8b11
Fix #2278: autoload gen skipping disabled autodefs
If a ;;;###if module cookie returned nil for a file, it should still
allow autodefs to be scraped from it, which wasn't happening before this
fix.

An autodef's guarantee is that it will always be defined, whether or not
the containing module is enabled.
2019-12-30 23:19:56 -05:00
Henrik Lissner
0b1ab39a00
Refactor doom-cli--generate-autoloads 2019-12-30 17:06:49 -05:00
Henrik Lissner
497a6a206e
Fix 'wrong-number-of-arguments autoload 9' error in autoloads
This error was caused by over-aggressive replacement of load-file-name
in autoloads files.

Instances of "load-file-name" would be replaced with a quoted file-path,
even in strings and comments, which would break surrounding strings and
docstrings.

Mentioned in hlissner/doom-emacs@f8ff505
2019-12-30 15:52:38 -05:00
Henrik Lissner
908bd4b945
Remove FORCE-P argument for doom-cli-reload-autoloads
We weren't using them anyway.
2019-12-30 06:44:16 -05:00
Henrik Lissner
f8ff50565e
Refactor autoload generator
- Halves LOC
- Adopts functional paradigm where possible.
- Reduces the filesize of autoloads files by ~10-20%
- Speeds up autoloads generation by ~20%
2019-12-29 22:20:48 -05:00
Henrik Lissner
d232ba241f
Remove 'doom autoloads'
It's redundant with doom refresh
2019-12-05 14:54:49 -05:00
Henrik Lissner
9d9b6e514c
Refactor autoloads generater 2019-11-23 01:21:24 -05:00
Henrik Lissner
88eb9d1d61
Don't bind noninteractive while building autoloads
See raxod502/straight.el#431
2019-11-22 13:52:07 -05:00
Henrik Lissner
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
Henrik Lissner
297728bf74
Generalize doom-file-cookie-p
And move it to doom-file-cookie-p for anyone to use.
2019-10-04 22:42:53 -04:00
Henrik Lissner
d297dc6934
Minor refactor & comment revision across the board 2019-10-03 23:33:59 -04:00
Henrik Lissner
45240699e0
Remove doom-elpa-dir variable
And just use package-user-dir. No need for two variable when one will
do.
2019-09-26 14:26:47 -04:00
Henrik Lissner
ec81fc30a4
Minor correction to comment 2019-09-08 20:56:50 -04:00
Henrik Lissner
a44e9153d3
Fix #1764: 'doom autoload' generating broken autoloads.pkg.el
Due to missing straight state that is properly initialized for 'doom
refresh' (by doom-packages-install), but not for 'doom autoloads'.
2019-09-08 20:52:30 -04:00
Henrik Lissner
b808c4e1ab
Reload autoloads files in noninteractive sessions
After it's been regenerated, so that any hacks (*cough*org/magit*cough*)
are in scope.
2019-08-07 16:55:04 -04:00
Henrik Lissner
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
Henrik Lissner
8dab8eefca
Prevent load-file-name/#$ replacements in strings & comments 2019-07-27 22:57:32 +02:00
Henrik Lissner
21a27b52d8
Refactor autoloads generation
- Correctly replace references to load-file-name and $# in autoloads.
- Don't load resulting autoloads file twice
- Read package autoloads literally (a little faster)
2019-07-27 16:59:10 +02:00
Henrik Lissner
6fcaa80355
Improve autoloads mtime scanning on packages
Scan source files in build directory rather than repos, which are better
indicators of a stale autoloads file.
2019-07-26 20:17:30 +02:00
Henrik Lissner
c2ae6f30a5
Don't compress auto-mode-alist
Modules may readd their entries afterwards, anyway.
2019-07-26 15:33:32 +02:00
Henrik Lissner
905ba1d23c
Refactor autoloads byte-compilation
- Let-bind byte-compile-* vars instead of using file-local vars.
- Fix duplicate bullet point in "Copied backup..." message.
- Only display refresh message if cli command was successful.
2019-07-26 03:12:06 +02:00
Henrik Lissner
ba990a6c9d
Build package autoloads in install order #374
Before this update, the autoloads files were collected in
lexicographical order (by traversing straight's build directory). By
using straight--build-cache's keys (which are entered in the order they
were registered) we avoid issues like
2019-07-23 21:54:50 +02:00
Henrik Lissner
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
Henrik Lissner
afebdb35da
Refactor autodef generator 2019-07-22 23:22:54 +02:00
Henrik Lissner
ffdb726ed8
Exclude gh.el from autoloads
See sigma/gh.el#95
2019-07-22 06:06:58 +02:00
Henrik Lissner
71ba4789ca
Fix hash-table-p errors on reloading pkg autoloads
Because doom-modules wasn't set in doom-module-path's scope.
2019-07-22 02:37:44 +02:00
Henrik Lissner
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
Henrik Lissner
cb401c8302
Don't abbreviate autoload paths on windows #1548 2019-07-10 16:05:40 +02:00
Henrik Lissner
71d505b893
Cache doom-modules on doom refresh 2019-07-07 14:10:21 +02:00
Henrik Lissner
9a02bd8ac8
Minor refactors across the board
- when-let* -> when-let
- Fix projectile-locate-dominating-file for connected remote files
2019-06-26 14:31:06 +02:00
Henrik Lissner
b45591989b
Revert remote reloading after refreshing autoloads
It's too flimsy, breaks easily, and doesn't handle the case where
multiple instances of Emacs are open.
2019-06-18 22:10:19 +02:00
Henrik Lissner
6be401f1a7
Refactor Doom core & reload autoloads remotely
- Move subr-x/cl-lib loading to core-lib
- Revise docstrings for and rename various CLI functions to be more
  descriptive and up-to-date
- After regenerating autoloads file, bin/doom will try to reload
  autoloads files remotely, through the server/daemon, if possible. This
  is highly experimental and could break
2019-06-16 23:01:17 +02:00
Henrik Lissner
5e9c020c21
doom-files-in: replace NOSORT w/ SORT; change default MATCH
- SORT defaults to t
- MATCH's new default regexp excludes files that start with underscore.
2019-06-16 19:16:23 +02:00
Henrik Lissner
84fd744e3f
Minor, general refactor & comment revision 2019-06-14 11:08:59 +02:00