chiark / gitweb /
el/dot-emacs.el: Indent string literals correctly, e.g., in Lisp mode.
[profile] / el / dot-emacs.el
index f86044d30782f432d3f2a759f3b9754daa0f72ec..4b4be863410d38c992eca13037ecd7549dfefcbf 100644 (file)
@@ -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))))))