diff options
author | Case Duckworth | 2021-08-14 12:40:52 -0500 |
---|---|---|
committer | Case Duckworth | 2021-08-14 12:40:52 -0500 |
commit | 4b3ebd99a0f0a3ea95e2d60c63d8d6f9273922e0 (patch) | |
tree | 453619319913fdadb9de9d40c015b543972b1dbd | |
parent | Use `unfill' package and delete `kill-ring-save-unfilled' (diff) | |
download | emacs-4b3ebd99a0f0a3ea95e2d60c63d8d6f9273922e0.tar.gz emacs-4b3ebd99a0f0a3ea95e2d60c63d8d6f9273922e0.zip |
Implement `with-eval-after-loads' macro
-rw-r--r-- | init.el | 26 | ||||
-rw-r--r-- | lisp/acdw.el | 16 |
2 files changed, 28 insertions, 14 deletions
diff --git a/init.el b/init.el index 703dc56..4209a6b 100644 --- a/init.el +++ b/init.el | |||
@@ -1009,15 +1009,14 @@ if ripgrep is installed, otherwise `consult-grep'." | |||
1009 | (:advise completing-read-multiple | 1009 | (:advise completing-read-multiple |
1010 | :filter-args #'crm-indicator)) | 1010 | :filter-args #'crm-indicator)) |
1011 | 1011 | ||
1012 | (with-eval-after-load 'vertico | 1012 | (with-eval-after-loads (vertico consult) |
1013 | (with-eval-after-load 'consult | 1013 | (when (boundp 'consult-crm-map) |
1014 | (when (boundp 'consult-crm-map) | 1014 | (define-key consult-crm-map "\r" #'+vertico-crm-exit) |
1015 | (define-key consult-crm-map "\r" #'+vertico-crm-exit) | 1015 | (define-key consult-crm-map "\t" #'vertico-exit) |
1016 | (define-key consult-crm-map "\t" #'vertico-exit) | 1016 | (defun +vertico-crm-exit () |
1017 | (defun +vertico-crm-exit () | 1017 | (interactive) |
1018 | (interactive) | 1018 | (run-at-time 0 nil #'vertico-exit) |
1019 | (run-at-time 0 nil #'vertico-exit) | 1019 | (funcall #'vertico-exit))))) |
1020 | (funcall #'vertico-exit)))))) | ||
1021 | 1020 | ||
1022 | (setup (:straight crux) | 1021 | (setup (:straight crux) |
1023 | 1022 | ||
@@ -1089,11 +1088,10 @@ if ripgrep is installed, otherwise `consult-grep'." | |||
1089 | #'which-key--hide-popup-ignore-command) | 1088 | #'which-key--hide-popup-ignore-command) |
1090 | embark-become-indicator embark-action-indicator) | 1089 | embark-become-indicator embark-action-indicator) |
1091 | 1090 | ||
1092 | (with-eval-after-load 'embark | 1091 | (with-eval-after-loads (embark consult) |
1093 | (with-eval-after-load 'consult | 1092 | (setup (:straight embark-consult) |
1094 | (setup (:straight embark-consult) | 1093 | (add-hook 'embark-collect-mode-hook |
1095 | (add-hook 'embark-collect-mode-hook | 1094 | #'consult-preview-at-point-mode)))) |
1096 | #'consult-preview-at-point-mode))))) | ||
1097 | 1095 | ||
1098 | (setup (:straight epithet) | 1096 | (setup (:straight epithet) |
1099 | (add-hook 'Info-selection-hook #'epithet-rename-buffer) | 1097 | (add-hook 'Info-selection-hook #'epithet-rename-buffer) |
diff --git a/lisp/acdw.el b/lisp/acdw.el index 4c17bcb..2aa6c1f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -108,6 +108,22 @@ is unfocused." | |||
108 | ,@body) | 108 | ,@body) |
109 | (message "%s... Done." ,message))) | 109 | (message "%s... Done." ,message))) |
110 | 110 | ||
111 | (defmacro with-eval-after-loads (files &rest body) | ||
112 | "Execute BODY after FILES are loaded. | ||
113 | This macro simplifies `with-eval-after-load' for multiple nested | ||
114 | features." | ||
115 | (declare (indent 1) (debug (form def-body))) | ||
116 | (waterfall-list 'with-eval-after-load files body)) | ||
117 | |||
118 | (defun waterfall-list (car list rest) | ||
119 | "Cons CAR with each element in LIST in a waterfall fashion, end with REST. | ||
120 | For use with the `with-eval-after-loads' function." | ||
121 | (cond ((atom list) `(,car ',list ,@rest)) | ||
122 | ((= 1 (length list)) `(,car ',(car list) ,@rest)) | ||
123 | (t | ||
124 | `(,car ',(car list) | ||
125 | ,(waterfall-list car (cdr list) rest))))) | ||
126 | |||
111 | 127 | ||
112 | ;;; Comment-or-uncomment-sexp | 128 | ;;; Comment-or-uncomment-sexp |
113 | ;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html | 129 | ;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html |