From 52a4f5ab818402f53bf152830151fccb62cc359d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 21 Oct 2021 03:12:36 +0200 Subject: Emacs: Add set-keys-and-load macro --- .emacs.d/init.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 6ce29bf..82d9bcb 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -15,6 +15,18 @@ into exps finally return `(progn ,@exps))) +(defmacro set-keys-and-load (file &rest keys) + "Call `autoload' and `global-set-key' at once." + (declare (indent defun)) + (cl-loop for (key fun) on keys by #'cddr + collect `(progn + (autoload #',fun ,(if (stringp file) file (symbol-name file)) nil t) + (global-set-key + ,(if (stringp key) `(kbd ,key) key) + ,(if (listp fun) fun `#',fun))) + into exps + finally return `(progn ,@exps))) + (defmacro set-keys-in (maps &rest keys) "Set multiple keys in multiple keymaps." (declare (indent defun)) @@ -72,14 +84,13 @@ "Run `async-shell-command', then delete the current window." (interactive) (call-interactively #'async-shell-command) - (delete-window)) ; TODO: Function for opening X program with - ; associated command output buffer. + (delete-window)) (defun customize-setq () "Customize variable according to `setq' expression at point." (interactive) (let ((sexp (list-at-point))) - (unless (symbol-value)))) + (unless (symbol-value)))) ; TODO (defun kill-buffer-now () "Kill the current buffer immediately." -- cgit v1.2.3