Commit Graph

418 Commits

Author SHA1 Message Date
Henrik Lissner
2525822791
Move GC optimization to init.el
And reformat core.el
2019-05-15 18:30:20 -04:00
Henrik Lissner
5cd1fb2a52
tutorial--saved-dir = doom-cache-dir/tutorial/ 2019-05-14 23:41:21 -04:00
Henrik Lissner
75777756e1
Remove redundant dired sort hook #1414
This still means dired will be unsorted for BSD ls users, but that's
acceptable (for now).
2019-05-14 18:45:38 -04:00
Henrik Lissner
9bc47ca329
Minor refactors
- Don't aggressively load gnu-elpa-keyring-update, it autoloads itself
- Update docstring + comments
- scroll-margin = 1
2019-05-13 19:34:44 -04:00
Henrik Lissner
20596cd41f
Reformat gc optimization & gc on focus-out
Also raises the gc upper limit to 512mb
2019-05-13 19:34:44 -04:00
Henrik Lissner
388e0def2c
Cheer up the byte-compiler
You deserve better than those warnings.
2019-05-02 21:54:47 -04:00
Henrik Lissner
6d314c2795
Revise and update docstrings and comments 2019-05-01 21:02:28 -04:00
Henrik Lissner
9735f034e1
General refactors & optimizations 2019-04-29 18:54:46 -04:00
Henrik Lissner
f61e0aa00c
Use outline-mode comment headings in core.el 2019-04-20 02:18:49 -04:00
Henrik Lissner
31eb845f6b
Reset more state on doom/module initialization
Makes `doom/reload` a little more reliable and the side effects of
`doom-initialize`/`doom-initialize-modules` a little more deterministic.
2019-04-09 03:43:13 -04:00
Henrik Lissner
2a079e2733
Load env even in tty Emacs
Even if it matches the current shell (or doesn't), the env file should
be the authority.
2019-04-03 01:53:20 -04:00
Henrik Lissner
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
Henrik Lissner
a6cc66e21e
Refresh exec-path & shell-file-name
When loading envvars, since `load-env-vars` only affects the environment
and not Emacs' variables.
2019-04-01 13:15:15 -04:00
Henrik Lissner
7488b51e9a
Prevent void-function load-env-vars errors
In case load-env-vars hasn't been autoloaded yet.
2019-03-29 01:51:36 -04:00
Henrik Lissner
eb1296387f
Make load-env-vars a core package
Fixes a race condition where the load-env-vars package is used before it
was (or could be) installed.
2019-03-28 13:30:39 -04:00
Henrik Lissner
b3d931d7ce
Refactor undo-tree advice 2019-03-28 01:56:09 -04:00
Henrik Lissner
37525bb1bd
Fix clipboard support on Windows #1284
Windows uses UTF-16 for clipboard content. selection-coding-system is
set correctly on Windows systems so we leave it to its default there.
2019-03-28 01:56:09 -04:00
Henrik Lissner
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
Henrik Lissner
e0ed8669af
Move (if|when)-let* shims to core.el
Fix void-functon when-let* errors at startup for Emacs 25.* users.
2019-03-08 18:06:35 -05:00
Henrik Lissner
5ab58a7eaf
Load subr-x & cl-lib sooner 2019-03-08 06:13:07 -05:00
Henrik Lissner
917d89da87
Refactor module init hooks
Also adds doom-after-init-modules-hook for consistency, which is an
alias to after-init-hook until I decide if it's necessary for it to be
independent.
2019-03-08 02:37:33 -05:00
Henrik Lissner
9b180fda97
Refactor doom-initialize & bootstrap in core.el 2019-03-08 02:37:32 -05:00
Henrik Lissner
e497df4a28
Restore obsolete doom-(post-)?init hooks
These will be removed later.
2019-03-05 19:23:50 -05:00
Henrik Lissner
024e27b618
Add contingency plan for local-vars hooks
They don't run if enable-local-variables is set to nil.
2019-03-05 17:08:39 -05:00
Henrik Lissner
05303c0fdb
💥 Rethink core hook order & naming
- doom-post-init-hook was renamed doom-init-modules-hook
- doom-init-hook was renamed doom-before-init-modules-hook
- doom-init-modules-hook now runs before the user's config.el is run
- Moved doom-init-ui-hook to run later (on window-setup-hook rather than
  emacs-startup-hook).

Yield a modest improvement in startup times.
2019-03-04 20:47:26 -05:00
Henrik Lissner
f6cc2644b0
New doom-log macro for debug-time logging
doom-log won't interfere with the minibuffer if it's in use, and will
report the originating module.

Addresses #1215
2019-03-04 18:38:25 -05:00
Henrik Lissner
1eb1933518
Don't let packages modify command-switch-alist
From their autoloads.
2019-03-02 03:55:15 -05:00
Henrik Lissner
84343f57aa
Refactor UTF-8 setters
Some were redundant
2019-03-02 03:53:13 -05:00
Henrik Lissner
d46bb287ae
General refactor of Doom core
- Code reduction and refactor across the board (cull unneeded minor
  advise, hooks and hacks or update them)
- Revise outdated comments and docstrings
- Reorganize core autoload libraries
- Remove large file check (Emacs already has a built-in one, which we
  augment to be even more performant when it does kick in)
- helpful.el can now be disabled completely through package!
2019-03-02 01:34:19 -05:00
Henrik Lissner
8a90f29c91
Make session persistence module agnostic
They've been removed from feature/workspaces and moved into
core/autoload/sessions, which falls back to desktop.el if persp-mode
isn't present. This also offers a substantial speed up to
restart+restoring and restoring sessions in general.

Also fixes #1210, where the newly spawned frame after doom/restart
wasn't focused.

Introduces the following commands:

- doom/restart
- doom/restart-and-restore
- doom/quickload-session
- doom/quicksave-session
- doom/load-session
- doom/save-session
- +workspace/restore-last-session (alias for doom/quickload-session)

And removes

- +workspace/load-session
- +workspace/save-session
- +workspace/load-last-session (renamed to +workspace/restore-last-session)
- +workspace/restart-emacs-then-restore (replaced by doom/restart-and-restore)
- :ss (ex command)
- :sl (ex command)
2019-03-02 01:34:19 -05:00
Henrik Lissner
21e01189b9
Properly keep cursor out of minibuffer prompt
The prompt in the minibuffer is read-only. You are able to move the
cursor into it before this fix.

This also more effectively silences echo-area output when deleting text
in the minibuffer. No more "Text is read-only" blocking what you're
typing.
2019-03-02 01:34:14 -05:00
Henrik Lissner
11d7ae070a
Add async-byte-compile-log-file setting to core.el 2019-02-21 19:13:35 -05:00
Henrik Lissner
19987df00a
Add IS-BSD constant
Fixes dired gls support on BSD OSes (and not just MacOS).
2019-01-05 16:06:26 -05:00
Henrik Lissner
e373052064
Restrict support to Emacs 25.3+ from now on
25.1-25.2 are no longer supported.
2018-12-28 15:22:52 -05:00
Henrik Lissner
9936532ea3
Move auth-sources & mc/list-files
...to move appropriate locations.
2018-12-23 23:16:03 -05:00
Henrik Lissner
a124497f4e
find-file-visit-truename = t 2018-12-22 14:30:29 -05:00
Henrik Lissner
f4698d2f0a
Fix uncaught errors during incremental load 2018-12-10 13:50:58 -05:00
Henrik Lissner
5d3bada86e
Don't byte-compile xdg-path in doom-private-dir
The danger of a stale value post-byte-compilation far outweighs the
benefits.
2018-10-06 20:44:25 -04:00
Henrik Lissner
fd19698927
doom|hack-local-variables => MODE-local-vars-hook
Uses a less destructive method (the same that Spacemacs uses) than the
one introduced in 13cee68, by introducing MODE-local-vars-hook hooks,
which run after local vars have been initialized.

The old method was to call `hack-local-variables` *before* mode hooks
run, however, this causes variables set by modes to have higher
precedence than local vars, which is unacceptable.

Also moved intero-mode & dante-mode to haskell-mode-local-vars-hook
2018-09-29 15:01:35 -04:00
Henrik Lissner
cae5009925
cl-remove-if -> cl-delete-if
Minor optimization for doom-load-packages-incrementally (cl-delete-if
deletes in-place).
2018-09-28 22:50:39 -04:00
Henrik Lissner
13cee6870e hack-local-variables before mode hooks
The default behavior is to read file+directory-local variables after the
major mode and its hooks have run. I think this is backwards. What if we
want to use these local variables to customize the things running in
hooks?

This does mean hack-local-variables will run at least twice when the
mode changes, but this is an acceptable compromise.
2018-09-28 21:13:28 -04:00
Henrik Lissner
078e3028a6 Minor, general comment revision 2018-09-28 21:02:59 -04:00
Henrik Lissner
c8b07f3caa
Fail gracefully if incremental load fails
...and continue loading other packages regardless.
2018-09-20 10:42:45 -04:00
Henrik Lissner
ba16dd8954
Resolve symlinks in doom-emacs-dir (and inline it) 2018-09-19 19:41:46 -04:00
Henrik Lissner
cc28aacecb
Don't inline DOOMDIR in doom-private-dir
Breaks DOOMDIR when config is byte-compiled, as mentioned in #900
2018-09-19 19:27:49 -04:00
Henrik Lissner
f4e119a642 Couple core-packages to package.el sooner
This way, if the user loads package.el themselves, doom's package.el
settings will take effect immediately.
2018-09-18 15:19:50 -04:00
Henrik Lissner
b96d50b3de history-length = 500 2018-09-18 15:19:50 -04:00
Henrik Lissner
e80f5e4c85
Remove unnecessary optimization in doom-try-run-hook
Hooks run with this should already be run in a gc-deferred state (at
startup), so deferring garbage collection _again_ may just cause
unnecessary consing.
2018-09-18 11:45:13 -04:00
Henrik Lissner
b7be38b2a9
New incremental lazy-loading at startup
This is for loading large packages (like org and magit) quietly in the
background during idle time. It is already set up to incrementally load
org and magit.

This is still experimental, however. the idle timers may need to be
tweaked.
2018-09-18 11:42:35 -04:00
Henrik Lissner
a9fdeefe15
Revert 142d364
Only add doom-private-dir to load-path during autoload generation,
otherwise a $DOOMDIR/autoload.el will shadow the built-in autoload.el
Emacs package.

Note: with `doom-private-dir' in `load-path', Doom autoloads files will
be unable to declare autoloads for the built-in autoload.el Emacs
package, should $DOOMDIR/autoload.el exist. Not sure why they'd want to
though, so it's an acceptable compromise for simpler autoload
declarations.
2018-09-14 09:39:40 -04:00
Henrik Lissner
142d3646ef
Add doom-private-dir to load-path
Makes private autoload paths simpler
2018-09-13 19:15:15 -04:00
Henrik Lissner
75036cefb0 Revert max-{specpdl-size,lisp-eval-depth} changes
They were unnecessary and could cause crashing in some cases.
2018-09-10 09:04:27 -04:00
Henrik Lissner
f07ae6a02b
max-specpdl-size = 5000, max-lisp-eval-depth = 2500
The defaults were designed for much, much older systems. We can safely
increase this to stave off premature abortion of intentional deeply
nested loops or excessive allocations.
2018-09-09 09:58:20 -04:00
Henrik Lissner
57579b883b
Refactor doom core files 2018-09-09 09:58:20 -04:00
Henrik Lissner
7d3ffdff06
Remove third line in section headers
This is truly important stuff. We've saved many lives with this update.
2018-09-09 09:58:19 -04:00
Henrik Lissner
eaa10946f1
Refactor startup optimizations
+ Add doom-gc-cons-upper-limit variable
+ Don't use most-positive-fixnum, in case Emacs somehow wants to
  allocate that much!
+ Don't use startup optimizations in noninteractive sessions
+ Restore gc-cons-threshold on idle timer, instead of hook (to defer the
  possible GC pause and so deferred packages can take advantage of these
  optimizations).
2018-09-03 03:58:43 +02:00
Henrik Lissner
daef19ba64
Defer garbage collection in the minibuffer
This can speed up things that run in or from the minibuffer, like
projectile/helm/ivy commands.
2018-09-02 17:06:12 +02:00
Henrik Lissner
712b775f36
Remove doom*set-indirect-buffer-filename hack
This was done to help the modeline build its file path in indirect
buffers, but this has been fixed by using buffer-base-buffer.

Both ui/modeline and ui/doom-modeline have been refactored to
accommodate this.
2018-09-01 12:39:26 +02:00
Henrik Lissner
300181aba3
Move custom hooks in core.el closer to top
Conform to the Doom/lisp convention of defining customizable elements
close to the top of files.
2018-08-26 00:20:18 +02:00
Henrik Lissner
631c4004ba
Load custom-file only once & after user's config
This change facilitates the users that prefer their custom-file
somewhere other than doom-local-dir (e.g. in ~/.doom.d/custom.el).

This change prevents loading both files during startup. Just change
`custom-file` and Doom will load it after your config.el is loaded (but
before doom-post-init-hook runs).
2018-08-25 19:45:23 +02:00
Henrik Lissner
62977247c9
Revert da7f9019 & refactor doom init hooks 2018-08-21 04:27:14 +02:00
Henrik Lissner
da7f9019d1
Run doom-post-init-hook as late as possible
Possibly fixes recursive load errors, to do with
kill-buffer-query-functions and buffer-predicate autoloads loading in a
weird way on Emacs 25 (and especially on MacOS, for some reason).
2018-08-21 04:03:05 +02:00
Henrik Lissner
ee73d6c9af
Minor reformatting & comment tweaks 2018-08-21 03:34:39 +02:00
Henrik Lissner
f923ed4341
Add docstrings to doom-inhibit-switch-*-hooks vars 2018-08-17 04:34:43 +02:00
Henrik Lissner
deea5f11b3
Fix enter/exit window/buffer hook names 2018-08-17 04:01:46 +02:00
Henrik Lissner
4a4b012b5d
Move custom hooks to core/core.el
Also ensures that the custom hooks aren't fired until as late as
possible, which prevents a few packages from prematurely loading at
startup. Faster startup! Yay!
2018-08-17 01:57:09 +02:00
Henrik Lissner
25d9786edf
Add early-init-file support to doom/profile-emacs #788
And fix wrong-type-argument: stringp errors when running esup.

Also ensure that doom|run-all-startup-hooks sets after-init-time.
2018-08-13 03:47:33 +02:00
Henrik Lissner
36044fccc9
defconst -> defvar for global constants
So they can be changed prior to being defined (e.g. for
doom/open-vanilla-sandbox).
2018-08-12 02:45:28 +02:00
Henrik Lissner
6eafdd7c62
Refactor module load process
doom! no longer loads modules, it only sets
doom-modules (incrementally).

Instead, modules are loaded by doom-initialize-modules (which makes more
sense).
2018-08-08 23:37:30 +02:00
Henrik Lissner
f88a97177c
Rename doom-ensure-core-directories
Give it a more descriptive name
2018-08-08 23:37:30 +02:00
Henrik Lissner
ea0f46b181
Add 2nd arg to doom-initialize to load core libs
This restores the correct value of noninteractive while core libs are
loading, so packages like recentf can avoid initializing when running
emacs non interactively (thus polluting output or possibly causing
errors).
2018-08-03 16:35:42 +02:00
Henrik Lissner
f16597ec72
Set gamegrid-user-score-file-directory
THIS IS IMPORTANT GUYS
2018-08-02 17:06:30 +02:00
Henrik Lissner
f3a3465c04
history-length = 250
Reduce from 500 to slim savehist data files and general Emacs memory
footprint.
2018-07-29 17:41:59 +02:00
Henrik Lissner
4941e327f4
General refactor for readability
+ Removes redundant/unhelpful comments
+ Renames functions, hooks and variables to be self-documenting
+ Use add-to-list to ensure idempotency (and is more performant)
2018-07-09 15:33:31 +02:00
Henrik Lissner
3d3d04b21c
Move use-package config to core-modules 2018-06-20 12:48:59 +02:00
Henrik Lissner
1efb0a8298
Rename core-dispatcher -> core-cli
The file's role is easier to guess at a glance.
2018-06-20 12:04:11 +02:00
Henrik Lissner
151858a8dc
Redesign Doom error handling
Another refactor, again to improve the locality of doom errors and make
the data that accompanies them more useful in determining the origin and
source of issues. Also, bin/doom is now a little more informative about
how to debug errors.
2018-06-20 02:07:12 +02:00
Henrik Lissner
84756b33a0
Fix closure symbolp errors blocking stacktraces
Caused because of symbol-file advice assuming SYMBOL would always be a
symbol.

This would prevent backtraces from happening, making debugging
impossibly obtuse.

This may indirectly fix #701
2018-06-20 01:59:07 +02:00
Henrik Lissner
600d7bcb4f
core: minor refactor/reformat
+ Prefer cl-loop over cl-mapcan for performance reasons.
+ Remove unnecessary let form
+ Log doom-try-run-hook when doom-debug-mode is on.
2018-06-19 20:55:44 +02:00
Henrik Lissner
0fefc43d39
Refactor autoloads init & error handling
Also reduces byte-compiled forms in the backtrace of a
doom-autoload-error.
2018-06-19 17:19:11 +02:00
Henrik Lissner
2c1b0ccaf8
Fix doom|run-all-startup-hooks
Wasn't using doom-try-run-hook correctly.
2018-06-19 12:01:51 +02:00
Henrik Lissner
4685eddb66
Don't eat stacks in backtraces in debug mode
The error handlers were a little too effective. They obscured a large
chunk of the stacktrace after errors, even in debug mode. This fixes
that and ensures backtraces in debug mode are more helpful.
2018-06-18 17:14:17 +02:00
Henrik Lissner
32954ecb69
Move compile-time fix for disabled packages
This fix prevented the byte-compiler from trying to load packages that
were disabled or failed their :when/:unless/:if predicates. This commit
moves it into doom-byte-compile, so the :no-require predicate doesn't
have to run on every package in an interactive session, eating MY
PRECIOUS cpu cycles.

I do love my cpu cycles, yessiree.
2018-06-18 14:52:24 +02:00
Henrik Lissner
ab07e07352
Improve general error handling at startup
This will hopefully reveal more information as to the cause and origin
of errors at startup. It should also make doom-debug-mode more likely to
produce a backtrace in non-interactive sessions.
2018-06-18 14:47:36 +02:00
Henrik Lissner
0d925cda5e
Load core-os sooner & in all sessions
Indirectly fixes set-env! errors when using it from your init files.
2018-06-18 12:04:30 +02:00
Henrik Lissner
26caea7f2b
Move doom-docs-dir to core.el 2018-06-17 21:39:40 +02:00
Henrik Lissner
03022d09f9
Remove doom//x naming convention
This naming convention was meant to be for batch commands, but it grew
to include "commands that were helpful with managing Doom", but many of
these commands shouldn't be interactive in the first place!
2018-06-17 21:35:58 +02:00
Henrik Lissner
1184967531
Advise symbol-file to return doom-file property
...if it exists. Otherwise fall back on original functionality. This
allows certain symbols to overwrite where Emacs thinks they were
defined.

Warning: only use this for autodefs! It may have unintended side-effects
for other symbols.
2018-06-15 16:20:20 +02:00
Henrik Lissner
bbda434365
Move startup optimizations into init.el
Doesn't really belong in core.el and only applies to interactive
sessions.
2018-06-15 16:20:20 +02:00
Henrik Lissner
db8b4091dd
Fix bin/doom ignoring -d flag
defconst -> defvar
2018-06-15 00:25:39 +02:00
Henrik Lissner
04ec62c8f2
General, minor refactor & feedback revision 2018-06-14 19:49:03 +02:00
Henrik Lissner
933023d779 Minor reformatting & docstring revision in core.el 2018-06-13 22:16:08 +02:00
Henrik Lissner
85591ca296
Move custom-file into local-dir (not etc-dir)
Makes more sense to put more vital files in local than etc or cache.
2018-06-12 12:17:33 +02:00
Henrik Lissner
4425fdfca4
defvar -> defconst for dir vars 2018-06-12 01:48:09 +02:00
Henrik Lissner
4c40195d40
Slightly better version check error 2018-06-12 01:47:43 +02:00
Henrik Lissner
0741c8851a
Split core-packages into two (packages & modules)
+ Move doom-initialize et co into core.el
+ Lazy load core-packages
+ load! has been moved into core-lib
+ Added FILE! and DIR! macros
+ Fix package! not returning correct value when package is disabled
+ Remove :disabled support for def-package-hook! officially
2018-06-12 00:02:04 +02:00
Henrik Lissner
2605a3938e
Initialize modules conditionally
doom-modules will be initialized on demand in non-interactive sessions.
2018-06-10 17:28:17 +02:00
Henrik Lissner
01d1a814f9
Refactor doom-initialize functions
Removes doom-module-table; which was inflexible (though more stable). It
prevented you from putting your doom! block in anywhere but
~/.doom.d/init.el.

It is replaced (somewhat) by (doom-modules).
2018-06-10 17:30:26 +02:00
Henrik Lissner
81c465a545
Move OS constants to core/core.el
So it is universally available to all of Doom, rather than excluding
sessions that haven't called doom-initialize interactively.
2018-06-08 13:31:45 +02:00
Henrik Lissner
b26bbd4762
Fix args-out-of-range in enable-minor-mode-maybe
Caused by trying to use out-of-scope match data.
2018-06-07 02:51:03 +02:00