diff options
author | John Turner <jturner.usa@gmail.com> | 2025-08-12 15:38:23 -0400 |
---|---|---|
committer | John Turner <jturner.usa@gmail.com> | 2025-08-12 15:38:23 -0400 |
commit | f24d553c1c07448fee69caf405f7aa155afa883d (patch) | |
tree | bd7714925949773b0d0028e5aff3e8ea419cae80 | |
parent | 1bd65af5071873f6d550012da5d43c0508e98aeb (diff) | |
download | emacs.d-f24d553c1c07448fee69caf405f7aa155afa883d.tar.gz |
create custom indent function
The custom indent function indents a base value with the result
of (syntax-ppss), which is the current nesting level of the expression
at point.
-rw-r--r-- | cil-mode.el | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cil-mode.el b/cil-mode.el index 74ad689..60c6b50 100644 --- a/cil-mode.el +++ b/cil-mode.el @@ -24,12 +24,19 @@ (put 'block 'lisp-indent-function 4) +(defcustom cil-mode-indent-width 4 + "Amount of spaces to indent expressions with.") + +(defun cil-mode--indent-function (_ _) + (* cil-mode-indent-width (car (syntax-ppss)))) + (defvar cil-mode--font-lock-defaults `((,(rx (group (or "in" "block" "macro")) eow) 0 font-lock-keyword-face))) (define-derived-mode cil-mode lisp-data-mode "cil" - (setq-local font-lock-defaults cil-mode--font-lock-defaults)) + (setq-local font-lock-defaults cil-mode--font-lock-defaults) + (setq-local lisp-indent-function 'cil-mode--indent-function)) (add-to-list 'auto-mode-alist '("\\.cil\\'" . cil-mode)) |