2017-02-20 20:42:37 -05:00
|
|
|
;;; tools/electric-indent/config.el
|
|
|
|
|
|
|
|
;; Smarter, keyword-based electric-indent
|
|
|
|
|
|
|
|
(defvar doom-electric-indent-p nil
|
|
|
|
"TODO")
|
|
|
|
|
|
|
|
(defvar-local doom-electric-indent-words '()
|
|
|
|
"TODO")
|
|
|
|
|
|
|
|
(setq electric-indent-chars '(?\n ?\^?))
|
|
|
|
|
|
|
|
(push (lambda (c)
|
|
|
|
(when (and (eolp) doom-electric-indent-words)
|
|
|
|
(save-excursion
|
|
|
|
(backward-word)
|
|
|
|
(looking-at-p
|
|
|
|
(concat "\\<" (regexp-opt doom-electric-indent-words))))))
|
|
|
|
electric-indent-functions)
|
|
|
|
|
|
|
|
(@def-setting :electric (modes &rest plist)
|
|
|
|
"Declare :words (list of strings) or :chars (lists of chars) in MODES that
|
|
|
|
trigger electric indentation."
|
|
|
|
(declare (indent 1))
|
|
|
|
(let ((modes (if (listp modes) modes (list modes)))
|
2017-02-20 20:55:21 -05:00
|
|
|
(chars (plist-get plist :chars))
|
|
|
|
(words (plist-get plist :words)))
|
2017-02-20 20:42:37 -05:00
|
|
|
(when (or chars words)
|
|
|
|
(let ((fn-name (intern (format "doom--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 doom-electric-indent-words ',words)))
|
|
|
|
(@add-hook ,modes ',fn-name))))))
|
|
|
|
|