[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 562540e 073/468: Fix lua-calculate-indentation: i
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 562540e 073/468: Fix lua-calculate-indentation: indent to 0 when inside string literal |
Date: |
Thu, 5 Aug 2021 04:58:10 -0400 (EDT) |
branch: elpa/lua-mode
commit 562540e030e8ed2bcfd3e5af08b539dd1d150e32
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
Fix lua-calculate-indentation: indent to 0 when inside string literal
Otherwise, all the whitespace by which the line is to be indented will get
into the literal
---
lua-mode.el | 55 +++++++++++++++++++++++++++++++------------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 2ab926b..fcb7ea2 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -811,30 +811,37 @@ In usual case returns an integer: the column to indent
to."
(let ((pos (point))
shift-amt)
(save-excursion
- (if parse-start (setq pos (goto-char parse-start)))
- (beginning-of-line)
- (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)
- ;; This code here searches backwards for a "block beginning/end"
- ;; It snarfs the indentation of that, plus whatever amount the
- ;; line was shifted left by, because of block end tokens. It
- ;; then adds the indentation modifier of that line to obtain the
- ;; final level of indentation.
- ;; Finally, if this line continues a statement from the
- ;; previous line, add another level of indentation.
- (if (lua-backwards-to-block-begin-or-end)
- ;; now we're at the line with block beginning or end.
- (max (+ (current-indentation)
- (lua-calculate-indentation-block-modifier)
- shift-amt)
- 0)
- ;; Failed to find a block begin/end.
- ;; Just use the previous line's indent.
- (goto-char pos)
- (beginning-of-line)
- (forward-line -1)
- (+ (current-indentation) shift-amt))))))
+ (catch 'indent
+ (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 (lua-string-p)
+ (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)
+ ;; This code here searches backwards for a "block beginning/end"
+ ;; It snarfs the indentation of that, plus whatever amount the
+ ;; line was shifted left by, because of block end tokens. It
+ ;; then adds the indentation modifier of that line to obtain the
+ ;; final level of indentation.
+ ;; Finally, if this line continues a statement from the
+ ;; previous line, add another level of indentation.
+ (if (lua-backwards-to-block-begin-or-end)
+ ;; now we're at the line with block beginning or end.
+ (max (+ (current-indentation)
+ (lua-calculate-indentation-block-modifier)
+ shift-amt)
+ 0)
+ ;; Failed to find a block begin/end.
+ ;; Just use the previous line's indent.
+ (goto-char pos)
+ (beginning-of-line)
+ (forward-line -1)
+ (+ (current-indentation) shift-amt)))))))
(defun lua-beginning-of-proc (&optional arg)
"Move backward to the beginning of a lua proc (or similar).
- [nongnu] elpa/lua-mode 6b48a94 165/468: Second part of the fix for #34, (continued)
- [nongnu] elpa/lua-mode 6b48a94 165/468: Second part of the fix for #34, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7a3a5f6 169/468: Add script to facilitate indentation testing, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7f8e519 178/468: Add backward compatibility aliases for cl-assert & cl-labels functions, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e6a46ee 182/468: Update README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4b407cc 203/468: Print 'Prefix key set to ...' only when setting via interactive function, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 88b0ec3 209/468: Fix indentation for blocks starting on continued lines, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 32b5639 210/468: Fix wrong imenu generic expression, add one more regexp to match 'x = function(...)' definitions, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 57d3e46 212/468: lua-mode.el: bump "Version:" field, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c7c8d0c 179/468: Fix bug with lua-mode-syntax-table initialization, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0b4ae97 184/468: Merge branch 'fix-36' of git://github.com/vhallac/lua-mode, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 562540e 073/468: Fix lua-calculate-indentation: indent to 0 when inside string literal,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 0f6048d 082/468: Implement lua-mark-all-multiline-literals function, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 96eba74 085/468: lua-(comment/string)-p: add optional pos parameter, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode aef55a6 091/468: Update contact info in README; bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8c28ed5 095/468: Add utility funcs lua-inside-multiline-p and lua-get-multiline-start, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 79ff5d0 110/468: lua-postprocess-output-buffer: replace save-excursion/set-buffer with with-current-buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9b929d4 115/468: Reorder operations in release target so that no pushing/sending is done if master differs from remotes/origin/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9c94413 118/468: lua-comment/-string-p funcs: wrap into save-excursion because syntax-ppss alters point position, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e470943 131/468: lua-mode-abbrev-table: mark abbreviations as :system so that they're not counted as user-defined and are not saved automatically (issue #8), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f4ab885 144/468: lua-cont-eol-regexp: add "return" keyword too, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 01d0f38 146/468: Bump thanks section, Philip Kaludercic, 2021/08/05