branch: externals/sql-indent
commit 91eba35b55df1d1a450ed221bf6fa963ca1be34a
Author: Alex Harsanyi <[email protected]>
Commit: Alex Harsanyi <[email protected]>

    move default indentation offsets in separate constant
    
    `sqlind-indentation-offsets-alist' is now buffer local and it is simpler to
    override
---
 customize-indentation.md | 10 +++++++---
 sql-indent.el            | 11 ++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/customize-indentation.md b/customize-indentation.md
index 9a6e94b..188b39d 100644
--- a/customize-indentation.md
+++ b/customize-indentation.md
@@ -20,13 +20,17 @@ them up in your init.el file before loading the package.  
For example:
     ;; Update indentation rules, select, insert, delete and update keywords
     ;; are aligned with the clause start
 
-    (defvar old-sqlind-indentation-offsets-alist 
sqlind-indentation-offsets-alist)
-    (setq sqlind-indentation-offsets-alist
+    (defvar my-sql-indentation-offsets-alist
       `((select-clause 0)
         (insert-clause 0)
         (delete-clause 0)
         (update-clause 0)
-        ,@old-sqlind-indentation-offsets-alist))
+        ,@sqlind-default-indentation-offsets-alist))
+        
+    (add-hoook 'sql-mode-hook 
+        (lambda () 
+           (setq sqlind-indentation-offsets-alist
+               my-sql-indentation-offsets-alist)))
 
 The simplest way to adjust the indentation is to explore the syntactic
 information using `sqlind-show-syntax-of-line`.  To use it, move the cursor to
diff --git a/sql-indent.el b/sql-indent.el
index aec5688..bb84dff 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -1362,7 +1362,7 @@ clause (select, from, where, etc) in which the current 
point is.
 - (in-update-clause CLAUSE) -- line is inside an update CLAUSE,
   which can be \"update\", \"set\" or \"where\".")
 
-(defvar sqlind-indentation-offsets-alist
+(defconst sqlind-default-indentation-offsets-alist
   '((syntax-error                   sqlind-report-sytax-error)
     (in-string                      sqlind-report-runaway-string)
 
@@ -1436,6 +1436,15 @@ indentation for each syntactic-symbol. It is a list of:
 See `sqlind-calculate-indentation' for how the indentation offset
 is calculated.")
 
+(defvar sqlind-indentation-offsets-alist
+  sqlind-default-indentation-offsets-alist
+  "Define the indentation amount for each syntactic symbol.
+See also `sqlind-default-indentation-offsets-alist',
+`sqlind-indentation-syntax-symbols' and
+`sqlind-calculate-indentation'")
+
+(make-variable-buffer-local 'sqlind-indentation-offsets-alist)
+
 (defun sqlind-calculate-indentation (syntax &optional base-indentation)
   "Return the indentation that should be applied to the current line.
 SYNTAX is the syntaxtic information as returned by

Reply via email to