Commit graph

17811 commits

Author SHA1 Message Date
Henrik Lissner
b480ed51a3
refactor(lib): suppress map! at compile/batch time
It's not useful in those scenarios, and is more likely to throw up
unrecoverably keybind conflict errors, when load order is determined by
an over-eager byte-compiler, rather than Doom's standard startup
process.
2022-09-16 01:14:21 +02:00
Henrik Lissner
701f51c3d6
refactor(lib): use uninterned symbols for transient/chained hooks
The debugger appears to display uninterned symbols properly, and since
these symbols should never be touched/referenced by users, there's no
reason to pollute the obarray with these transient symbols.
2022-09-16 01:14:21 +02:00
Henrik Lissner
cf1c6e9a68
dev(ci): fix commit linter config for module scopes
This file used to live in /.github/ci.el. It was later moved to
/.doomrc (in 9b8ed39), but I forgot to push this change to update the
relative path to Doom's modules. This caused the linter to complain that
all module scopes were invalid.

Also, I removed the $DOOMDIR/modules/ check, as modules in the user's
config shouldn't be factored into the list of valid scopes.

Amend: 9b8ed397e8
2022-09-16 01:14:21 +02:00
Henrik Lissner
26914d0369
refactor(lib): use ansi-color-apply
Rather than reimplement its face lookup (and have two versions of
doom-print-ansi-alist -- one for 27.x and one for 28+), let's just rely
on ansi-color.
2022-09-16 01:14:21 +02:00
Henrik Lissner
94ea4aa7dc
docs: add examples.org
This adds the basic framework of docs/examples.org, including the former
contents of demo.org in :lang emacs-lisp. elisp-demo has also been
reconfigured to search it instead.

Keep in mind that examples.org references a few things in as-of-yet
published documentation. This will be rectified soon.
2022-09-16 01:14:20 +02:00
Henrik Lissner
e71daf5cc3
tweak(emacs-lisp): elisp indentation for data/plists
This was adapted from
https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_indentation_of_quoted_lists/.
It fixes the indentation of quoted data (and plist keywords) so they're
indented like data, rather than function arguments, like so:

  BEFORE:
    `(foo bar baz
          doom emacs)
    '(:foo 1
           :bar 2
           :baz 3)
    '(:foo 1
           2
           3
           :bar 4)
    (:foo 1
          :bar 2)
    (:foo 1
          ;; test comment
          :bar 2)
    (:foo 1
          2
          :bar 3)

  AFTER:
    `(foo bar baz
      doom emacs)
    '(:foo 1
      :bar 2
      :baz 3)
    '(:foo 1
      2
      3
      :bar 4)
    ;; only align unquoted keywords if keywords start each line:
    (:foo 1
     :bar 2)
    (:foo 1
     ;; test comment
     :bar 2)
    (:foo 1
          2
          :bar 3)

