Function: sqlind-adjust-operator
sqlind-adjust-operator is a natively compiled function defined in
sql-indent.el.
Signature
(sqlind-adjust-operator SYNTAX BASE-INDENTATION)
Documentation
Adjust the indentation for operators in select clauses.
If the line to be indented starts with an operator, the right-hand operand is lined up with the left hand operand on the previous line. Otherwise, BASE-INDENTATION is returned. For example:
select col1, col2
|| col3 as composed_column,
col4
|| col5 as composed_column2
from my_table
where cond1 = 1
and cond2 = 2;
This is an indentation adjuster and needs to be added to the
`sqlind-indentation-offsets-alist`
Source Code
;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-adjust-operator (syntax base-indentation)
"Adjust the indentation for operators in select clauses.
If the line to be indented starts with an operator, the
right-hand operand is lined up with the left hand operand on the
previous line. Otherwise, BASE-INDENTATION is returned. For
example:
select col1, col2
|| col3 as composed_column,
col4
|| col5 as composed_column2
from my_table
where cond1 = 1
and cond2 = 2;
This is an indentation adjuster and needs to be added to the
`sqlind-indentation-offsets-alist`"
(save-excursion
(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))))
(if (eq (sqlind-syntax-symbol syntax)
'select-column-continuation)
(goto-char (sqlind-column-definition-start
(point) (sqlind-anchor-point syntax)))
(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)))))