branch: externals/sql-indent
commit bc500b8a3be9799ef1185dff1f84eb4e34e492c0
Author: Alex Harsanyi <[email protected]>
Commit: Alex Harsanyi <[email protected]>
don't move cursor when indenting the line
previous simplified too much
---
sql-indent.el | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/sql-indent.el b/sql-indent.el
index c21aa7e..12cf31d 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1667,9 +1667,17 @@ syntaxes"
indentation unit and `sqlind-indentation-offsets-alist' is used to
determine how to indent each type of syntactic element."
(let* ((syntax (sqlind-syntax-of-line))
- (column (sqlind-calculate-indentation syntax)))
- (when column
- (indent-line-to column))))
+ (base-column (current-column))
+ (indent-column (sqlind-calculate-indentation syntax)))
+ (when indent-column
+ (back-to-indentation)
+ (let ((offset (- base-column (current-column))))
+ ;; avoid modifying the buffer when the indentation does not
+ ;; have to change
+ (unless (eq (current-column) indent-column)
+ (indent-line-to indent-column))
+ (when (> offset 0)
+ (forward-char offset))))))
;;;; sqlind-setup