[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 158f267 058/468: Merge lua-goto-nonblank-* funcs
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 158f267 058/468: Merge lua-goto-nonblank-* funcs into one |
Date: |
Thu, 5 Aug 2021 04:58:07 -0400 (EDT) |
branch: elpa/lua-mode
commit 158f26765c0abd1d646313a94c413c2754a79021
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
Merge lua-goto-nonblank-* funcs into one
---
lua-mode.el | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index bdc8d22..de643f4 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -530,27 +530,20 @@ matching keyword that ends the block, and vice versa."
(error "Not on a block control keyword or brace.")
position)))
-(defun lua-goto-nonblank-previous-line ()
- "Puts the point at the first previous line that is not blank.
-Returns the point, or nil if it reached the beginning of the buffer"
- (catch 'found
- (beginning-of-line)
- (while t
- (if (bobp) (throw 'found nil))
- (forward-char -1)
- (beginning-of-line)
- (if (not (looking-at "\\s *\\(--.*\\)?$")) (throw 'found (point))))))
+(defun lua-forward-line-skip-blanks (&optional back)
+ "Move 1 line forward (back if BACK is non-nil) skipping blank lines.
+
+Moves point 1 line forward (or backward) skipping lines that contain
+no Lua code besides comments. The point is put to the beginning of
+the line.
-(defun lua-goto-nonblank-next-line ()
- "Puts the point at the first next line that is not blank.
-Returns the point, or nil if it reached the end of the buffer"
+Returns final value of point as integer or nil if operation failed."
(catch 'found
- (end-of-line)
(while t
- (forward-line)
- (if (eobp) (throw 'found nil))
- (beginning-of-line)
- (if (not (looking-at "\\s *\\(--.*\\)?$")) (throw 'found (point))))))
+ (unless (eql (forward-line (if back -1 1)) 0) ;; 0 means success
+ (throw 'found nil))
+ (unless (looking-at "\\s *\\(--.*\\)?$") ;; blank lua line
+ (throw 'found (point))))))
(eval-when-compile
(defconst lua-operator-class
@@ -616,7 +609,7 @@ The criteria for a continuing statement are:
(let ((prev-line nil))
(save-excursion
(if parse-start (goto-char parse-start))
- (save-excursion (setq prev-line (lua-goto-nonblank-previous-line)))
+ (save-excursion (setq prev-line (lua-forward-line-skip-blanks 'back)))
(and prev-line
(or (lua-first-token-continues-p)
(and (goto-char prev-line)
@@ -728,7 +721,7 @@ one."
;; e + f + g)"
(save-excursion
(or (and (lua-last-token-continues-p) lua-indent-level)
- (and (lua-goto-nonblank-next-line)
(lua-first-token-continues-p) lua-indent-level)
+ (and (lua-forward-line-skip-blanks)
(lua-first-token-continues-p) lua-indent-level)
0)))
(+ (lua-calculate-indentation-left-shift)
(cdr indentation-info)
- [nongnu] elpa/lua-mode a3ed448 106/468: Make dist with git-archive, (continued)
- [nongnu] elpa/lua-mode a3ed448 106/468: Make dist with git-archive, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 742180e 125/468: lua-automark-multiline: add lua-automark-multiline-maxsize variable to prevent long waits on big files, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0b3df35 135/468: Fix string content indentation: it's now indented by indent-level relative to indentation of the line where string/comment literal starts (issue #6), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5aa6f9e 042/468: Patch from Reuben: fix long string colouring problem, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode eb5d301 055/468: Bump version., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d66ec8e 080/468: Remove broken multiline literal font-locking, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d142ed1 084/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode de12f4b 086/468: lua-mark-all-multiline-literals: also handle multiline comments, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 46683e7 052/468: Make lua-indent-level customizable., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3c89a0a 054/468: Reorder customizations better., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 158f267 058/468: Merge lua-goto-nonblank-* funcs into one,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode c5f37b0 088/468: lua-mark-all-multiline-literals: look for multiline ending beyond specified bounds to improve integrity, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 96658a0 089/468: Move actual marking of multiline construct into lua-mark-multiline-region, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode da22ef7 094/468: Rename lua-clear-multiline-delims -> lua-unmark-multiline-literals, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5607327 096/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2b91610 098/468: Bump contact information, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5953970 101/468: Bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c044a1b 109/468: Fix emacs compilation warning in XEmacs-oriented code, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3367502 121/468: Merge pull request #7 from rlph/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9645322 124/468: lua-indent-line: add lua-indent-string-contents custom variable to enable indenting multiline strings if necessary (issue #6), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 99ef499 129/468: Make lua-automark variables buffer local, Philip Kaludercic, 2021/08/05