[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 87d0007: Automate support for `sql-indent' ELPA pac
From: |
Michael Mauger |
Subject: |
[Emacs-diffs] master 87d0007: Automate support for `sql-indent' ELPA package |
Date: |
Mon, 1 Oct 2018 00:20:02 -0400 (EDT) |
branch: master
commit 87d0007499d8434f40926c99f1edc3c4a700a79d
Author: Michael R. Mauger <address@hidden>
Commit: Michael R. Mauger <address@hidden>
Automate support for `sql-indent' ELPA package
* progmodes/lisp/sql.el (sql-use-indent-support): New variable.
(sql-is-indent-available): New function.
(sql-indent-enable): Use above.
(sql-mode-hook, sql-interactive-mode-hook): Add `sql-indent-enable'.
---
etc/NEWS | 23 +++++++++++++++++++++++
lisp/progmodes/sql.el | 37 ++++++++++++++++++++++++++++++++-----
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index a54abd7..daacf49 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -365,6 +365,29 @@ better emulate 'M-.' in both Bash and zsh, since the
former counts
from the beginning of the arguments, while the latter counts from the
end.
+** SQL
+
+*** Installation of 'sql-indent' from ELPA is strongly encouraged.
+This package support sophisticated rules for properly indenting SQL
+statements. SQL is not like other programming languages like C, Java,
+or Python where code is sparse and rules for formatting are fairly
+well established. Instead SQL is more like COBOL (from which it came)
+and code tends to be very dense and line ending decisions driven by
+syntax and line length considerations to make readable code.
+Experienced SQL developers may prefer to rely upon existing Emacs
+facilities for formatting code but the 'sql-indent' package provides
+facilities to aid more casual SQL developers layout queries and
+complex expressions.
+
+*** 'sql-use-indent-support' (default t) enables SQL indention support.
+The `sql-indent' package from ELPA must be installed to get the
+indentation support in 'sql-mode' and 'sql-interactive-mode'.
+
+*** 'sql-mode-hook' and 'sql-interactive-mode-hook' changed.
+Both hook variables have had 'sql-indent-enable' added to their
+default values. If youhave existing customizations to these variables,
+you should make sure that the new default entry is included.
+
** Term
---
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index ba180c2..1cdae35 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -213,7 +213,7 @@
;; Drew Adams <address@hidden> -- Emacs 20 support
;; Harald Maier <address@hidden> -- sql-send-string
;; Stefan Monnier <address@hidden> -- font-lock corrections;
-;; code polish
+;; code polish; on-going guidance and mentorship
;; Paul Sleigh <address@hidden> -- MySQL keyword enhancement
;; Andrew Schein <address@hidden> -- sql-port bug
;; Ian Bjorhovde <address@hidden> -- db2 escape newlines
@@ -222,6 +222,7 @@
;; Mark Wilkinson <address@hidden> -- file-local variables ignored
;; Simen Heggestøyl <address@hidden> -- Postgres database completion
;; Robert Cochran <address@hidden> -- MariaDB support
+;; Alex Harsanyi <address@hidden> -- sql-indent package and support
;;
@@ -723,6 +724,30 @@ This allows highlighting buffers properly when you open
them."
:group 'SQL
:safe 'symbolp)
+;; SQL indent support
+
+(defcustom sql-use-indent-support t
+ "If non-nil then use the SQL indent support features of sql-indent.
+The `sql-indent' package in ELPA provides indentation support for
+SQL statements with easy customizations to support varied layout
+requirements.
+
+The package must be available to be loaded and activated."
+ :group 'SQL
+ :link '(url-link "https://elpa.gnu.org/packages/sql-indent.html";)
+ :type 'booleanp
+ :version "27.1")
+
+(defun sql-is-indent-available ()
+ "Check if sql-indent module is available."
+ (when (locate-library "sql-indent")
+ (fboundp 'sqlind-minor-mode)))
+
+(defun sql-indent-enable ()
+ "Enable `sqlind-minor-mode' if available and requested."
+ (when (sql-is-indent-available)
+ (sqlind-minor-mode (if sql-use-indent-support +1 -1))))
+
;; misc customization of sql.el behavior
(defcustom sql-electric-stuff nil
@@ -850,15 +875,17 @@ commands when the input history is read, as if you had set
;; The usual hooks
-(defcustom sql-interactive-mode-hook '()
+(defcustom sql-interactive-mode-hook '(sql-indent-enable)
"Hook for customizing `sql-interactive-mode'."
:type 'hook
- :group 'SQL)
+ :group 'SQL
+ :version "27.1")
-(defcustom sql-mode-hook '()
+(defcustom sql-mode-hook '(sql-indent-enable)
"Hook for customizing `sql-mode'."
:type 'hook
- :group 'SQL)
+ :group 'SQL
+ :version "27.1")
(defcustom sql-set-sqli-hook '()
"Hook for reacting to changes of `sql-buffer'.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 87d0007: Automate support for `sql-indent' ELPA package,
Michael Mauger <=