From f24d553c1c07448fee69caf405f7aa155afa883d Mon Sep 17 00:00:00 2001 From: John Turner Date: Tue, 12 Aug 2025 15:38:23 -0400 Subject: 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. --- cil-mode.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)) -- cgit v1.2.3