2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/emacs-lisp/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-08-30 20:41:54 +02:00
|
|
|
(defvar +emacs-lisp-enable-extra-fontification t
|
|
|
|
"If non-nil, highlight special forms, and defined functions and variables.")
|
|
|
|
|
2022-10-28 02:44:27 +02:00
|
|
|
(defvar +emacs-lisp-outline-regexp "[ \t]*;;;\\(;*\\**\\) [^ \t\n]"
|
2019-03-07 23:12:38 -05:00
|
|
|
"Regexp to use for `outline-regexp' in `emacs-lisp-mode'.
|
|
|
|
This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
|
|
|
|
2022-09-16 02:05:51 +02:00
|
|
|
(defvar +emacs-lisp-linter-warnings
|
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: c05e61536ed9
2022-09-10 15:33:10 +02:00
|
|
|
'(not free-vars ; don't complain about unknown variables
|
|
|
|
noruntime ; don't complain about unknown function calls
|
|
|
|
unresolved) ; don't complain about undefined functions
|
|
|
|
"The value for `byte-compile-warnings' in non-packages.
|
2020-06-04 20:02:46 -04:00
|
|
|
|
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: c05e61536ed9
2022-09-10 15:33:10 +02:00
|
|
|
This reduces the verbosity of flycheck in Emacs configs and scripts, which are
|
|
|
|
so stateful that the deluge of false positives (from the byte-compiler,
|
|
|
|
package-lint, and checkdoc) can be more overwhelming than helpful.
|
|
|
|
|
|
|
|
See `+emacs-lisp-non-package-mode' for details.")
|
2020-06-04 20:02:46 -04:00
|
|
|
|
2019-03-07 23:12:38 -05:00
|
|
|
|
2018-07-29 17:58:15 +02:00
|
|
|
;; `elisp-mode' is loaded at startup. In order to lazy load its config we need
|
|
|
|
;; to pretend it isn't loaded
|
2018-12-05 19:01:17 -05:00
|
|
|
(defer-feature! elisp-mode emacs-lisp-mode)
|
2017-02-03 19:22:59 -05:00
|
|
|
|
2017-02-09 04:23:25 -05:00
|
|
|
|
2018-06-27 22:52:46 +02:00
|
|
|
;;
|
2019-05-01 19:12:52 -04:00
|
|
|
;;; Config
|
2018-06-27 22:52:46 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! elisp-mode
|
2019-02-24 13:58:56 -05:00
|
|
|
:mode ("\\.Cask\\'" . emacs-lisp-mode)
|
2022-06-21 23:41:59 +02:00
|
|
|
:interpreter ("doomscript" . emacs-lisp-mode)
|
2019-02-24 13:58:56 -05:00
|
|
|
:config
|
2024-09-14 17:15:13 -04:00
|
|
|
(let ((modes '(emacs-lisp-mode lisp-interaction-mode lisp-data-mode)))
|
|
|
|
(set-repl-handler! modes #'+emacs-lisp/open-repl)
|
|
|
|
(set-eval-handler! modes #'+emacs-lisp-eval)
|
|
|
|
(set-lookup-handlers! `(,@modes helpful-mode)
|
|
|
|
:definition #'+emacs-lisp-lookup-definition
|
|
|
|
:documentation #'+emacs-lisp-lookup-documentation)
|
|
|
|
(set-docsets! modes "Emacs Lisp")
|
|
|
|
(set-ligatures! modes :lambda "lambda")
|
|
|
|
(set-formatter! 'lisp-indent #'apheleia-indent-lisp-buffer :modes modes)
|
|
|
|
(set-rotate-patterns! modes
|
|
|
|
:symbols '(("t" "nil")
|
|
|
|
("let" "let*")
|
|
|
|
("when" "unless")
|
|
|
|
("advice-add" "advice-remove")
|
|
|
|
("defadvice!" "undefadvice!")
|
|
|
|
("add-hook" "remove-hook")
|
|
|
|
("add-hook!" "remove-hook!")
|
|
|
|
("it" "xit")
|
|
|
|
("describe" "xdescribe"))))
|
2018-06-27 22:52:46 +02:00
|
|
|
|
2018-09-20 15:28:03 -04:00
|
|
|
(setq-hook! 'emacs-lisp-mode-hook
|
2020-08-02 18:58:58 -04:00
|
|
|
;; Emacs' built-in elisp files use a hybrid tab->space indentation scheme
|
|
|
|
;; with a tab width of 8. Any smaller and the indentation will be
|
|
|
|
;; unreadable. Since Emacs' lisp indenter doesn't respect this variable it's
|
|
|
|
;; safe to ignore this setting otherwise.
|
|
|
|
tab-width 8
|
2018-09-20 15:28:03 -04:00
|
|
|
;; Don't treat autoloads or sexp openers as outline headers, we have
|
|
|
|
;; hideshow for that.
|
2022-10-28 02:44:27 +02:00
|
|
|
outline-regexp +emacs-lisp-outline-regexp
|
|
|
|
outline-level #'+emacs-lisp-outline-level)
|
2022-09-12 16:14:11 +02:00
|
|
|
|
2022-10-28 02:47:02 +02:00
|
|
|
;; DEPRECATED: Remove when 27.x support is dropped.
|
|
|
|
(when (< emacs-major-version 28)
|
|
|
|
;; As of Emacs 28+, `emacs-lisp-mode' uses a shorter label in the mode-line
|
|
|
|
;; ("ELisp/X", where X = l or d, depending on `lexical-binding'). In <=27,
|
|
|
|
;; it uses "Emacs-Lisp". The former is more useful, so I backport it:
|
|
|
|
(setq-hook! 'emacs-lisp-mode-hook
|
|
|
|
mode-name `("ELisp"
|
|
|
|
(lexical-binding (:propertize "/l"
|
|
|
|
help-echo "Using lexical-binding mode")
|
|
|
|
(:propertize "/d"
|
|
|
|
help-echo "Using old dynamic scoping mode"
|
|
|
|
face warning
|
|
|
|
mouse-face mode-line-highlight)))))
|
|
|
|
|
2024-02-03 17:05:52 -05:00
|
|
|
;; Introduces logic to improve plist indentation in emacs-lisp-mode.
|
2022-09-12 16:14:11 +02:00
|
|
|
(advice-add #'calculate-lisp-indent :override #'+emacs-lisp--calculate-lisp-indent-a)
|
2018-09-18 11:48:16 -04:00
|
|
|
|
2024-02-03 17:05:52 -05:00
|
|
|
;; Variable-width indentation is superior in elisp. Otherwise, `dtrt-indent'
|
2020-05-25 02:29:30 -04:00
|
|
|
;; and `editorconfig' would force fixed indentation on elisp.
|
|
|
|
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode)
|
2018-07-29 02:54:19 +02:00
|
|
|
|
2024-09-14 17:15:13 -04:00
|
|
|
(add-hook! '(emacs-lisp-mode-hook lisp-data-mode-local-vars-hook)
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Allow folding of outlines in comments
|
2019-07-26 19:57:13 +02:00
|
|
|
#'outline-minor-mode
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Make parenthesis depth easier to distinguish at a glance
|
2019-07-26 19:57:13 +02:00
|
|
|
#'rainbow-delimiters-mode
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Make quoted symbols easier to distinguish from free variables
|
2019-07-26 19:57:13 +02:00
|
|
|
#'highlight-quoted-mode
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Extend imenu support to Doom constructs
|
|
|
|
#'+emacs-lisp-extend-imenu-h
|
|
|
|
;; Ensure straight sees modifications to installed packages
|
|
|
|
#'+emacs-lisp-init-straight-maybe-h)
|
2020-01-06 22:49:54 -05:00
|
|
|
|
2024-02-02 18:47:15 -05:00
|
|
|
;; UX: Both Flycheck's and Flymake's two emacs-lisp checkers produce a *lot*
|
2024-02-03 17:05:52 -05:00
|
|
|
;; of false positives in non-packages (like Emacs configs or elisp scripts),
|
|
|
|
;; so I disable `checkdoc' (`emacs-lisp-checkdoc', `elisp-flymake-checkdoc')
|
|
|
|
;; and set `byte-compile-warnings' to a subset that makes more sense (see
|
|
|
|
;; `+emacs-lisp-linter-warnings')
|
2023-08-05 23:14:43 +05:30
|
|
|
(add-hook! '(flycheck-mode-hook flymake-mode-hook) #'+emacs-lisp-non-package-mode)
|
2018-08-10 19:39:28 +02:00
|
|
|
|
2023-09-09 12:07:27 -05:00
|
|
|
(defadvice! +syntax--fix-elisp-flymake-load-path (orig-fn &rest args)
|
|
|
|
"Set load path for elisp byte compilation Flymake backend"
|
|
|
|
:around #'elisp-flymake-byte-compile
|
|
|
|
(let ((elisp-flymake-byte-compile-load-path
|
|
|
|
(append elisp-flymake-byte-compile-load-path load-path)))
|
|
|
|
(apply orig-fn args)))
|
|
|
|
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Enhance elisp syntax highlighting, by highlighting Doom-specific
|
|
|
|
;; constructs, defined symbols, and truncating :pin's in `package!' calls.
|
2018-07-29 18:24:14 +02:00
|
|
|
(font-lock-add-keywords
|
|
|
|
'emacs-lisp-mode
|
2018-08-10 19:39:28 +02:00
|
|
|
(append `(;; custom Doom cookies
|
2019-03-09 02:42:03 -05:00
|
|
|
("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t)))
|
2018-08-30 20:41:54 +02:00
|
|
|
;; highlight defined, special variables & functions
|
|
|
|
(when +emacs-lisp-enable-extra-fontification
|
2020-05-25 02:29:30 -04:00
|
|
|
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
|
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +emacs-lisp-append-value-to-eldoc-a (fn sym)
|
2020-05-06 21:01:04 -04:00
|
|
|
"Display variable value next to documentation in eldoc."
|
|
|
|
:around #'elisp-get-var-docstring
|
2021-08-04 01:18:06 -04:00
|
|
|
(when-let (ret (funcall fn sym))
|
2021-03-06 16:28:28 +01:00
|
|
|
(if (boundp sym)
|
2021-01-02 12:24:31 +01:00
|
|
|
(concat ret " "
|
|
|
|
(let* ((truncated " [...]")
|
|
|
|
(print-escape-newlines t)
|
|
|
|
(str (symbol-value sym))
|
|
|
|
(str (prin1-to-string str))
|
|
|
|
(limit (- (frame-width) (length ret) (length truncated) 1)))
|
|
|
|
(format (format "%%0.%ds%%s" (max limit 0))
|
|
|
|
(propertize str 'face 'warning)
|
|
|
|
(if (< (length str) limit) "" truncated))))
|
|
|
|
ret)))
|
2020-05-06 21:01:04 -04:00
|
|
|
|
Introduce general.el & rewrite map!
+ Now uses an overriding keymap for leader keys, so that it is always
available, even outside of normal/visual states. In insert/emacs
states, or in sessions where evil is absent, an alternative prefix is
used for leader/localleader keys. See these variables:
+ doom-leader-prefix
+ doom-leader-alt-prefix
+ doom-localleader-prefix
+ doom-localleader-alt-prefix
+ Keybinds now support alternative prefixes through the new :alt-prefix
property. This is useful for non-evil users and non-normal evil
states. By default, this is M-SPC (leader) and M-SPC m (localleader).
+ Removed +evil-commands flag from config/default (moved to
feature/evil/+commands.el).
+ config/default/+bindings.el has been split into
config/default/+{evil,emacs}-bindings.el, which one is loaded depends
on whether evil is present or not. The latter is blank, but will soon
be populated with a keybinding scheme for non-evil users (perhaps
inspired by #641).
+ The define-key! macro has been replaced; it is now an alias for
general-def.
+ Added unmap! as an alias for general-unbind.
+ The following modifier key conventions are now enforced for
consistency, across all OSes:
alt/option = meta
windows/command = super
It used to be
alt/option = alt
windows/command = meta
Many of the default keybinds have been updated to reflect this switch,
but it is likely to affect personal meta/super keybinds!
The map! macro has also been rewritten to use general-define-key. Here
is what has been changed:
+ map! no longer works with characters, e.g. (map! ?x #'do-something) is
no longer supported. Keys must be kbd-able strings like "C-c x" or
vectors like [?C-c ?x].
+ The :map and :map* properties are now the same thing. If specified
keymaps aren't defined when binding keys, it is automatically
deferred.
+ The way you bind local keybinds has changed:
;; Don't do this
(map! :l "a" #'func-a
:l "b" #'func-b)
;; Do this
(map! :map 'local "a" #'func-a
"b" #'func-b)
+ map! now supports the following new blocks:
+ (:if COND THEN-FORM ELSE-FORM...)
+ (:alt-prefix PREFIX KEYS...) -- this prefix will be used for
non-normal evil states. Equivalent to :non-normal-prefix in general.
+ The way you declare a which-key label for a prefix key has changed:
;; before
(map! :desc "label" :prefix "a" ...)
;; now
(map! :prefix ("a" . "label") ...)
+ It used to be that map! supported binding a key to a key sequence,
like so:
(map! "a" [?x]) ; pressing a is like pressing x
This functionality was removed *temporarily* while I figure out the
implementation.
Addresses: #448, #814, #860
Mentioned in: #940
2018-12-22 03:30:04 -05:00
|
|
|
(map! :localleader
|
2022-02-19 22:04:25 +07:00
|
|
|
:map (emacs-lisp-mode-map lisp-interaction-mode-map)
|
2019-10-04 17:49:28 -04:00
|
|
|
:desc "Expand macro" "m" #'macrostep-expand
|
2019-09-19 13:56:38 +09:00
|
|
|
(:prefix ("d" . "debug")
|
2019-10-04 17:49:28 -04:00
|
|
|
"f" #'+emacs-lisp/edebug-instrument-defun-on
|
|
|
|
"F" #'+emacs-lisp/edebug-instrument-defun-off)
|
|
|
|
(:prefix ("e" . "eval")
|
|
|
|
"b" #'eval-buffer
|
|
|
|
"d" #'eval-defun
|
|
|
|
"e" #'eval-last-sexp
|
2019-10-25 04:27:40 -04:00
|
|
|
"r" #'eval-region
|
|
|
|
"l" #'load-library)
|
2019-10-04 17:49:28 -04:00
|
|
|
(:prefix ("g" . "goto")
|
|
|
|
"f" #'find-function
|
2019-10-25 04:27:40 -04:00
|
|
|
"v" #'find-variable
|
|
|
|
"l" #'find-library)))
|
2017-02-08 02:23:06 -05:00
|
|
|
|
2020-05-28 11:53:15 +10:00
|
|
|
(use-package! ielm
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(set-lookup-handlers! 'inferior-emacs-lisp-mode
|
|
|
|
:definition #'+emacs-lisp-lookup-definition
|
2021-07-10 16:32:11 -04:00
|
|
|
:documentation #'+emacs-lisp-lookup-documentation)
|
|
|
|
|
|
|
|
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/ to add
|
|
|
|
;; syntax highlighting to ielm REPLs.
|
|
|
|
(setq ielm-font-lock-keywords
|
|
|
|
(append '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)"
|
|
|
|
(1 font-lock-comment-face)
|
|
|
|
(2 font-lock-constant-face)))
|
|
|
|
(when (require 'highlight-numbers nil t)
|
|
|
|
(highlight-numbers--get-regexp-for-mode 'emacs-lisp-mode))
|
|
|
|
(cl-loop for (matcher . match-highlights)
|
|
|
|
in (append lisp-el-font-lock-keywords-2
|
|
|
|
lisp-cl-font-lock-keywords-2)
|
|
|
|
collect
|
|
|
|
`((lambda (limit)
|
|
|
|
(when ,(if (symbolp matcher)
|
|
|
|
`(,matcher limit)
|
|
|
|
`(re-search-forward ,matcher limit t))
|
|
|
|
;; Only highlight matches after the prompt
|
|
|
|
(> (match-beginning 0) (car comint-last-prompt))
|
|
|
|
;; Make sure we're not in a comment or string
|
|
|
|
(let ((state (syntax-ppss)))
|
|
|
|
(not (or (nth 3 state)
|
|
|
|
(nth 4 state))))))
|
|
|
|
,@match-highlights)))))
|
2019-10-17 01:53:14 -04:00
|
|
|
|
|
|
|
|
2017-02-03 19:22:59 -05:00
|
|
|
;;
|
2019-05-01 19:12:52 -04:00
|
|
|
;;; Packages
|
2017-02-03 19:22:59 -05:00
|
|
|
|
2019-05-01 19:12:52 -04:00
|
|
|
;;;###package overseer
|
2018-08-21 00:04:48 +02:00
|
|
|
(autoload 'overseer-test "overseer" nil t)
|
2020-05-25 02:29:30 -04:00
|
|
|
;; Properly lazy load overseer by not loading it so early:
|
2020-04-08 15:29:29 -04:00
|
|
|
(remove-hook 'emacs-lisp-mode-hook #'overseer-enable-mode)
|
2018-08-21 00:04:48 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! flycheck-cask
|
2022-08-17 01:16:08 +01:00
|
|
|
:when (and (modulep! :checkers syntax)
|
|
|
|
(not (modulep! :checkers syntax +flymake)))
|
2018-05-25 00:46:11 +02:00
|
|
|
:defer t
|
2017-07-17 11:33:47 +02:00
|
|
|
:init
|
2018-02-19 14:37:32 -05:00
|
|
|
(add-hook! 'emacs-lisp-mode-hook
|
2017-07-17 11:33:47 +02:00
|
|
|
(add-hook 'flycheck-mode-hook #'flycheck-cask-setup nil t)))
|
|
|
|
|
|
|
|
|
2021-07-25 16:37:28 -04:00
|
|
|
(use-package! flycheck-package
|
2022-08-17 01:16:08 +01:00
|
|
|
:when (and (modulep! :checkers syntax)
|
|
|
|
(not (modulep! :checkers syntax +flymake)))
|
2021-07-25 16:37:28 -04:00
|
|
|
:after flycheck
|
|
|
|
:config (flycheck-package-setup))
|
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! elisp-demos
|
2019-03-12 11:31:25 -04:00
|
|
|
:defer t
|
2019-03-11 00:16:57 +10:00
|
|
|
:init
|
2022-09-15 23:29:19 +02:00
|
|
|
(advice-add #'describe-function-1 :after #'elisp-demos-advice-describe-function-1)
|
|
|
|
(advice-add #'helpful-update :after #'elisp-demos-advice-helpful-update)
|
2019-07-21 14:53:19 +02:00
|
|
|
:config
|
2024-02-03 17:01:37 -05:00
|
|
|
;; Add Doom's core and module demo files, so additional demos can be specified
|
|
|
|
;; by end-users (in $DOOMDIR/demos.org), by modules (modules/X/Y/demos.org),
|
|
|
|
;; or Doom's core (lisp/demos.org).
|
|
|
|
(dolist (file (doom-module-locate-paths (doom-module-list) "demos.org"))
|
|
|
|
(add-to-list 'elisp-demos-user-files file))
|
|
|
|
|
|
|
|
;; HACK: These functions open Org files non-interactively without any
|
|
|
|
;; performance optimizations. Given how prone org-mode is to being tied to
|
|
|
|
;; expensive functionality, this will often introduce unexpected freezes
|
|
|
|
;; without this advice.
|
|
|
|
;; TODO: PR upstream?
|
2024-02-07 00:01:34 -05:00
|
|
|
(defvar org-inhibit-startup)
|
|
|
|
(defvar org-mode-hook)
|
2024-02-03 17:01:37 -05:00
|
|
|
(defadvice! +emacs-lisp--optimize-org-init-a (fn &rest args)
|
|
|
|
"Disable unrelated functionality to optimize calls to `org-mode'."
|
|
|
|
:around #'elisp-demos--export-json-file
|
|
|
|
:around #'elisp-demos--symbols
|
|
|
|
:around #'elisp-demos--syntax-highlight
|
|
|
|
(let ((org-inhibit-startup t)
|
2024-08-22 22:30:46 -04:00
|
|
|
(doom-inhibit-local-var-hooks t)
|
2024-02-03 17:01:37 -05:00
|
|
|
enable-dir-local-variables
|
|
|
|
org-mode-hook)
|
|
|
|
(apply fn args))))
|
2019-03-11 00:16:57 +10:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! buttercup
|
2019-07-21 14:49:09 +02:00
|
|
|
:defer t
|
|
|
|
:minor ("/test[/-].+\\.el$" . buttercup-minor-mode)
|
2019-07-25 12:56:34 +02:00
|
|
|
:preface
|
|
|
|
;; buttercup.el doesn't define a keymap for `buttercup-minor-mode', as we have
|
|
|
|
;; to fool its internal `define-minor-mode' call into thinking one exists, so
|
|
|
|
;; it will associate it with the mode.
|
|
|
|
(defvar buttercup-minor-mode-map (make-sparse-keymap))
|
|
|
|
:config
|
2019-07-26 13:59:52 +02:00
|
|
|
(set-popup-rule! "^\\*Buttercup\\*$" :size 0.45 :select nil :ttl 0)
|
2019-07-25 12:56:34 +02:00
|
|
|
(set-yas-minor-mode! 'buttercup-minor-mode)
|
|
|
|
(when (featurep 'evil)
|
|
|
|
(add-hook 'buttercup-minor-mode-hook #'evil-normalize-keymaps))
|
2019-12-22 23:02:54 -05:00
|
|
|
(map! :localleader
|
|
|
|
:map buttercup-minor-mode-map
|
2019-07-25 12:56:34 +02:00
|
|
|
:prefix "t"
|
|
|
|
"t" #'+emacs-lisp/buttercup-run-file
|
2019-07-27 11:33:41 +02:00
|
|
|
"a" #'+emacs-lisp/buttercup-run-project
|
2019-07-25 12:56:34 +02:00
|
|
|
"s" #'buttercup-run-at-point))
|
2019-07-21 14:49:09 +02:00
|
|
|
|
|
|
|
|
2024-08-30 01:56:03 -04:00
|
|
|
(use-package! helpful
|
|
|
|
;; a better *help* buffer
|
|
|
|
:commands helpful--read-symbol
|
|
|
|
:hook (helpful-mode . visual-line-mode)
|
|
|
|
:init
|
|
|
|
;; Make `apropos' et co search more extensively. They're more useful this way.
|
|
|
|
(setq apropos-do-all t)
|
|
|
|
|
|
|
|
(global-set-key [remap describe-function] #'helpful-callable)
|
|
|
|
(global-set-key [remap describe-command] #'helpful-command)
|
|
|
|
(global-set-key [remap describe-variable] #'helpful-variable)
|
|
|
|
(global-set-key [remap describe-key] #'helpful-key)
|
2024-09-14 02:01:50 -04:00
|
|
|
;; (global-set-key [remap describe-symbol] #'helpful-symbol)
|
2024-08-30 01:56:03 -04:00
|
|
|
|
|
|
|
(defun doom-use-helpful-a (fn &rest args)
|
|
|
|
"Force FN to use helpful instead of the old describe-* commands."
|
|
|
|
(letf! ((#'describe-function #'helpful-function)
|
|
|
|
(#'describe-variable #'helpful-variable))
|
|
|
|
(apply fn args)))
|
|
|
|
|
|
|
|
(after! apropos
|
|
|
|
;; patch apropos buttons to call helpful instead of help
|
|
|
|
(dolist (fun-bt '(apropos-function apropos-macro apropos-command))
|
|
|
|
(button-type-put
|
|
|
|
fun-bt 'action
|
|
|
|
(lambda (button)
|
|
|
|
(helpful-callable (button-get button 'apropos-symbol)))))
|
|
|
|
(dolist (var-bt '(apropos-variable apropos-user-option))
|
|
|
|
(button-type-put
|
|
|
|
var-bt 'action
|
|
|
|
(lambda (button)
|
|
|
|
(helpful-variable (button-get button 'apropos-symbol))))))
|
|
|
|
|
|
|
|
;; DEPRECATED: Remove when support for 29 is dropped.
|
|
|
|
(when (= emacs-major-version 29)
|
|
|
|
(defadvice! doom--find-function-search-for-symbol-save-excursion-a (fn &rest args)
|
|
|
|
"Suppress cursor movement by `find-function-search-for-symbol'.
|
|
|
|
|
|
|
|
Addresses an unwanted side-effect in `find-function-search-for-symbol' on Emacs
|
|
|
|
29 where the cursor is moved to a variable's definition if it's defined in the
|
|
|
|
current buffer."
|
|
|
|
:around #'find-function-search-for-symbol
|
|
|
|
(let (buf pos)
|
|
|
|
(letf! (defun find-library-name (library)
|
|
|
|
(let ((filename (funcall find-library-name library)))
|
|
|
|
(with-current-buffer (find-file-noselect filename)
|
|
|
|
(setq buf (current-buffer)
|
|
|
|
pos (point)))
|
|
|
|
filename))
|
|
|
|
(prog1 (apply fn args)
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf (goto-char pos))))))))
|
|
|
|
:config
|
|
|
|
(setq helpful-set-variable-function #'setq!)
|
|
|
|
|
|
|
|
(cond ((modulep! :completion ivy)
|
|
|
|
(setq counsel-describe-function-function #'helpful-callable
|
|
|
|
counsel-describe-variable-function #'helpful-variable
|
|
|
|
counsel-descbinds-function #'helpful-callable))
|
|
|
|
((modulep! :completion helm)
|
|
|
|
(dolist (fn '(helm-describe-variable helm-describe-function))
|
|
|
|
(advice-add fn :around #'doom-use-helpful-a))))
|
|
|
|
|
|
|
|
;; Open help:* links with helpful-* instead of describe-*
|
|
|
|
(advice-add #'org-link--open-help :around #'doom-use-helpful-a)
|
|
|
|
|
|
|
|
(map! :map helpful-mode-map
|
|
|
|
:ng "o" #'link-hint-open-link
|
|
|
|
:n "gr" #'helpful-update))
|
|
|
|
|
|
|
|
|
2017-04-04 22:19:48 -04:00
|
|
|
;;
|
2019-05-01 19:12:52 -04:00
|
|
|
;;; Project modes
|
2017-04-04 22:19:48 -04:00
|
|
|
|
|
|
|
(def-project-mode! +emacs-lisp-ert-mode
|
2019-07-21 14:49:09 +02:00
|
|
|
:modes '(emacs-lisp-mode)
|
2019-03-04 19:52:56 -05:00
|
|
|
:match "/test[/-].+\\.el$"
|
2019-07-21 14:49:09 +02:00
|
|
|
:add-hooks '(overseer-enable-mode))
|