Commit graph

202 commits

Author SHA1 Message Date
Henrik Lissner
22d5e3059f
feat(emacs-lisp): extend config to lisp-{data,interaction}-mode
So these modes (and particularly .doom* dotfiles and .dir-locals.el) can
benefit from smarter syntax highlighting and integration with other
modules.
2024-09-17 05:56:44 -04:00
Henrik Lissner
d34770407c
fix(emacs-lisp): unremap describe-symbol to helpful-symbol
The latter can't look up cl types. Rather than remap it globally, allow
folks to bind them separately.
2024-09-14 15:22:06 -04:00
Henrik Lissner
6671adc687
refactor!: move helpful from :core to :lang emacs-lisp
BREAKING CHANGE: This moves helpful.el out of core into :lang
emacs-lisp. Since most (all) people have this module enabled, this
shouldn't make a difference for most people, but if you're one of the
few that don't have :lang emacs-lisp enabled, Doom will revert to using
Emacs' built-in help.el and describe-* commands.

Others can also disable helpful with (package! helpful :disable t) if
they prefer Emacs' built-in help system, which wasn't possible before,
because it was a core package.

This was done as part of an ongoing effort to slim down Doom's core in
preparation for v3.
2024-08-30 02:26:41 -04:00
Henrik Lissner
ad26fcdbdd
perf(emacs-lisp): elisp-demos: inhibit local-vars hooks 2024-08-22 22:37:13 -04:00
Henrik Lissner
639fcc6a2e
tweak(emacs-lisp): remove pin truncation
This removes the truncation of `package!` `:pin`s. This was originally
intended to make packages.el files easier to skim, but in hindsight it
didn't really. It served little other purpose but to make it harder for
folks to interact with the :pin string.
2024-03-26 10:30:34 -04:00
Henrik Lissner
a5ff292cbd
fix(emacs-lisp): 'defining as dynamic an already lexical var' error
Fix: #7653
Amend: 3bea4f66a8
2024-02-07 00:30:51 -05:00
Henrik Lissner
4c89262a6b
nit(emacs-lisp): reformat/revise comments 2024-02-04 17:54:30 -05:00
Henrik Lissner
3bea4f66a8
refactor(emacs-lisp): elisp-demos: reorganize Doom demos
- Move Doom core elisp API demos out of docs/examples.org into lisp/demos.org.
- Recognize and search demos.org file in modules for additional
  demos (including $DOOMDIR/demos.org).
- Refactor emacs-lisp module to use new elisp-demos-user-files variable
  instead of an advice. This way, elisp-demo's commands (such as
  `elisp-demos-find-demo` and `elisp-demos-add-demo`) will include
  Doom's demos.
2024-02-04 17:54:29 -05:00
Henrik Lissner
ffd2654aa3
fix(emacs-lisp): non-package-mode: only enable in elisp buffers
This prevents +emacs-lisp-non-package-mode from being activated in
non-elisp buffers.

Amend: #7341
Close: #7645
Co-authored-by: PatrickNorton <PatrickNorton@users.noreply.github.com>
2024-02-02 18:50:31 -05:00
Henrik Lissner
ddca307b39
merge: pull request #7341 from jeetelongname/flymake-less-error
feat(emacs-lisp): add reduced-flymake-byte-compile
2024-02-01 18:45:42 -05:00
Liam Hupfer
6666685993 fix(emacs-lisp): add elisp flymake load path advice
We set flycheck-emacs-lisp-load-path to 'inherit, which evaluates
load-path when spawning the Emacs subprocess. flymake relies on a static
variable, hence the advice. elisp-flymake-byte-compile is autoloaded by
elisp-mode, so there is little reason to condition on `:checkers syntax
+flymake`.

Ref: e56e30d8c6/flycheck.el (L8725-L8727)
Ref: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/elisp-mode.el?h=emacs-29.1#n2166
Ref: https://emacs.stackexchange.com/questions/48661/how-do-i-get-flymake-to-recognize-files-in-my-load-path
2024-02-01 18:44:35 -05:00
Jeetaditya Chatterjee
2e67ad18e9
feat(emacs-lisp): no doc warnings with flymake 2023-09-15 12:13:48 +01:00
Ian Kerins
5efec260ef fix(format): use correct lisp format function
`apheleia--indent-lisp-buffer` does not exist.

