[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair:
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair: readability refactoring |
Date: |
Thu, 5 Aug 2021 04:58:08 -0400 (EDT) |
branch: elpa/lua-mode
commit e610db461fde985f88405d3f4b61daa4b6c8706d
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
lua-make-indentation-info-pair: readability refactoring
---
lua-mode.el | 83 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 44 insertions(+), 39 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index f4d372a..0e0c9fc 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -619,45 +619,50 @@ The criteria for a continuing statement are:
(defun lua-make-indentation-info-pair ()
"This is a helper function to lua-calculate-indentation-info. Don't
use standalone."
- (cond ((string-equal found-token "function")
- ;; this is the location where we need to start searching for the
- ;; matching opening token, when we encounter the next closing token.
- ;; It is primarily an optimization to save some searching time.
- (cons 'absolute (+ (save-excursion (goto-char found-pos)
- (current-column))
- lua-indent-level)))
- ((or (string-equal found-token "{")
- (string-equal found-token "("))
- (save-excursion
- ;; expression follows -> indent at start of next expression
- (if (and (not (search-forward-regexp "[[:space:]]--"
(line-end-position) t))
- (search-forward-regexp "[^[:space:]]" (line-end-position)
t))
- (cons 'absolute (1- (current-column)))
- (cons 'relative lua-indent-level))))
- ;; closing tokens follow
- ((string-equal found-token "end")
- (save-excursion
- (lua-goto-matching-block-token nil found-pos)
- (if (looking-at "\\_<function\\_>")
- (cons 'absolute
- (+ (current-indentation)
- (lua-calculate-indentation-block-modifier
- nil (point))))
- (cons 'relative (- lua-indent-level)))))
- ((or (string-equal found-token ")")
- (string-equal found-token "}"))
- (save-excursion
- (lua-goto-matching-block-token nil found-pos)
- (cons 'absolute
- (+ (current-indentation)
- (lua-calculate-indentation-block-modifier
- nil (point))))))
- (t
- (cons 'relative (if (nth 2 (match-data))
- ;; beginning of a block matched
- lua-indent-level
- ;; end of a block matched
- (- lua-indent-level))))))
+ (cond
+ ((string-equal found-token "function")
+ ;; this is the location where we need to start searching for the
+ ;; matching opening token, when we encounter the next closing token.
+ ;; It is primarily an optimization to save some searching time.
+ (cons 'absolute (+ (save-excursion (goto-char found-pos)
+ (current-column))
+ lua-indent-level)))
+
+ ((or (string-equal found-token "{")
+ (string-equal found-token "("))
+ (save-excursion
+ ;; expression follows -> indent at start of next expression
+ (if (and (not (search-forward-regexp "[[:space:]]--" (line-end-position)
t))
+ (search-forward-regexp "[^[:space:]]" (line-end-position) t))
+ (cons 'absolute (1- (current-column)))
+ (cons 'relative lua-indent-level))))
+
+ ;; closing tokens follow
+ ((string-equal found-token "end")
+ (save-excursion
+ (lua-goto-matching-block-token nil found-pos)
+ (if (looking-at "\\_<function\\_>")
+ (cons 'absolute
+ (+ (current-indentation)
+ (lua-calculate-indentation-block-modifier
+ nil (point))))
+ (cons 'relative (- lua-indent-level)))))
+
+ ((or (string-equal found-token ")")
+ (string-equal found-token "}"))
+ (save-excursion
+ (lua-goto-matching-block-token nil found-pos)
+ (cons 'absolute
+ (+ (current-indentation)
+ (lua-calculate-indentation-block-modifier
+ nil (point))))))
+
+ ('other-indentation-modifier
+ (cons 'relative (if (nth 2 (match-data))
+ ;; beginning of a block matched
+ lua-indent-level
+ ;; end of a block matched
+ (- lua-indent-level))))))
(defun lua-calculate-indentation-info (&optional parse-start parse-end)
- [nongnu] elpa/lua-mode eebb50c 035/468: Fix #1913: Indenting: "(" like "{", (continued)
- [nongnu] elpa/lua-mode eebb50c 035/468: Fix #1913: Indenting: "(" like "{", Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fc0a1e3 036/468: Changes/Fixes by Reuben Thomas:, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode de08e4b 028/468: Added version comment for Tom Tromeys package.el, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 676f0a6 045/468: Sync with reality., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 239783b 046/468: Bump version., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a5f8e7b 048/468: Fix generation and use of VERSION, and ignore release notes files., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 14300f1 049/468: Specify branch to pull from., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 60073cc 050/468: Change https to http in URL., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7af5dec 057/468: Use line-beginning(-end)-position when possible, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3ba5bf1 059/468: Redo lua-toggle-electric-state, remove extra function lua-calculate-state, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair: readability refactoring,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode cc46763 061/468: Add some comments, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b2860f1 062/468: lua-setup-keymap: improve readability, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7935b5f 064/468: Fix previous commit, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 85d26f8 065/468: lua-mode-map: initialize as soon as lua-mode is loaded (previously waited for call to lua-mode), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3339da6 067/468: lua-prefix-key: auto-convert from/to character, update bindings automagically, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5842703 068/468: Add TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8165775 069/468: Fix lua-set-prefix message, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6b1d389 074/468: lua-calculate-unindentation: skip semicolons as well, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bda4fbd 075/468: lua-calculate-unindentation: update docs, remove extraneous catch, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a20b08e 078/468: lua-indent-line: remove extra variable shift-amt, Philip Kaludercic, 2021/08/05