Add previously missing SQL-indent
This commit is contained in:
parent
866fca1028
commit
e122cca29d
4 changed files with 28 additions and 4 deletions
|
|
@ -40,16 +40,16 @@
|
|||
nil
|
||||
t))
|
||||
|
||||
(defun call-in-windowed-mode (callee)
|
||||
(defun byte-compile-in-windowed-mode ()
|
||||
"Call function passed as CALLEE only if run in window mode."
|
||||
(interactive)
|
||||
(if (display-graphic-p)
|
||||
(progn
|
||||
(funcall callee))))
|
||||
(byte-compile-init-dir))))
|
||||
|
||||
;; (call-in-windowed-mode 'byte-compile-init-dir)
|
||||
|
||||
(add-hook 'kill-emacs-hook 'byte-compile-init-dir)
|
||||
(add-hook 'kill-emacs-hook 'byte-compile-in-windowed-mode)
|
||||
(add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
|
||||
|
||||
;; Always start in fullscreen
|
||||
|
|
|
|||
|
|
@ -226,6 +226,10 @@
|
|||
(unless (package-installed-p 'pyenv-mode)
|
||||
(package-install 'pyenv-mode))
|
||||
|
||||
;; SQL
|
||||
(unless (package-installed-p 'sql-indent)
|
||||
(package-install 'sql-indent))
|
||||
|
||||
;; Javascript
|
||||
(unless (package-installed-p 'company-tern)
|
||||
(package-install 'company-tern))
|
||||
|
|
|
|||
2
init.el
2
init.el
|
|
@ -27,7 +27,7 @@
|
|||
;; If there is more than one, they won't work right.
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(json-mode terraform-mode flycheck-rust company-ghc company-ghci scion hlinum etags-select nvm tide yaml-mode window-purpose web-mode ujelly-theme toml-mode smart-mode-line scala-mode rvm ruby-end rspec-mode robe rainbow-mode rainbow-delimiters racer pyenv-mode noctilux-theme monokai-theme markdown-mode less-css-mode json-reformat jade-mode indent-guide helm-themes helm-projectile helm-ag haskell-mode haml-mode groovy-mode flymake-ruby flymake-cursor flycheck flatui-theme exec-path-from-shell evil-nerd-commenter evil-magit evil-leader elpy dumb-jump dockerfile-mode diff-hl dash-at-point company-tern company-racer company-jedi column-enforce-mode color-theme-approximate base16-theme atom-one-dark-theme alchemist aggressive-indent ag)))
|
||||
(sql-indent json-mode terraform-mode flycheck-rust company-ghc company-ghci scion hlinum etags-select nvm tide yaml-mode window-purpose web-mode ujelly-theme toml-mode smart-mode-line scala-mode rvm ruby-end rspec-mode robe rainbow-mode rainbow-delimiters racer pyenv-mode noctilux-theme monokai-theme markdown-mode less-css-mode json-reformat jade-mode indent-guide helm-themes helm-projectile helm-ag haskell-mode haml-mode groovy-mode flymake-ruby flymake-cursor flycheck flatui-theme exec-path-from-shell evil-nerd-commenter evil-magit evil-leader elpy dumb-jump dockerfile-mode diff-hl dash-at-point company-tern company-racer company-jedi column-enforce-mode color-theme-approximate base16-theme atom-one-dark-theme alchemist aggressive-indent ag)))
|
||||
'(safe-local-variable-values (quote ((encoding . utf-8)))))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
|
|
|
|||
|
|
@ -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