Ref: #6369
2023-09-14 03:31:56 +02:00
Ellis Kenyő
cd79edf134
feat(format): add :lang emacs-lisp formatter
Introduce a formatter function for emacs-lisp (tracked upstream here
[1]) that tries to preserve as much of what the user wants as possible

[1]: https://github.com/radian-software/apheleia/pull/102
2023-09-13 20:20:58 +01:00
Henrik Lissner
f427c8a30e
tweak: scroll-conservatively = 10
Forces the window to recenter if the cursor moves >=10 lines off-screen.
This makes some of our manual recentering elsewhere unnecessary.
2023-09-11 23:53:36 +02:00
Jeetaditya Chatterjee
4696f0d4ce
tweak(syntax): feat gate flycheck in all modules 2023-07-25 00:11:09 +01:00
Henrik Lissner
d39ec50bb7
fix(emacs-lisp): backport mode-name from 28+
In Emacs 28+, the mode-name in emacs-lisp-mode is "ELisp/X" (where X = d
or l depending on lexical-binding). I find this much more useful than
"Emacs-Lisp" in <=27.x or our static replacement "Elisp".
2022-10-29 01:57:43 +02:00
Henrik Lissner
a0ccb6b95b
feat(emacs-lisp,lispy): recognize ;;* outline headings
Permit `;;* ...` be recognized by imenu and outline-minor-mode (and
outline's commands). This also patches Lispy to reflect this new
configuration (if :lang emacs-lisp is active).

Close: #6732
Co-authored-by: LemonBreezes <LemonBreezes@users.noreply.github.com>
2022-10-29 01:57:43 +02:00
Henrik Lissner
36d3a62f6e
fix(emacs-lisp): defconst->defvar for +emacs-lisp-linter-warnings
This wasn't supposed to be a constant, and there's no reason it should
be one.

Amend: afa154db27
2022-09-16 02:06:43 +02:00
Henrik Lissner
20ab9154c2
refactor(emacs-lisp): sharp-quote function symbols 2022-09-16 01:14:24 +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
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
Henrik Lissner
a5c80fcb4b
refactor: deprecate doom-private-dir for doom-user-dir
- Deprecates the doom-private-dir variable in favor of doom-user-dir.
- Renames the pseudo category for the user's module: :private -> :user.
- Renames the doom-private-error error type to doom-user-error.

Emacs uses the term "user" to refer to the "things" in user space (e.g.
user-init-file, user-emacs-directory, user-mail-address, xdg-user-dirs,
package-user-dir, etc), and I'd like to be consistent with that. It also
has the nice side-effect of being slightly shorter. I also hope
'doom-user-error' will be less obtuse to beginners than
'doom-private-error'.
2022-08-14 20:43:35 +02:00
Henrik Lissner
ad6a3d0f33
refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00
Henrik Lissner
170dadca5a
feat(emacs-lisp): register doomscript as elisp interpreter 2022-06-21 23:42:16 +02:00
Daanturo
f63aad2ff6 tweak(emacs-lisp): local leader for lisp-interaction-mode 2022-02-23 17:47:39 +01:00
Henrik Lissner
704957437c revert: Ignore unsafe local variables, but log them
This behavior was too non-standard and invited more confusion than it
helped.

Ref #4070
Revert 5e7864838a
2021-10-06 01:30:45 +02:00
Henrik Lissner
06392a723f refactor: rename orig-fn arg in advice to fn
A minor tweak to our naming conventions for the first argument of an
:around advice.
2021-08-04 01:53:12 -04:00
Henrik Lissner
54a556c2fa lang/emacs-lisp: add flycheck-package 2021-07-25 16:37:28 -04:00
Henrik Lissner
243cb43fec Fix #5187: syntax highlighting in ielm REPL 2021-07-10 16:32:53 -04:00
Wetlize
0a2ed4d346
lang/emacs-lisp: Replace sym with var in +emacs-lisp-log-unsafe-local-variables-a
Otherwise it will make Emacs to error with (void-variable sym) error when
checking the variable.
2021-05-06 13:04:15 +03:00
Henrik Lissner
b63441387b lang/emacs-lisp: don't use risky-local-variable-p
It's hardcoded to return t for symbols that end in any of '-command',
'-frame-alist', '-function', '-functions', '-hook', '-hooks', '-form',
'-forms', '-map', '-map-alist', '-mode-alist', '-program', or
'-predicate' -- which I think is excessive next to a safety check.

I'll trust that: if the user marks X as safe, and it isn't *explicitly*
marked risky, and it destroys the universe, then it's their fault, not
mine, not Emacs'.
2021-05-06 04:27:33 -04:00
Henrik Lissner
ccf6f0b53d Log unsafe eval forms in file/dir local variables 2021-04-29 13:25:48 -04:00
Henrik Lissner
5e7864838a Ignore unsafe local variables, but log them
This suppresses the annoying "do you want to apply these unsafe file/dir
local variables" prompt by ignoring them (but stills them so at least
users are told).

