summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-08-12 15:38:23 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-08-12 15:38:23 -0400
commitf24d553c1c07448fee69caf405f7aa155afa883d (patch)
treebd7714925949773b0d0028e5aff3e8ea419cae80
parent1bd65af5071873f6d550012da5d43c0508e98aeb (diff)
downloadcil-mode-master.tar.gz
create custom indent functionHEADmaster
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.el9
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))