mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 03:50:24 +10:00
Moving to Doom Emacs!
This commit is contained in:
26
.emacs.d/modules/emacs/electric/autoload.el
Normal file
26
.emacs.d/modules/emacs/electric/autoload.el
Normal file
@@ -0,0 +1,26 @@
|
||||
;;; 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 ()
|
||||
(when (eq major-mode mode)
|
||||
(setq-local electric-indent-inhibit nil)
|
||||
(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))))))
|
||||
18
.emacs.d/modules/emacs/electric/config.el
Normal file
18
.emacs.d/modules/emacs/electric/config.el
Normal file
@@ -0,0 +1,18 @@
|
||||
;;; emacs/electric/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Smarter, keyword-based electric-indent
|
||||
|
||||
(defvar-local +electric-indent-words '()
|
||||
"The list of electric words. Typing these will trigger reindentation of the
|
||||
current line.")
|
||||
|
||||
;;
|
||||
(after! electric
|
||||
(setq-default electric-indent-chars '(?\n ?\^?))
|
||||
|
||||
(add-hook! 'electric-indent-functions
|
||||
(defun +electric-indent-char-fn (_c)
|
||||
(when (and (eolp) +electric-indent-words)
|
||||
(save-excursion
|
||||
(backward-word)
|
||||
(looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))))
|
||||
Reference in New Issue
Block a user