Fixes issue mentioned in #4335
2021-03-21 00:42:49 -04:00
Nikita Bloshchanevich
169d0b2ed5 Emacs lisp: fix variable value display in eldoc
`fboundp' does not check if a variable is bound, but rather a function.
Use `boundp'.
2021-03-06 16:29:07 +01:00
Henrik Lissner
1c8451e509 Move docs/api.org to emacs-lisp module 2021-01-18 17:45:29 -05:00
Nikita Bloshchanevich
b12df73cc1 Emacs-lisp eldoc: fix error if symbol unbound
`+emacs-lisp-append-value-to-eldoc-a' `error's if the symbol isn't
bound, because `symbol-value' errors in that case. Fix that bug by only
modifying the result of `elisp-get-var-docstring' if the symbol is
bound.
2021-01-04 12:08:53 +01:00
Nikita Bloshchanevich
345327ae8b Use max', not min'
`min' puts a lower bound on LIMIT, but we want an upper bound, so `max' must be
used.
2020-11-29 19:55:41 +01:00
Nikita Bloshchanevich
49f4461daa Elisp `eldoc': fix "Invalid format operation %-"
In `+emacs-lisp-append-value-to-eldoc-a', if the `frame-width' of the minibuffer
is smaller than the length of the documentation + " [...]" + 1, a negative
maximum %s bound is passed, causing the error in the title.

Fix this by clamping the computed LIMIT to 0.
2020-11-29 09:37:11 +01:00
Henrik Lissner
7081d833f6
Move :ui pretty-code to :ui ligatures
Includes a major refactor of the module.
2020-08-20 02:14:32 -04:00
Henrik Lissner
b8c20d50fe
Fix unreadable indentation in native elisp files 2020-08-02 18:58:58 -04:00
Andrew Whatson
b9a1563746 Define lookup handlers for lisp-interaction-mode 2020-06-10 00:19:51 +10:00
Henrik Lissner
8bf902d5f4
General refactors & reformatting across the board 2020-06-04 20:13:28 -04:00
Andrew Whatson
595c055953 Add lookup handlers for IELM 2020-05-28 11:53:48 +10:00
Henrik Lissner
ada4110730
Refactor :lang emacs-lisp 2020-05-25 03:43:40 -04:00
Henrik Lissner
a80ae71b05
Append elisp variable's value to eldoc 2020-05-06 21:01:04 -04:00
Henrik Lissner
a634e2c812
Indent elisp plists more sensibly 2020-04-30 15:54:36 -04:00
Henrik Lissner
45cdfb1258
Bump :core
spudlyo/clipetty@7ee3f9c -> spudlyo/clipetty@01b3904
bbatsov/projectile@eec569d -> bbatsov/projectile@5cd261d
noctuid/general.el@14ad4c8 -> noctuid/general.el@42e3803

We're also transitioning from abbreviated SHA1 hashes to full ones,
because underlying git machinery in future updates of straight will
require it (e.g. to obtain shallow clones of pinned packages).
2020-04-29 23:48:21 -04:00
Henrik Lissner
b78fc4eb76
Minor refactor & reformatting across the board 2020-04-08 15:30:10 -04:00