Commit Graph

391 Commits

Author SHA1 Message Date
Henrik Lissner
c795a988e6
Conform many modules to new conventions 2019-07-23 12:30:47 +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
a7ce48c2df
bin/doom: add -l/--local/DOOMLOCALDIR
Will come in handy for the new testing framework.
2019-07-22 02:37:48 +02:00
Henrik Lissner
060ede0e2e
General, minor reformatting across the board
And an offering of blood to our great lord Byte Compiler-sama.
2019-07-22 02:37:45 +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
0a84d2f0a9
core-lib: add auto-minor-mode, revise def-project-mode!
- Adds the auto-minor-mode package to replace our in-house
  implementation.
- Merges associate! into the def-project-mode! macro because associate!
  on its own is less useful than auto-minor-mode-alist,
  auto-minor-mode-magic-alist or hooks.
- Changes the semantics of :modes and :add-hooks properties of
  def-project-mode!. Its arguments are evaluated as is; lists will need
  to be quoted.

squash! core-lib: remove associate! macro
2019-07-22 02:30:39 +02:00
Henrik Lissner
fdcb259bcd
Major refactor of Doom core files
- Remove core-os and move many of its settings out to other core
  libraries, where they belong
- Significantly improve commenting & compartmentalization of many
  settings
- Correct some mis-named public hooks (that were named as if they were
  private)
- Move the vast majority of optimizations to "Optimizations" section in
  core.el
- Don't activate xclip-mode or osx-clipboard-mode if we're accessing
  Emacs through an SSH connection (does more bad than good there)
- Add fast-but-imprecise-scrolling = t
- Set bidi-display-reordering = 'left-to-right, at the recommendation of
  an Emacs dev. Apparently setting it to nil is undefined, as Emacs is
  designed to always assume it's set; setting it explicitly to
  left-to-right will still do what was originally intended by turning it
  off: to reduce line/text scans for bidirectional text, which gives us
  a moderate boost in general runtime snappiness
- Set inhibit-compacting-fon-caches = t on windows (where it struggles
  especially with icon fonts)
- Disables "literal" mode for very large files (because I will be
  backporting so-long.el from Emacs 27 in the next commit)
2019-07-22 02:30:38 +02:00
Henrik Lissner
81ab3dbc5d
Simplify and decouple init files
The two doom-gc-* variables in init.el couples the rest of the config to
these two files. The bulk of GC/file-handler optimization was moved into
core.el and simplified (all that idle-timer voodoo was overkill).

Also adds (setq frame-inhibit-implied-reize t) to early-init, which
speeds up startup a fair bit in some edge cases with larger fonts.

squash! Simplify and decouple init files
2019-07-22 02:30:38 +02:00
Henrik Lissner
149b2617b0
💥 revise hook/var fns naming convention (2/2)
This is second of three big naming convention changes. In this commit,
we change the naming conventions for hook functions and variable
functions:

1. Replace the bar | to indicate a hook function with a -h suffix, e.g.

     doom|init-ui -> doom-init-ui-h
     doom|run-local-var-hooks -> doom-run-local-var-hooks-h

2. And add a -fn suffix for functions meant to be set on variables,
   e.g.

     (setq magit-display-buffer-function #'+magit-display-buffer-fn)

See ccf327f8 for the reasoning behind these changes.
2019-07-22 02:30:38 +02:00
Henrik Lissner
51d3b1b424
💥 revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.

In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.

  doom*shut-up -> doom-shut-up-a
  doom*recenter -> doom-recenter-a
  +evil*static-reindent -> +evil--static-reindent-a

The rationale behind this change is:

1. Elisp's own formatting/indenting tools would occasionally struggle
   with | and * (particularly pp and cl-prettyprint). They have no
   problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
   github markdown) struggle with it, sometimes refusing to highlight
   code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
   intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
   on haphazardly way back when Doom was simply "my private config".

Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.

Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
  macro. The old pair weren't as useful. The new def-advice! saves on a
  lot of space.
- Removed "stage" assertions to make sure you were using the right
  macros in the right place. Turned out to not be necessary, we'll
  employ better checks later.
2019-07-22 02:27:45 +02:00
Henrik Lissner
b4d004a91a
Don't read envvar literally at startup #1549 2019-07-10 15:01:01 +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
b245237b0c
Move custom-file to DOOMDIR/init.el
(And don't auto-load it at startup; no need)
2019-06-26 14:31:06 +02:00
Henrik Lissner
ae365272ad
Set exec-path/shell-file-name in doom-load-env-vars
And perform file-readable-p check inside doom-load-env-vars
2019-06-18 11:46:27 +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
72fd61e07b
Ensure order of after-change-major-mode-hook hooks
Reduces the likeliness of load order issues.
2019-06-16 19:16:23 +02:00
Henrik Lissner
653bd99b77
Polyfill kill-current-buffer in Emacs<=25.3 #1446
kill-current-buffer wasn't introduced until Emacs 26.
2019-06-10 09:38:55 +02:00
Henrik Lissner
9413e9ccae
Remove tutorial--saved-dir
See #1433: it is a function, not a variable.
2019-05-28 23:47:52 -04:00
Henrik Lissner
0383e504fe
Fix exec-path on Windows #1423
Windows uses ; as its PATH separator.
2019-05-21 17:24:22 -04:00
Henrik Lissner
4d20655f78
Optimize incremental loading
Interrupt package loading if Emacs recieves input. This further reduces
percieved pauses at startup.
2019-05-19 02:17:58 -04:00
Henrik Lissner
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
Henrik Lissner
40d2d4d222
Minor tweaks & byte-compiler offerings 2019-05-15 20:53:11 -04:00
Henrik Lissner
a4fb4070ea
Rework how unicode fonts are set and loaded 2019-05-15 20:24:52 -04:00
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