emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/lua-mode d57fdaf 134/468: String content indentation: put


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode d57fdaf 134/468: String content indentation: put back code that forbidden ANY indentation unless it's enabled
Date: Thu, 5 Aug 2021 04:58:22 -0400 (EDT)

branch: elpa/lua-mode
commit d57fdafd5e638ba0db568093a74dd5cb8407c67d
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>

    String content indentation: put back code that forbidden ANY indentation 
unless it's enabled
---
 lua-mode.el | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index 999845d..4a6d98c 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -450,16 +450,19 @@ Return the amount the indentation changed by."
         ;; save point as a distance to eob - it's invariant w.r.t indentation
         (pos (- (point-max) (point))))
     (back-to-indentation)
-    (setq indent (max 0 (- (lua-calculate-indentation nil)
-                           (lua-calculate-unindentation))))
-    (when (not (equal indent (current-column)))
-      (delete-region (line-beginning-position) (point))
-      (indent-to indent))
-    ;; If initial point was within line's indentation,
-    ;; position after the indentation.  Else stay at same point in text.
-    (if (> (- (point-max) pos) (point))
-        (goto-char (- (point-max) pos)))
-    indent))
+    (if (and (not lua-indent-string-contents) (lua-string-p))
+        (goto-char (- (point-max) pos)) ;; just restore point position
+
+      (setq indent (max 0 (- (lua-calculate-indentation nil)
+                             (lua-calculate-unindentation))))
+      (when (not (equal indent (current-column)))
+        (delete-region (line-beginning-position) (point))
+        (indent-to indent))
+      ;; If initial point was within line's indentation,
+      ;; position after the indentation.  Else stay at same point in text.
+      (if (> (- (point-max) pos) (point))
+          (goto-char (- (point-max) pos)))
+      indent)))
 
 (defun lua-find-regexp (direction regexp &optional limit ignore-p)
   "Searches for a regular expression in the direction specified.
@@ -858,11 +861,6 @@ In usual case returns an integer: the column to indent to."
         (if parse-start (setq pos (goto-char parse-start)))
         (beginning-of-line)
 
-        ;; if bol is inside a string, suppress any indentation
-        ;; or all of the whitespace will go into the literal
-        (when (and (lua-string-p) (not lua-indent-string-contents)
-          (throw 'indent 0)))
-
         (setq shift-amt (if (lua-is-continuing-statement-p) lua-indent-level 
0))
         (if (bobp)          ; If we're at the beginning of the buffer, no 
change.
             (+ (current-indentation) shift-amt)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]