aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-03-16 12:02:08 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-03-16 19:05:08 -0700
commit3df852af414d6972c1fae2bbe5785acd55ea28b6 (patch)
tree7ee9591b60d21b1694ed4c3690925b8deb26f10e
parent2a880a1419674091190a7814ff25dc6f57014876 (diff)
downloadconsfigurator-3df852af414d6972c1fae2bbe5785acd55ea28b6.tar.gz
consfigurator.el.in: fix indentation after leading #~m//, #~s///
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--emacs/consfigurator.el.in18
1 files changed, 17 insertions, 1 deletions
diff --git a/emacs/consfigurator.el.in b/emacs/consfigurator.el.in
index ed08766..bc2a5fd 100644
--- a/emacs/consfigurator.el.in
+++ b/emacs/consfigurator.el.in
@@ -179,13 +179,29 @@ Modes that use this should add `syntax-propertize-multiline' to
(consfigurator--finish-propertize-qq-heredoc end)))))))
(point) end))))
+(defun consfigurator--lisp-indent-function (indent-point state)
+ ;; Don't indent to below trailing modifiers like the 'g' in '#~/foo/g'.
+ (or (save-excursion
+ (goto-char (1+ (nth 1 state)))
+ (and (looking-at "#[[:digit:]]*!?~") (current-column)))
+ (common-lisp-indent-function indent-point state)))
+
+;; `slime-lisp-mode-hook' runs the hooks for `slime-mode' and only then sets
+;; `lisp-indent-function', so I can't see a cleaner way to override it.
+(defun consfigurator--slime-lisp-mode-hook ()
+ (when (derived-mode-p 'consfigurator-lisp-mode)
+ (setq-local lisp-indent-function #'consfigurator--lisp-indent-function)))
+(advice-add 'slime-lisp-mode-hook
+ :after #'consfigurator--slime-lisp-mode-hook)
+
;;;###autoload
(define-derived-mode consfigurator-lisp-mode lisp-mode "Lisp"
"Derivative of `lisp-mode' for files using Consfigurator's readtable."
(add-hook 'syntax-propertize-extend-region-functions
#'syntax-propertize-multiline t t)
(setq-local syntax-propertize-function
- #'consfigurator-syntax-propertize-function)
+ #'consfigurator-syntax-propertize-function
+ lisp-indent-function #'consfigurator--lisp-indent-function)
(when consfigurator-auto-activate-indentation-hints
(activate-consfigurator-indentation-hints)))