[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode bb9330f 132/468: Fix string contents indentation
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode bb9330f 132/468: Fix string contents indentation (issue #6) |
Date: |
Thu, 5 Aug 2021 04:58:22 -0400 (EDT) |
branch: elpa/lua-mode
commit bb9330f81af5e18d1d2b32794e7c4812989c1761
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Fix string contents indentation (issue #6)
---
lua-mode.el | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index de9d4bd..57ccd20 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -450,19 +450,16 @@ 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)
- (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)))
+ (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.
@@ -666,7 +663,10 @@ previous one even though it looked like an
end-of-statement."
(let ((line-end (line-end-position)))
(save-excursion
(beginning-of-line)
- (re-search-forward lua-cont-bol-regexp line-end t))))
+ ;; if first character of the line is inside string, it's a continuation
+ ;; if strings aren't supposed to be indented,
`lua-calculate-indentation' won't even let
+ ;; the control inside this function
+ (or (lua-comment-or-string-p) (re-search-forward lua-cont-bol-regexp
line-end t)))))
(defun lua-is-continuing-statement-p (&optional parse-start)
"Return non-nil if the line continues a statement.
@@ -860,8 +860,8 @@ In usual case returns an integer: the column to indent to."
;; if bol is inside a string, suppress any indentation
;; or all of the whitespace will go into the literal
- (when (lua-string-p)
- (throw 'indent 0))
+ (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.
- [nongnu] elpa/lua-mode 1d8dc55 214/468: Rename lua--function-name-rx, use it in font-lock keywords init, (continued)
- [nongnu] elpa/lua-mode 1d8dc55 214/468: Rename lua--function-name-rx, use it in font-lock keywords init, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d552910 218/468: Add a test for defun font-locking; add make check target to run it, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4141c85 222/468: Make builtin font-locking more stable; enable it after ".." operator, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1716660 223/468: Fix interaction with electric-pair-mode (issue #54), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4217513 230/468: Remove highlighting of numbers for consistency with other major-modes, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 248bea3 233/468: Remove syntax hacks for '.' & '_' characters, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c5e9620 238/468: Fix stacktrace parsing in inferior process buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f834c21 105/468: lua-mark-all-multiline-literals: fix missed rename, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode aec4eea 117/468: lua-mark/-unmark-all-multiline-literals: fix error occurring on empty buffer (fixes #4 ?), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 535ca1b 128/468: lua-mark-char-multiline-delim, lua-unmark-multiline-literals: inhibit after-change-functions to avoid running automarking twice on the same text, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bb9330f 132/468: Fix string contents indentation (issue #6),
Philip Kaludercic <=
- [nongnu] elpa/lua-mode d57fdaf 134/468: String content indentation: put back code that forbidden ANY indentation unless it's enabled, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8435a96 137/468: Major modifications to indentation logic., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 98f7fb0 145/468: lua-calculate-indentation: remove unneeded variables & "let" form, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 167e046 147/468: lua-calculate-indentation-override: fix typo (caddr was a reference to wrong field of token table), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a0490fc 150/468: lua-font-lock-keywords: highlight hash-bang line as comment (#17), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6563aeb 156/468: Merge pull request #30 from vhallac/fix-22, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9d75878 159/468: lua-font-lock-keywords: highlight numbers as constants (issue #15), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c2f8a7f 175/468: Use define-derived-mode, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9f5107e 181/468: Fix population of lua-mode-syntax-table (issue #42), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f92ced5 283/468: lua-send-region: send extra printline, Philip Kaludercic, 2021/08/05