From: Mark Wooding Date: Sun, 26 Jul 2020 21:46:17 +0000 (+0100) Subject: el/dot-emacs.el: Indent string literals correctly, e.g., in Lisp mode. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/1de7dc662545c5c46f8cba0db90061a6a67ad751?ds=inline el/dot-emacs.el: Indent string literals correctly, e.g., in Lisp mode. I had formed the impression that my indentation machinery worked correctly on Common Lisp docstrings, but this turns out to be completely wrong. Of course, my life would be better if it did work, and now it does. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index f86044d..4b4be86 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -1337,13 +1337,20 @@ (defun mdw-fill-paragraph () (let ((fill-prefix (mdw-choose-dynamic-fill-prefix))) (fill-paragraph nil))) +(defun mdw-point-within-string-p () + "Return non-nil if point is within a string." + (let ((state (syntax-ppss))) + (elt state 3))) + (defun mdw-standard-fill-prefix (rx &optional mat) "Set the dynamic fill prefix, handling standard hanging indents and stuff. This is just a short-cut for setting the thing by hand, and by design it doesn't cope with anything approximating a complicated case." (setq mdw-fill-prefix - `((,(concat rx mdw-hanging-indents) + `(((if (mdw-point-within-string-p) + ,(concat "\\(\\s-*\\)" mdw-hanging-indents) + ,(concat rx mdw-hanging-indents)) (match . 1) (pad . ,(or mat 2))))))