[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 6563aeb 156/468: Merge pull request #30 from vhal
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 6563aeb 156/468: Merge pull request #30 from vhallac/fix-22 |
Date: |
Thu, 5 Aug 2021 04:58:27 -0400 (EDT) |
branch: elpa/lua-mode
commit 6563aeb2f98b8a7f815e8a7e1b758f76ce470811
Merge: 0407042 ec26ea4
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
Merge pull request #30 from vhallac/fix-22
Fix: Single-line conditionals can confuse indenting (#22)
---
lua-mode.el | 58 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 3b6c6fc..8f37dbd 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -849,31 +849,30 @@ use standalone."
;; end of a block matched
(- lua-indent-level))))))
-(defun lua-cleanup-indentation-info (info)
- "Cleanup the list of indentation information.
-There are two tokens that cause list cleanup: remove-matching,
-and replace matching. These tokens are considered cleanup tokens.
-
-When a remove-matching token is found, the next non cleanup token
-is removed from list.
-
-When a replace-matching token is found, the next non-cleanup
-token is removed from the list, and the cdr of the
-replace-matching token is inserted in its place."
- (let (value
- (erase-count 0))
- (dolist (elt info value)
- (cond
- ( (eq 'remove-matching (car elt))
- (setq erase-count (1+ erase-count)))
- ( (eq 'replace-matching (car elt))
- (setq value (cons (cdr elt) value))
- (setq erase-count (1+ erase-count)))
- ( t
- (if (= erase-count 0)
- (setq value (cons elt value))
- (setq erase-count (1- erase-count))))))
- (reverse value)))
+(defun lua-add-indentation-info-pair (pair info)
+ "Add the given indentation info pair to the list of indentation information.
+This function has special case handling for two tokens: remove-matching,
+and replace-matching. These two tokens are cleanup tokens that remove or
+alter the effect of a previously recorded indentation info.
+
+When a remove-matching token is encountered, the last recorded info, i.e.
+the car of the list is removed. This is used to roll-back an indentation of a
+block opening statement when it is closed.
+
+When a replace-matching token is seen, the last recorded info is removed,
+and the cdr of the replace-matching info is added in its place. This is used
+when a middle-of the block (the only case is 'else') is seen on the same line
+the block is opened."
+ (cond
+ ( (eq 'remove-matching (car pair))
+ ; Remove head of list
+ (cdr info))
+ ( (eq 'replace-matching (car pair))
+ ; remove head of list, and add the cdr of pair instead
+ (cons (cdr pair) (cdr info)))
+ ( t
+ ; Just add the pair
+ (cons pair info))))
(defun lua-calculate-indentation-info (&optional parse-start parse-end)
"For each block token on the line, computes how it affects the indentation.
@@ -901,10 +900,11 @@ and relative each, and the shift/column to indent to."
(found-end (match-end 0))
(data (match-data)))
(setq indentation-info
- (cons (lua-make-indentation-info-pair found-token found-pos)
indentation-info))))
-
- (or (and indentation-info (lua-cleanup-indentation-info
indentation-info))
- (list (cons 'absolute start-indentation)))))))
+ (lua-add-indentation-info-pair
+ (lua-make-indentation-info-pair found-token found-pos)
+ indentation-info))))
+ (or indentation-info
+ (list (cons 'absolute start-indentation)))))))
(defun lua-accumulate-indentation-info (info)
"Accumulates the indentation information previously calculated by
- [nongnu] elpa/lua-mode c5e9620 238/468: Fix stacktrace parsing in inferior process buffer, (continued)
- [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, 2021/08/05
- [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 <=
- [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
- [nongnu] elpa/lua-mode 68cd23d 292/468: Merge pull request #85 from immerrr/beginning-of-proc-regex, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 532701b 298/468: Add missing Lua 5.3 functions and modules, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 445bad6 301/468: Merge pull request #92 from ramnes/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7f8fbf2 308/468: lua-mode: don't remove syntax-table during unfontification, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b4943f6 313/468: Add luadoc keyword fontification (issue #71), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode debba6c 317/468: Use electric-indent-mode for per-char electric indentation, Philip Kaludercic, 2021/08/05