doomemacs/modules/emacs/electric/autoload.el
Henrik Lissner 51190fa771
More descriptive signature for set-electric!
And mention that electric-indent-local-mode is enabled by this in its
docstring.
2018-10-16 18:30:44 -04:00

31 lines
1.1 KiB
EmacsLisp

;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-
;;;###autodef
(defun set-electric! (modes &rest plist)
"Declare that WORDS (list of strings) or CHARS (lists of chars) should trigger
electric indentation.
Enables `electric-indent-local-mode' in MODES.
\(fn MODES &key WORDS CHARS)"
(declare (indent defun))
(dolist (mode (doom-enlist modes))
(let ((hook (intern (format "%s-hook" mode)))
(fn (intern (format "+electric|init-%s" mode))))
(cond ((null (car-safe plist))
(remove-hook hook fn)
(unintern fn nil))
((fset fn
(lambda ()
(cl-destructuring-bind (&key chars words) plist
(electric-indent-local-mode +1)
(if chars (setq electric-indent-chars chars))
(if words (setq +electric-indent-words words)))))
(add-hook hook fn))))))
;; FIXME obsolete :electric
;;;###autoload
(def-setting! :electric (modes &rest plist)
:obsolete set-electric!
`(set-electric! ,modes ,@plist))