Add previously missing SQL-indent
This commit is contained in:
parent
866fca1028
commit
e122cca29d
4 changed files with 28 additions and 4 deletions
|
|
@ -22,6 +22,26 @@
|
|||
(add-hook 'sql-mode-hook 'editor-config-sql)
|
||||
(add-hook 'sql-mode-hook 'completion-config-sql)
|
||||
|
||||
(require 'sql-indent)
|
||||
|
||||
;;========== Functions =====================
|
||||
(defun sql-indent-string ()
|
||||
"Indents the string under the cursor as SQL."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(er/mark-inside-quotes)
|
||||
(let* ((text (buffer-substring-no-properties (region-beginning) (region-end)))
|
||||
(pos (region-beginning))
|
||||
(column (progn (goto-char pos) (current-column)))
|
||||
(formatted-text (with-temp-buffer
|
||||
(insert text)
|
||||
(delete-trailing-whitespace)
|
||||
(sql-indent-buffer)
|
||||
(replace-string "\n" (concat "\n" (make-string column (string-to-char " "))) nil (point-min) (point-max))
|
||||
(buffer-string))))
|
||||
(delete-region (region-beginning) (region-end))
|
||||
(goto-char pos)
|
||||
(insert formatted-text))))
|
||||
|
||||
|
||||
;;; sql.el ends here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue