Commit graph

82 commits

Author SHA1 Message Date
Henrik Lissner
36c24be6d4
release(modules): 24.04.0-dev
Ref: 2b39e41368
2024-05-21 17:17:10 +02:00
Henrik Lissner
8a813dd3fa
refactor: startup optimizations
I revisit all our startup optimizations to see how they fair in Emacs
29.x and 30.x. Most of them still hold up. I've revised and updated most
of the accompanying comments to better explain them, given what I know
now compared to when I first wrote them.
2024-05-21 17:17:10 +02:00
Henrik Lissner
6e60a5921c
tweak: enable startup optimizations in debug mode
Before this, startup optimizations were disabled in debug mode, but more
often than not, this just made it difficult to reproduce some errors at
startup.
2024-05-21 17:16:58 +02:00
Henrik Lissner
1aaaf9b851
refactor: consolidate startup--load-user-init-file advice
Splitting up all this advice was unnecessary noise.
2024-05-21 17:16:56 +02:00
Henrik Lissner
aedf2a194f
fix: shut up site-lisp
One various OSes, Emacs ships with site-lisp files that load
OS/architecture-specific config (like native-comp config), or load-lines
for Emacs packages installed via your OS package manager (like mu4e).
Output from these are rarely suppressed, for some reason, which causes
noise in *Messages* at startup, which triggers a redraw, which can be
very expensive during startup, depending on your window system.
2024-05-21 17:16:56 +02:00
Henrik Lissner
4997015ac7
fix: ensure inhibit-* is reset on startup error 2024-05-21 17:16:56 +02:00
Henrik Lissner
22309ad240
release(modules): 24.03.0-dev
Ref: 2b39e41368
2024-05-21 17:16:54 +02:00
Henrik Lissner
d4c3b12390
nit: revise and reformat comments 2024-05-21 17:16:52 +02:00
Henrik Lissner
df2cd34403
nit: fix s/make/bake typo 2024-05-21 17:16:37 +02:00
Henrik Lissner
ddd3f7564d
refactor!: deprecate IS-* OS constants
BREAKING CHANGE: This deprecates the IS-(MAC|WINDOWS|LINUX|BSD) family
of global constants in favor of a native `featurep` check:

  IS-MAC      ->  (featurep :system 'macos)
  IS-WINDOWS  ->  (featurep :system 'windows)
  IS-LINUX    ->  (featurep :system 'linux)
  IS-BSD      ->  (featurep :system 'bsd)

The constants will stick around until the v3 release so folks can still
use it -- and there are still some modules that use it, but I'll phase
those uses out gradually.

Fix: #7479
2024-05-21 17:16:36 +02:00
Henrik Lissner
fa0e73467d
release(modules): 24.02.0-dev
Ref: 2b39e41368
2024-05-21 17:16:36 +02:00
Henrik Lissner
16828e6dae
nit: minor comment revision, reformatting, & internal refactor 2024-05-21 17:16:31 +02:00
Henrik Lissner
0d1aec019c
fix: ensure top-level file-name-handler-alist is affected
Ensures that lexical contexts are never taken into account, in the case
where Doom's core is loaded in an isolated environment (e.g. the
sandbox). Also improves my startup time by 10%? I'll take it.
2024-05-21 17:16:31 +02:00
Henrik Lissner
a3118f9972
fix(lib): appease byte-compiler-sama
Silences some byte-compiler warnings about:

- 'nreverse on constant list' on add-hook! calls.
- inhibit-changing-match-data deprecation warning.
- unescaped quotes in docstring in some doom-*-dir variables.
- Variable non-essential should be quoted (though it isn't referring to
  a variable).
- CONTEXT -> CONTEXTS to match argument name.
2024-05-21 17:16:31 +02:00
Henrik Lissner
17dc4e4851
release(modules): 23.12.0-dev
This version bumps comes 3 months due to a short hiatus from moving back
from Denmark to Toronto and all the ensuing catch-up.

Ref: 2b39e41368
2024-05-21 17:16:28 +02:00
Henrik Lissner
ce25fd41cd
nit: reformatting, comment, and markup revision 2024-05-21 17:16:28 +02:00
Henrik Lissner
377bcdbbe6
tweak: emit feedback when started in daemon mode 2024-05-21 17:16:28 +02:00
Henrik Lissner
dabf992940
fix: write native-comp cache to $EMACSLOCALDIR
Otherwise, it writes them to /tmp. This way, the CLI can clean them up
along with other package state in the future.
2024-05-21 17:15:53 +02:00
Henrik Lissner
3837c9cb7e
release(modules): 23.09.0-dev
Ref: 2b39e41368
2024-05-21 17:15:52 +02:00
Henrik Lissner
6fdfce9f85
release(modules): 23.08.0-dev
This one comes quite late due to a personal hiatus over the past few
months.

Ref: 2b39e41368
2024-05-21 17:15:45 +02:00
Henrik Lissner
1cd2a287f5
nit: comment revision, spellcheck, & reformatting
Close: #7262
Co-authored-by: emergenz <emergenz@users.noreply.github.com>
2023-07-22 19:01:35 +02:00
Henrik Lissner
3e81655b0e
feat: add 'harfbuzz to features 2023-07-22 17:57:25 +02:00
Henrik Lissner
63586423da
release(modules): 23.03.0-dev
Ref: 2b39e41368
2023-03-11 20:25:45 -05:00
Henrik Lissner
225e159b04
release(modules): 23.02.0-dev
Ref: 2b39e41368
2023-02-23 04:18:11 -05:00
Henrik Lissner
357d10f5a7
feat: add doctor context
Ref: f9201eb218
2023-02-23 01:34:55 -05:00
Henrik Lissner
b0f91f6403
fix: void-variable native-comp-deferred-compilation-deny-list
In later versions of Emacs 29, this variable has been renamed without a
deprecation alias, causing void-variable errors wherever it is used.
Since it could potentially be used outside of Doom, I'll use a variable
alias until we formally drop 28 support (not for a long time).

Close: #7090
Co-authored-by: AdoPi <AdoPi@users.noreply.github.com>
2023-02-20 19:00:45 -05:00
Raymond Huang
aac3c15cde
fix: change warning-suppress-types to list of lists
warning-suppress-types' pre-29 documentation suggests that it accepts a
list of symbols, but a recent, upstream correction changes this.

Ref: emacs-mirror/emacs@d5ee49c25c
Amend: 8c442d84b9
2022-10-05 15:14:12 +02:00
Henrik Lissner
ba35f12be4
release(modules): 22.10.0-dev
Ref: 2b39e41368
2022-10-02 19:13:58 +02:00
Henrik Lissner
6eab48641f
fix: disable non-essential startup optimizations in debug-mode
As to not interfere with debugging.
2022-10-02 18:46:37 +02:00
Henrik Lissner
9f512a60bf
nit: mention test env for startup optimizations
And remove "debug-mode" clause because of c20ba77.

Ref: c20ba77ff7
2022-09-29 17:35:56 +02:00
Henrik Lissner
71f7e4b5b8
perf: defer resetting inhibit vars further 2022-09-26 12:41:00 +02:00
Henrik Lissner
fbe94ba9f2
perf: inhibit display-startup-screen 2022-09-26 12:39:10 +02:00
Henrik Lissner
8bf308f9b1
fix: failure to recognize X switches in PGTK builds
This is a regression introduced in 1c4217a.

Doom unsets command-line-x-option-alist when it reasonably suspects it's
not running in an X environment. The heuristic for that is checking when
`initial-window-system` is set to `x`, but as it turns out, PGTK builds
of Emacs set this to `pgtk`, so PGTK users were deprived of Emacs' X
switches, like --geometry, --foreground, --font, etc (they'd throw an
"Unknown option" error at startup). This was fixed.

However, this heuristic isn't perfect. Not all PGTK users are on X (I'd
hazard to guess most of them aren't). So a more reliable check is
needed (and it's too early in the startup process for us to call
display-graphic-p on any frame). The `(not IS-LINUX)` or `(or IS-MAC
IS-WINDOWS)` I had previously used (before 1c4217a) wasn't enough
either, because users can (and do) install X on these
systems (especially where WSL is involved). Still, until I've found a
better one, this is an acceptable workaround.

Amend: 1c4217aa27
2022-09-25 11:35:48 +02:00
Henrik Lissner
c20ba77ff7
tweak: employ startup optimizations even in debug mode
It's kind of a pain to have different behavior when you're debugging.
Some errors may not present without them, so best to remain predictable
and permit these optimizations even when debug mode is on.
2022-09-24 22:10:02 +02:00
Henrik Lissner
8c442d84b9
perf: custom-dont-initialize = t
defcustom does some initialization work to accommodate the possibility
that the user has set the variable before it was defined.  This work is
unneeded so early at startup, so I disable it (temporarily).

In the future, Doom will use defcustom more, as it's a helpful
indication to readers what variables I intended for configuration (and
helps with discovery of options through `M-x doom/help-custom-variable`
or `M-x customize`). As that transition occurs, the benefit of this
optimization will begin to show, but for now its effect on startup time
is negligible.

* lisp/doom.el (warning-suppress-types): set this immediately. Since its
  default value is nil and this happens so early at startup, we don't
  have to be considerate of defaults. Plus, this custom-dont-initialize
  optimization can cause breakage if a warning is thrown *before* before
  this setting is changed.
2022-09-24 22:10:02 +02:00
Henrik Lissner
f9201eb218
refactor: introduce doom-context
Introduces a system to announce what execution contexts are active, so I
can react appropriately, emit more helpful logs/warnings in the case of
issues, and throw more meaningful errors.

* bin/doom: load module CLIs in the 'modules' context.
* lisp/cli/doctor.el: load package files in 'packages' context.
* lisp/doom-cli.el:
  - (doom-before-init-hook, doom-after-init-hook): trigger hooks at the
    correct time. This may increase startup load time, as the benchmark
    now times more of the startup process.
  - (doom-cli-execute, doom-cli-context-execute,
    doom-cli-context-restore, doom-cli-context-parse,
    doom-cli--output-benchmark-h, doom-cli-call, doom-cli--restart,
    doom-cli-load, run!): remove redundant context prefix in debug logs,
    it's now redundant with doom-context, which doom-log now prefixes
    them with.
* lisp/doom-lib.el (doom-log): prefix doom-context to doom-log output,
  unless it starts with :.
* lisp/doom-packages.el (package!, doom-packages--read): throw error if
  not used in a packages.el file or in the context of our package
  manager.
* lisp/doom-profiles.el (doom-profile--generate-init-vars,
  doom-profile--generate-load-modules): use modules doom-context instead
  of doom-init-time to detect startup.
* lisp/doom-start.el (doom-load-packages-incrementally-h): move function
  closer to end of doom-after-init-hook.
* lisp/doom.el:
  - (doom-before-init-hook, doom--set-initial-values-h,
    doom--begin-init-h): rename doom--set-initial-values-h to
    doom--begin-init-h and ensure it runs as late in
    doom-before-init-hook as possible, as that is the point where Doom's
    "initialization" formally begins.
  - (doom-after-init-hook): don't trigger at the end of command-line-1
    in non-interactive sessions. This will be triggered manually in
    doom-cli.el's run!.
* lisp/lib/config.el (doom/reload, doom/reload-autoloads,
  doom/reload-env): use 'reload' context for reload commands.
* modules/lang/emacs-lisp/autoload.el (+emacs-lisp-eval): use 'eval'
  context.
* modules/lang/org/config.el: remove doom-reloading-p; check for
  'reload' doom context instead.
2022-09-24 22:09:05 +02:00
Henrik Lissner
1c4217aa27
refactor: minor refactors & commentary revision
* lisp/doom-cli.el:
  - reference backport source commit.
  - doom-cli--restart: a type check is all we need here. This is a
    programmer error, not a user error.
* lisp/doom-editor.el (recentf): mention recentf-show-abbreviated (added in
  emacs-mirror/emacs@32906819ad)
* lisp/doom-keybinds.el (doom-init-leader-keys-h): move to
  doom-after-init-hook, in case the user customizes leader variables in
  a previous hook (like emacs-startup-hook or after-init-hook).
* lisp/doom-start.el: use eval-when! to compile out the section on
  non-macOS systems (when Doom gets around to compiling its core files,
  later).
* modules/config/literate/autoload.el (+literate-config-file): use
  file-name-concat instead of string concat. This relaxes the
  requirement that doom-user-dir end in a /; a requirement I intend to
  fully phase out.
* modules/lang/emacs-lisp/autoload.el (+emacs-lisp-non-package): remove
  empty map! macro in flycheck-emacs-lisp-check-form. The macro already
  no-ops at compile-time/in noninteractive sessions since b480ed51a3.
* modules/ui/hl-todo/config.el (hl-todo-keyword-faces): revise
  commentary for default hl-todo keywords.

Ref: emacs-mirror/emacs@32906819ad
Ref: b480ed51a3
2022-09-24 20:31:34 +02:00
Henrik Lissner
2fc3442508
nit: revise init hook docstrings & load order commentary 2022-09-24 18:46:21 +02:00
Henrik Lissner
a3a275624e
refactor: record doom-init-time in doom-after-init-hook 2022-09-24 18:46:21 +02:00
Henrik Lissner
5a5195b84d
fix: add :depth field to modules
This introduces a depth field for modules so that they may dictate their
load order explicitly, it also treats depths <= -100 or >= 100 as
special depths, which will be loaded early, before their respective
doom-{before,after}-module-{init,config}-hook. This permits psuedo
modules like :core and :user modules to be treated as normal modules
without too many special cases.

This also fixes a module load order issue on Emacs 29 (#6813), caused by
emacs-mirror/emacs@4311bd0bd7, which changed the return value order of
hash-table-{keys,values} causing modules to be loaded in reverse order;
resulting in the loss of evil keybinds, among other things.

Other notable changes:
- Changes the data structure for module data caches from a list to a
  vector. Uses less memory and permits faster lookups. Also adds two
  depth fields to the front of it.
- Changes the signature of doom-module-list and doom-package-list.
- Renames doom--read-packages -> doom-packages--read for consistency
  with naming convention.
- Add doom-module-depth function.
- Adds a temporary doom-core-dir/init.el file, which is responsible for
  loading doom-*.el.

Fix: #6813
Ref: emacs-mirror/emacs@4311bd0bd7
2022-09-24 18:46:21 +02:00
Henrik Lissner
a726ba33b9
tweak: use doom-profile-*-dir for core dir/file vars
In this commit I start using doom-profile-*-dir vars, though it will
make no difference to the default Doom install (only to profiles, and in
the future, in v3, where we'll drop $EMACSDIR/.local entirely).
2022-09-17 21:41:42 +02:00
Henrik Lissner
25bc9c9765
fix: defconst->defvar for more doom-*-dir vars
So they can be changed before doom.el is loaded (e.g. by profiles).
2022-09-17 21:41:42 +02:00
Henrik Lissner
00e8f6b72a
fix: don't require doom-local-dir end with a slash 2022-09-17 11:00:08 +02:00
Henrik Lissner
51a9745f38
perf: native-comp: use 1/4 of your cores instead of 1/2
The sudden spike in CPU and memory utilization alarms people, so I've
reduced how many cores native-comp will use. In non-interactive
sessions, it will use all of them, however (that is, when I later
introduce an AOT switch).

You can still override this by setting native-comp-async-jobs-number or
comp-num-cpus yourself.

I use advice instead of setting comp-num-cpus so that users to avoid
trampling on default behavior, or attempts by the user to change them.
2022-09-16 19:09:34 +02:00
Henrik Lissner
b598d41ffb
nit: correct comment header about startup optimizations
To claim they're ordered by effectiveness was silly of me, and was never
*quite* true, so I remove it altogether.
2022-09-16 01:14:25 +02:00
Henrik Lissner
f34e91d3b9
fix: guard tty-run-terminal-initialization against GUI sessions 2022-09-16 01:14:25 +02:00
Henrik Lissner
aa53ad2c1b
fix: load subr-x at compile-time in doom.el
This is more to nip 27.x issues in the bud, where fewer of subr-x's
macros are autoloaded.
2022-09-16 01:14:25 +02:00
Henrik Lissner
85f3b19f61
docs: revise version check failure message
- Recommend 28.1.
- Swap condition.
2022-09-16 01:14:24 +02:00
Henrik Lissner
a023482c36
perf: delay tool-bar-setup at startup 2022-09-16 01:14:24 +02:00
Henrik Lissner
b914830403
refactor!: complete profile gen and init systems
BREAKING CHANGE: This commit makes three breaking changes:

- Doom now fully and dynamically generates (and byte-compiles) your
  profile and its init files, which includes your autoloads, loading
  your init files and modules, and then some. This replaces
  doom-initialize-modules, doom-initialize-core-modules, and
  doom-module-loader, which have been removed. This has also improved
  startup time by a bit, but if you use these functions in your CLIs,
  for instance, this will be a breaking change.
- `doom sync` is now required for Doom to see your profiles (and must be
  run whenever you change them, or when you up/downgrade Emacs across
  major versions).
- $DOOMDIR/init.el is now read much earlier than it used to be. Before
  any of doom-{ui,keybinds,editor,projects}, before any autoloads are
  loaded, and before your load-path has been populated with your
  packages. It now runs in the context of early-init.el, giving users
  freer range over what they can affect, but a more minimalistic
  environment to do it in.

  If you must have some logic run when all that is set up, add it to one
  of the module hooks added in e08f68b or 283308a.

This also poses a significant change to Doom's load order (see the
commentary change in lib/doom.el), along with the following (non
breaking) changes:

1. Adds a new `doom profiles sync` command. This will forcibly resync
   your profiles, while `doom sync` will only do so if your profiles
   have changed.
2. Doom now fully and dynamically generates (and byte-compiles) your
   user-init-file, which includes loading all your init files, modules,
   and custom-file. This replaces the job of doom-initialize-modules,
   doom-initialize-core-modules, and doom-module-loader, which have been
   removed. This has also improved startup time by a bit.
3. Defines new doom-state-dir variable, though not used yet (saving that
   and the other breaking changes for the 3.0 release).
4. Redesigns profile directory variables (doom-profile-*-dir) to prepare
   for future XDG-compliance.
5. Removed unused/unimportant profile variables in doom.el.
6. Added lisp/doom-profiles.el. It's hardly feature complete, but it's
   enough to power the system as it is now.
7. Updates the "load order" commentary in doom.el to reflect these
   changes.
2022-09-16 01:14:23 +02:00