[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent 61759eb 2/3: Skip over empty lines when usin
From: |
Stefan Monnier |
Subject: |
[elpa] externals/sql-indent 61759eb 2/3: Skip over empty lines when using previous-line indentation (#95) |
Date: |
Tue, 16 Mar 2021 09:45:05 -0400 (EDT) |
branch: externals/sql-indent
commit 61759eb5f07a78282a228bb1c2908273656905eb
Author: Alex Harsanyi <AlexHarsanyi@gmail.com>
Commit: Alex Harsanyi <AlexHarsanyi@gmail.com>
Skip over empty lines when using previous-line indentation (#95)
* sql-indent.el (sqlind-use-previous-line-indentation): find the
first non-empty line for determining indentation
---
sql-indent.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sql-indent.el b/sql-indent.el
index 4d6e699..b6ddc6a 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -2075,12 +2075,16 @@ anchor."
(current-column)))
(defun sqlind-use-previous-line-indentation (syntax _base-indentation)
- "Return the indentation of the previous line.
+ "Return the indentation of the previous non-empty line.
If the start of the previous line is before the anchor of SYNTAX,
use the column of the anchor + 1."
(let ((anchor (sqlind-anchor-point syntax)))
(save-excursion
(forward-line -1)
+ (beginning-of-line)
+ (while (and (looking-at "^\\s-*$") (> (point) anchor)) ; empty line,
skip it
+ (forward-line -1)
+ (beginning-of-line))
(back-to-indentation)
(if (< (point) anchor)
(progn