diff --git a/core/defuns/macros-editor.el b/core/defuns/macros-editor.el new file mode 100644 index 000000000..0a8406b76 --- /dev/null +++ b/core/defuns/macros-editor.el @@ -0,0 +1,20 @@ +;;; macros-editor.el + +;;;###autoload +(defmacro def-electric! (modes &rest rest) + (declare (indent 1)) + (let ((modes (if (listp modes) modes (list modes))) + (chars (plist-get rest :chars)) + (words (plist-get rest :words))) + (when (or chars words) + (let ((fn-name (intern (format "narf--electric-%s" + (s-join "-" (mapcar 'symbol-name modes)))))) + `(progn + (defun ,fn-name () + (electric-indent-local-mode +1) + ,(if chars `(setq electric-indent-chars ',chars)) + ,(if words `(setq narf-electric-indent-words ',words))) + (add-hook! ,modes ',fn-name)))))) + +(provide 'macros-editor) +;;; macros-editor.el ends here