Also, I added a way to declare that plists in an macro's arguments
should be indented like data:

  (put 'map! 'indent-plists-as-data t)

  BEFORE:
    (map! :localleader
          :map emacs-lisp-mode-map
          (:prefix ("d" . "debug")
                   "f" #'+emacs-lisp/edebug-instrument-defun-on
                   "F" #'+emacs-lisp/edebug-instrument-defun-off))

  AFTER:
    (map! :localleader
          :map emacs-lisp-mode-map
          (:prefix ("d" . "debug")
           "f" #'+emacs-lisp/edebug-instrument-defun-on
           "F" #'+emacs-lisp/edebug-instrument-defun-off))

There was a third improvement I was hoping to include, namely,
proper indentation of interpolated forms:

  BEFORE:
    `(foo
      bar
      ,(if t
           'baz
         'boo))

    `(foo
      bar
      (if t
          baz
        boo))

  AFTER:
  `(foo
    bar
    ,(if t
          'baz
        'boo))

  `(foo
    bar
    (if t
     baz
     boo))

But this was removed because it breaks indentation for quoted macro
forms (or dynamic elisp programming):

  BEFORE: (good)
    `(with-temp-buffer
       (if (always)
           (message
            "Hello %s"
            user-login-name)
         (message
          "Goodbye %s"
          user-login-name)))

  AFTER: (bad)
    `(with-temp-buffer
      (if (always)
       (message
        "Hello %s"
        user-login-name)
       (message
        "Goodbye %s"
        user-login-name)))

Ref: https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_indentation_of_quoted_lists/'
2022-09-16 01:14:20 +02:00
Henrik Lissner
3fe1641937
feat(lib): add doom-compile-function
To be used in some autoloaded libraries, in case they haven't been
byte-compiled and contain especially expensive functions.
2022-09-16 01:14:20 +02:00
Henrik Lissner
a18ea683d2
refactor(python): autoload syntax highlighter fix for 28.1
A summary of the issue:
- emacs-mirror/emacs@c44908c059 broke syntax highlighting for
  python-mode.
- emacs-mirror/emacs@a8acb9516e fixes the issue shortly after, but the
  fix did not make it into the 28.1 release (but made it into 28.2).
- This fix was deployed in #6414 (773122f1ec).
- This commit ensures the fix is only effective for 28.1 users, and
  documents it for posterity.

Ref: #6414
Ref: emacs-mirror/emacs@c44908c059
Ref: emacs-mirror/emacs@a8acb9516e
Amend: 773122f1ec
Co-authored-by: dani84bs <dani84bs@users.noreply.github.com>
2022-09-16 01:14:20 +02:00
Henrik Lissner
f49953ab56
feat(lib): add versionp! macro
A convenience macro for Emacs' version API, for performing compound
version checks in less code.
2022-09-16 01:14:20 +02:00
Henrik Lissner
dde728d847
fix(lib): void-function insert-into-buffer on Emacs 27
insert-into-buffer was introduced in 28.1
2022-09-16 01:14:20 +02:00
Henrik Lissner
6a83079d2e
refactor: move core optimizations to doom-start
These only benefit interactive sessions, and doom-start's responsibility
is to configure interactive sessions; it doesn't make sense to keep
these in core.
2022-09-16 01:14:20 +02:00
Henrik Lissner
b7bd27d22b
refactor(cli,lib): print levels & output redirection
This refactors how Doom captures and redirects its output (to stdout and
stderr) into a more general with-output-to! macro, and:

- Simplifies the "print level" system. The various doom-print-*-level
  variables have been removed.
- Adds a new print level: notice, which will be the default level for
  all standard output (from print!, doom-print, prin[ct1], etc).
- Adds a with-output-to! macro for capturing and redirecting
  output to multiple streams (without suppressing it from stdout). It
  can also be nested.
- Changes the following about doom-print:
  - Default :format changed to nil (was t)
  - Default :level changed to t (was `doom-print-level`)
  - No longer no-ops if OUTPUT is only whitespace
2022-09-16 01:14:20 +02:00
Henrik Lissner
6cac7b05b6
refactor(lib): tidy doom-log output
This commit reduces the debug log noise, makes it easier to
read/parse/search, and soft-introduces a convention for doom-log
messages, where they are prefixed with a unique identifier loosely named
after it's running context or calling function.

I haven't enforced it everywhere doom-log is used yet, but this is a
start.
2022-09-12 16:01:43 +02:00
Henrik Lissner
0c43c769ef
refactor!: replace doom-incremental-load-immediately var
BREAKING CHANGE: This removes the doom-incremental-load-immediately
variable. Instead, set doom-incremental-first-idle-timer to 0 to force
all iloaded packages be eagerly loaded at startup. This is already the
default behavior for daemon sessions.
2022-09-12 15:59:29 +02:00
Henrik Lissner
bcf7a8a554
refactor!(cli): rename cli definers for consistency
BREAKING CHANGE: If anyone is using Doom's CLI framework and are
defining their own CLIs with any of the following macros, they'll need
to be updated to their new names:

- defautoload! -> defcli-autoload!
- defgroup! -> defcli-group!
- defstub! -> defcli-stub!
- defalias! -> defcli-alias!
- defobsolete! -> defcli-obsolete!

These were renamed to make their relationship with CLIs more obvious;
they were too ambiguous otherwise.
2022-09-12 11:45:59 +02:00
Henrik Lissner
0ce2989d86
refactor(lib): remove redundant full? arg in doom-glob
file-expand-wildcards already does this check, internally.
2022-09-12 11:45:59 +02:00
Henrik Lissner
afa154db27
refactor!(emacs-lisp): flycheck config in non-packages
BREAKING CHANGE: This performs the following backwards-incompatible
changes:

- Replaces `+emacs-lisp-reduce-flycheck-errors-in-emacs-config-h` with a
  `+emacs-lisp-non-package-mode` minor-mode.
- Removed the `+emacs-lisp-disable-flycheck-in-dirs` variable, as this
  mechanism no longer checks a directory list to detect a "non-package".

If you've referenced either of these symbols, you'll need to
update/remove them from your config. No extra config is needed
otherwise.

Why: Doom has always tried to reduce the verbosity of Flycheck when
viewing elisp config files or scripts (i.e. non-packages). These are so
stateful that the byte-compiler, package-lint, and checkdoc inundate
users with false positives that are more overwhelming than helpful.

The heuristic for this has always been a simple "is this file in
$DOOMDIR or $EMACSDIR", but this wasn't robust enough, especially in
cases where symlinking was involved, so I've employed a new, more
general heuristic for detecting non-package files:

- The file isn't a theme in `custom-theme-load-path`,
- The file doesn't have a (provide ...) or (provide-theme ...)
  statement whose first argument matches the file name,
- The file lives in a project with a .doommodule file (doom modules
  never have convention package files in them),
- Or the file is a dotfile (like .dir-locals.el or .doomrc).

I've also tweaked byte-compile-warnings to yield a little more output,
but not by much. Whether this is too permissive or not will require
further testing to determine.

What's more, I've updated this to reflect recent changes to Doom's
startup process (in c05e615).

Ref: c05e61536e
2022-09-12 11:45:56 +02:00
Jeff Kowalski
29e30e8af4 fix(cli): follow-on syntax fixes to #6772
While fixing #6772, we also address several other issues found by
sh-shellcheck:

L47C39 SC1007:Remove space after = if trying to assign a value
(for empty string, use var='' ... ).

L47C46 SC2046:Quote this to prevent word splitting.

L62C20 SC2086:Double quote to prevent globbing and word splitting.

L82C9  SC2154:tmpdir is referenced but not assigned
(did you mean 'TMPDIR'?).
2022-09-12 11:44:11 +02:00
Jeff Kowalski
571ab7425a fix(cli): #6772 - trivial doomscripts fail
When trying to establish the value of EMACSDIR, the proper fallback
when BASH_SOURCE is undefined is $0 rather than 0, in correct shell-
scripting parlance.
2022-09-12 11:44:11 +02:00
Sean Farley
2548632600 fix(mu4e): force the account stripe face to be non-italic
With mu4e came a new face for the header view. While this is nice for
the text, it had the consequence of making the account stripe (the
vertical bar) a bit jarring. This patch fixes that behavior to make the
stripe non-italic by append `'default` to the face.
2022-09-10 23:54:31 +02:00
tecosaur
01bb743c6c
tweak(mu4e): set last-child thread symbol
Also tweak the line order and whitespace while I'm at it, to show the
overall styling more clearly.
2022-09-10 23:52:36 +02:00
Ivan
6af7338140
refactor(lib): remove unreachable code in doom-print-class-alist
An earlier element in this alist associates buffer with
doom-print--buffer, so this later element is unreachable.
2022-09-10 23:51:40 +02:00
Ivan
44ff627e35
nit: remove unused base-specs arg in doom--make-font-specs 2022-09-10 23:48:56 +02:00
Ivan
ffe3dd59ff
fix: error caused by typo in doom--recentf-file-truename-fn 2022-09-10 23:46:40 +02:00
Krzysztof Baranowski
836d229636 fix(nix): remove :mode hook for nix-drv-mode
The nix-mode package already does this and it shadows other entries for the .drv files in auto-mode-alist (namely Guix derivations).

Ref: 34d51e2731/nix-drv-mode.el (L48)
2022-09-10 23:37:50 +02:00
Henrik Lissner
251ccbcc6b
fix: package recipes with relative :local-repo
Necessitated by 7e0c2ed, and missed in 45a66cd. This would indirectly
cause "No :repo specified for package 'X'" errors for packages with a
`:local-repo` relative to their packages.el file.

Amend: 45a66cda60
Ref: 7e0c2ed8a3
2022-09-10 20:45:44 +02:00
Henrik Lissner
c80fa2efdf
fix: all packages seen as disabled
In v3, doom-module data is stored in symbol plists, but in v2, it's
stored in a hash table. Some v3 code snuck into 45a66cd, which made Doom
try to read module data from plists that hadn't been initialized yet, so
Doom could no longer see your module settings.

Fix: #6769
Amend: 45a66cda60
2022-09-10 20:03:45 +02:00
Henrik Lissner
7a2fa1e313
fix(cli): doctor warnings about irrelevant bytecode
This would check for stale bytecode across all profiles or even .local*
directories created by shell.nix, which is unnecessary.
2022-09-10 20:03:24 +02:00
Henrik Lissner
45a66cda60
fix: ensure module state is in scope for modulep!
Otherwise, doom-module-from-path (and modulep!) would fail to detect the
module they're in, or at least, modulep! would incorrectly return nil,
even for enabled modules.

This issue is what would've caused the package list or the doctor to
include/consider packages in disabled modules or behind disabled flags.
2022-09-10 19:11:03 +02:00
Henrik Lissner
ce0e3a04b6
tweak(lib): prevent redundant timestamps in logs 2022-09-10 18:36:24 +02:00
Henrik Lissner
78af0eeecb
fix(lib): only set top-level values of debug variables 2022-09-10 18:36:24 +02:00
Henrik Lissner
05d06cc552
tweak(lib): suppress GC logging in debug mode
It happens so often it can overwhelm the echo area. It's still logged
to *Messages* however.
2022-09-10 18:36:24 +02:00
Henrik Lissner
d290152a8e
refactor(lib): replace doom-debugger with advice
Writing a debugger for Elisp is too much hassle. `debug` itself isn't
very customizable without a *lot* of boilerplate, so instead of writing
my own, it's more effective to advise debug instead. Certainly, I don't
do anything with it yet, but I will soon.
2022-09-10 18:36:24 +02:00
Henrik Lissner
b66ccaeca0
fix(agda): tree-sitter compatibility with agda2-mode
Tree-sitter-lang recognized agda-mode, but not agda2-mode.
2022-09-10 18:36:24 +02:00
Henrik Lissner
49f4ec3b10
feat(tree-sitter): add set-tree-sitter-lang! autodef 2022-09-10 18:36:24 +02:00
Henrik Lissner
151300ecce
feat(cli): deny XDG, Wayland, Sway, + socket envvars
Additional envvars that would not be helpful to persist.

Ref: https://discourse.doomemacs.org/t/3088
2022-09-10 18:36:24 +02:00
Henrik Lissner
c59fe8596f
dev: handle blank shell.nix inputs properly
If doomdir, emacsdir, and/or doomlocaldir were blank, / would be treated
as their value, which will fail in some spectacular (and some quiet)
ways.
2022-09-10 18:36:23 +02:00
Henrik Lissner
b5b0d5de1c
dev: update shell.nix
To include a wider selection of Emacs versions.

Also makes 28.1 the default version.
2022-09-10 18:36:23 +02:00
Henrik Lissner
c747d218ae
refactor(cli): throw error if Doom fails to load 2022-09-10 18:36:23 +02:00
Henrik Lissner
3505e666a8
fix: failure to load doom libs on 27.x
Emacs 27.x does not collapse consecutive slashes in a file path when
trying to load them, and instead discards everything before it and
treats the rest as an absolute path, e.g. "~/some//path/foo/" ->
"/path/foo". This is not the case in 28.1, but Doom's backport of
file-name-concat did not take this into account, so it's been modified
to trim trailing slashes.

Fix: #6766
Amend: 433c9e344d
2022-09-10 18:33:02 +02:00
Henrik Lissner
eb80d461df
fix(lib): void-function macroexp-file-name error
This function was introduced in Emacs 28.1, so 7e0c2ed was a breaking
change for 27.x users.

Fix: #6766
Amend: 7e0c2ed8a3
2022-09-10 13:03:53 +02:00
Henrik Lissner
7e931ec586
fix: file-missing errors while trying to build packages
This is caused by a bug in recent builds of Emacs 29, where
`loaddefs-generate` will activate emacs-lisp-mode to read a package's
autoloads, but does so without suppressing its mode hooks. Other
packages may add functions to this hook from their autoloads (like
overseer.el does). Calling these functions will initiate a chain
reaction where other packages will be loaded (plus their dependencies),
but aren't guaranteed to be available so early in the bootstrap process.
The result are file-missing errors about seemingly unrelated packages,
like pkg-info or dash.

Ref: emacs-mirror/emacs@0d383b592c
Fix: https://discourse.doomemacs.org/t/3149
2022-09-10 12:38:53 +02:00
Henrik Lissner
96ae3f1b04
fix(cli): nativecomp error writing to read-only fs
Occurs when a site-file fails to be natively compiled, and Doom attempts
to write an error file in the same directory. On some systems, the
site-lisp directory is in a read-only tree/mount (like nix and guix).
This should suppress those attempts.
2022-09-10 12:08:16 +02:00
Henrik Lissner
f3e85afc7e
fix(lib): ensure after! body gets expanded
Relying on eval-after-load's compiler-macro magic (after 8b4f722) can
cause scope issues with nested macros (like file! and dir! running in
the context of a temp buffer), so best we use with-eval-after-load
directly.

Ref: 8b4f722fa3
2022-09-10 11:59:48 +02:00
Henrik Lissner
7e0c2ed8a3
fix(lib): convert file! and dir! to macros
To ensure that they're expanded at a file's top-level, while expanded,
where they're used. It also fixes a few inlined uses of the file!
macro (e.g. in `load!`, as reported in #6764), which was prematurely
committed ahead of this change.

Close: #6764
Amend: a179b8d262
2022-09-10 11:59:17 +02:00
Henrik Lissner
46e23f37ba
fix: memory leak & freezes on native-comp+pgtk builds
b7f84bd introduced a nasty regression that caused an infinite loop and
runaway memory usage on some pgtk+native-comp builds of Emacs when it
attempted to perform deferred native compilation of your packages. This
would make Emacs unusable and, if left alone, could even crash your
system.

The only Emacs builds I'm certain are affected are derived from
flatwhatson/emacs (like emacs-pgtk-native-comp on Guix and Arch Linux in
particular). 28.1 stable and master (on emacs-mirror/emacs@e13509468b)
are unaffected.

It appears that some, earlier pgtk builds stack idle timers differently.
I'm not entirely sure how, because it doesn't manifest in more recent
builds of Emacs, and I'm already burnt out on debugging this, but here's
how Doom encountered it:

Doom has an incremental package loader; it loads packages, piecemeal,
after Emacs has been idle for 2s, then again every 0.75s until it
finishes or the user sends input (then it waits another 2s before
starting again). However, if at any time the iloader detected that
native-compilation is in progress, it waits 2s before trying
again (repeat, until native-comp is done). But here's the catch, given
the following:

  (run-with-idle-timer
   2 nil (lambda ()
           (run-with-idle-timer 1 nil (lambda () (message "hi")))))

I had assumed "hi" would be emitted after 3 seconds (once idle), but
instead it is emitted after 2. Like this, Doom's iloader would elapse
one idle timer directly into another, ad infinitum, until Emacs was
forcibly killed.

By switching to run-at-time and employing my own rudimentary idle timer,
I avoid this issue. Also, the iloader no longer needs to be considerate
of native-comp, because the latter does its own rate-limiting controlled
by native-comp-async-jobs-number.

Amend: b7f84bdd01
2022-09-10 01:38:58 +02:00
Henrik Lissner
3fe81f4291
fix(cli): wrong-number-of-args error when auto-resolving prompts
E.g. 'doom sync -!' will auto-resolve repo conflicts, but this error was
preventing that.
2022-09-10 01:36:58 +02:00
Henrik Lissner
6e8de0bd89
refactor(lib): use num-processors
This C function was introduced in Emacs 28.1.
2022-09-08 13:36:17 +02:00
Henrik Lissner
cd269753cf
fix(lib): leave point at bob in with-file-contents!
with-file-contents!'s docstring promises that point will end up at the
beginning of the buffer, but this promise wasn't kept until now.
2022-09-08 00:24:16 +02:00
Henrik Lissner
b121c5e1c6
refactor(lib): provide doom-libs as subfeatures
This allows us to load them via doom-require. Why not use normal
features? Because Doom's libraries are designed to be loaded as part of
Doom, and will openly rely on Doom state if needed; this is a contract I
want to enforce by ensuring their only entry points are through
`doom-require` or autoloading.

I will add them to the rest of the libraries later.

Site-node: this also adds Commentary+Code to the comment headings, as I
want a space to use that space to describe the library, when I get
around to it.
2022-09-08 00:20:26 +02:00