2018-06-15 13:10:00 +02:00
|
|
|
;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-
|
2018-06-15 12:30:56 +02:00
|
|
|
|
|
|
|
;;;###autodef
|
|
|
|
(defun set-electric! (modes &rest plist)
|
|
|
|
"Declare :words (list of strings) or :chars (lists of chars) in MODES that
|
|
|
|
trigger electric indentation."
|
|
|
|
(declare (indent 1))
|
2018-06-15 13:29:25 +02:00
|
|
|
(unless plist
|
|
|
|
(signal 'wrong-number-of-arguments
|
|
|
|
(list '(:char :words) plist)))
|
2018-06-15 16:50:39 +02:00
|
|
|
(cl-destructuring-bind (&key chars words) plist
|
2018-06-15 13:29:25 +02:00
|
|
|
(dolist (mode (doom-enlist modes))
|
|
|
|
(let ((fn (intern (format "+electric-indent--init-%s" mode))))
|
2018-06-15 12:30:56 +02:00
|
|
|
(fset fn
|
2018-06-15 13:29:25 +02:00
|
|
|
(lambda ()
|
|
|
|
(electric-indent-local-mode +1)
|
2018-06-15 12:30:56 +02:00
|
|
|
(if chars (setq electric-indent-chars chars))
|
|
|
|
(if words (setq +electric-indent-words words))))
|
2018-06-15 13:29:25 +02:00
|
|
|
(add-hook (intern (format "%s-hook" mode)) fn)))))
|
2018-06-15 12:30:56 +02:00
|
|
|
|
|
|
|
;; FIXME obsolete :electric
|
|
|
|
;;;###autoload
|
|
|
|
(def-setting! :electric (modes &rest plist)
|
|
|
|
"Declare :words (list of strings) or :chars (lists of chars) in MODES that
|
|
|
|
trigger electric indentation."
|
|
|
|
:obsolete set-electric!
|
|
|
|
`(set-electric! ,modes ,@plist))
|