[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent 283116d 04/13: Correct the adjustment of ind
From: |
Stefan Monnier |
Subject: |
[elpa] externals/sql-indent 283116d 04/13: Correct the adjustment of indentation for operators in select (#52) |
Date: |
Sun, 11 Feb 2018 22:24:13 -0500 (EST) |
branch: externals/sql-indent
commit 283116d7c3bd4275a169d1631235de61e0da7c01
Author: Pierre Téchoueyres <address@hidden>
Commit: Alex Harsányi <address@hidden>
Correct the adjustment of indentation for operators in select (#52)
* Correct the adjustment of indentation for operators in select
With this fix the following statement is propely indented
``` sql
select mt.myVar
|| '-*-' myVarLabel,
myVar2
from myTable mt;
```
instead of
``` sql
select mt.myVar
|| '-*-' myVarLabel,
myVar2
from myTable mt;
```
* sql-indent.el: Use sqlind syntax table in adjustments functions.
(sqlind-adjust-operator): Use sqlind syntax table.
* Add test to pr52
---
sql-indent-test.el | 3 +++
sql-indent.el | 33 +++++++++++++++++----------------
test-data/pr52-io-left.eld | 1 +
test-data/pr52.sql | 12 ++++++++++++
4 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index 97d6082..67cdf1e 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -352,4 +352,7 @@ information read from DATA-FILE (as generated by
(sqlind-ert-check-file-indentation "test-data/pr50.sql"
"test-data/pr50-io-left.eld"
sqlind-indentation-left-offsets-alist 2))
+(ert-deftest sqlind-ert-pr52-io-left ()
+ (sqlind-ert-check-file-indentation "test-data/pr52.sql"
"test-data/pr52-io-left.eld"
+ sqlind-indentation-left-offsets-alist 2))
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index 72028b6..c16dd9a 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1959,22 +1959,23 @@ example:
This is an indentation adjuster and needs to be added to the
`sqlind-indentation-offsets-alist`"
(save-excursion
- (back-to-indentation)
- ;; If there are non-word constituents at the beginning if the line,
- ;; consider them an operator and line up the line to the first word of the
- ;; line, not the operator
- (cond ((looking-at sqlind-operator-regexp)
- (let ((ofs (length (match-string 0))))
- (forward-line -1)
- (end-of-line)
- (sqlind-backward-syntactic-ws)
- ;; Previous function leaves us on the first non-white-space
- ;; character. This might be a string terminator (') char, move
- ;; the cursor one to the left, so 'forward-sexp' works correctly.
- (ignore-errors (forward-char 1))
- (forward-sexp -1)
- (max 0 (- (current-column) ofs))))
- ('t base-indentation))))
+ (with-syntax-table sqlind-syntax-table
+ (back-to-indentation)
+ ;; If there are non-word constituents at the beginning if the line,
+ ;; consider them an operator and line up the line to the first word of
the
+ ;; line, not the operator
+ (cond ((looking-at sqlind-operator-regexp)
+ (let ((ofs (length (match-string 0))))
+ (forward-line -1)
+ (end-of-line)
+ (sqlind-backward-syntactic-ws)
+ ;; Previous function leaves us on the first non-white-space
+ ;; character. This might be a string terminator (') char, move
+ ;; the cursor one to the left, so 'forward-sexp' works correctly.
+ (ignore-errors (forward-char 1))
+ (forward-sexp -1)
+ (max 0 (- (current-column) ofs))))
+ ('t base-indentation)))))
(defun sqlind-lone-semicolon (syntax base-indentation)
"Indent a lone semicolon with the statement start. For example:
diff --git a/test-data/pr52-io-left.eld b/test-data/pr52-io-left.eld
new file mode 100644
index 0000000..4a96bab
--- /dev/null
+++ b/test-data/pr52-io-left.eld
@@ -0,0 +1 @@
+(0 4 7 0 0 0 0 0 0 0 0 0 0)
diff --git a/test-data/pr52.sql b/test-data/pr52.sql
new file mode 100644
index 0000000..84b1847
--- /dev/null
+++ b/test-data/pr52.sql
@@ -0,0 +1,12 @@
+select mt.myVar
+ || '-*-' myVarLabel,
+ myVar2
+from myTable mt;
+
+-- Local Variables:
+-- mode: sql
+-- mode: sqlind-minor
+-- tab-width: 2
+-- indent-tabs-mode: nil
+-- sql-product: oracle
+-- End:
- [elpa] externals/sql-indent updated (c3d49c6 -> 44841a8), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent bd39d07 10/13: add explanation on how `sqlind-beginning-of-block` works, Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 2c9c17f 07/13: Fix typo in sql-indent.org. (#56), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 283116d 04/13: Correct the adjustment of indentation for operators in select (#52),
Stefan Monnier <=
- [elpa] externals/sql-indent 51b17d6 01/13: Update README with instructions on how to install from GNU ELPA, Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 0bca299 12/13: Fix travis build. (#58), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 44841a8 13/13: Add .elpaignore file, Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 1b4d0e8 03/13: Add CONTRIBUTING.md file (#51), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 3ee7f95 08/13: Fix various typos here and there. (#57), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent d56faed 06/13: Updated documentation, Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 9f716f6 09/13: Recognize PostgreSQL $$ quote syntax, #54 (#55), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 8a1c4ec 05/13: Correct indentation of column continuation with operators. (#53), Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 1efac21 11/13: Update sql-indent.el to version 1.1, Stefan Monnier, 2018/02/11
- [elpa] externals/sql-indent 146655b 02/13: Add new indentation function for select columns. (#50), Stefan Monnier, 2018/02/11