update of packages
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
;; Generated package description from sql-indent.el -*- no-byte-compile: t -*-
|
||||
(define-package "sql-indent" "1.6" "Support for indenting code in SQL files." '((cl-lib "0.5")) :commit "ea5aa87c9b8ce6020758d4b4e5d73fc2c50eacfa" :authors '(("Alex Harsanyi" . "AlexHarsanyi@gmail.com")) :maintainer '("Alex Harsanyi" . "AlexHarsanyi@gmail.com") :keywords '("languages" "sql") :url "https://github.com/alex-hhh/emacs-sql-indent")
|
||||
(define-package "sql-indent" "1.7" "Support for indenting code in SQL files." '((cl-lib "0.5")) :commit "323ece64acaac7f27b7806db9dba0757d6e57885" :authors '(("Alex Harsanyi" . "AlexHarsanyi@gmail.com")) :maintainer '("Alex Harsanyi" . "AlexHarsanyi@gmail.com") :keywords '("languages" "sql") :url "https://github.com/alex-hhh/emacs-sql-indent")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
;; Author: Alex Harsanyi <AlexHarsanyi@gmail.com>
|
||||
;; Created: 27 Sep 2006
|
||||
;; Version: 1.6
|
||||
;; Version: 1.7
|
||||
;; Keywords: languages sql
|
||||
;; Homepage: https://github.com/alex-hhh/emacs-sql-indent
|
||||
;; Package-Requires: ((cl-lib "0.5"))
|
||||
@@ -93,8 +93,8 @@ This is used to indent multi-line comments.")
|
||||
|
||||
(defsubst sqlind-in-comment-or-string (pos)
|
||||
"Return non nil if POS is inside a comment or a string.
|
||||
We actually return 'string if POS is inside a string, 'comment if
|
||||
POS is inside a comment, nil otherwise."
|
||||
We actually return \\='string if POS is inside a string,
|
||||
\\='comment if POS is inside a comment, nil otherwise."
|
||||
(syntax-ppss-context (syntax-ppss pos)))
|
||||
|
||||
(defun sqlind-backward-syntactic-ws ()
|
||||
@@ -174,7 +174,7 @@ a string or comment."
|
||||
(defun sqlind-column-definition-start (pos limit)
|
||||
"Find the beginning of a column definition in a select statement.
|
||||
POS is the current position of the line to be indented, assumed
|
||||
to be in a 'select-column-continuation syntax.
|
||||
to be in a \\='select-column-continuation syntax.
|
||||
|
||||
LIMIT is the limit of the search, the beginning of the select
|
||||
statement."
|
||||
@@ -209,8 +209,8 @@ See `sqlind-syntax-of-line' for the definition of CONTEXT."
|
||||
|
||||
(defun sqlind-syntax-keyword (context)
|
||||
"Return the syntax keyword for the most specific syntax of CONTEXT.
|
||||
This is used for complex syntax symbols like '(in-block case
|
||||
\"\"), in that case, it will return the 'case symbol. See
|
||||
This is used for complex syntax symbols like \\='(in-block case
|
||||
\"\"), in that case, it will return the \\='case symbol. See
|
||||
`sqlind-syntax-of-line' for the definition of CONTEXT."
|
||||
(when context
|
||||
(let ((syntax-part (caar context)))
|
||||
@@ -308,8 +308,7 @@ But don't go before LIMIT."
|
||||
(save-excursion
|
||||
(catch 'done
|
||||
(while (> (point) (or limit (point-min)))
|
||||
(when (re-search-backward
|
||||
";\\|:=\\|\\_<\\(declare\\|begin\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\|elseif\\)\\_>\\|)\\|\\$\\$"
|
||||
(when (re-search-backward ";\\|:=\\|\\_<\\(declare\\|\\(begin\\(\\(\\s-+not\\)?\\s-+atomic\\)?\\)\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\|elseif\\)\\_>\\|)\\|\\$\\$"
|
||||
limit 'noerror)
|
||||
(unless (sqlind-in-comment-or-string (point))
|
||||
(let ((candidate-pos (match-end 0)))
|
||||
@@ -497,7 +496,7 @@ We try to avoid false positives, like \"end if\" or the various
|
||||
(forward-word -1)
|
||||
;; we don't want to match an "end if", and things like "drop index if
|
||||
;; exists..." and "create index if not exist..."
|
||||
(not (looking-at "end\\|schema\\|table\\|view\\|index\\|trigger\\|procedure\\|function\\|package\\|body\\|extension")))))
|
||||
(not (looking-at "end\\|schema\\|table\\|view\\|index\\|constraint\\|type\\|trigger\\|procedure\\|function\\|routine\\|package\\|body\\|extension")))))
|
||||
|
||||
(defun sqlind-maybe-if-statement ()
|
||||
"If (point) is on an IF statement, report its syntax."
|
||||
@@ -652,7 +651,7 @@ See also `sqlind-beginning-of-block'"
|
||||
(save-excursion
|
||||
(sqlind-backward-syntactic-ws)
|
||||
(skip-syntax-backward "_w") ; note that the $$ is symbol constituent!
|
||||
(looking-at "\\(\\$\\$\\)\\|begin\\|then\\|else")))
|
||||
(looking-at "\\(\\$\\$\\)\\|begin\\|then\\|else\\|\\(<<[a-z0-9_]+>>\\)")))
|
||||
(throw 'finished
|
||||
(if (null sqlind-end-stmt-stack)
|
||||
'declare-statement
|
||||
@@ -1048,6 +1047,7 @@ reverse order (a stack) and is used to skip over nested blocks."
|
||||
"\\_<\\("
|
||||
"\\(\\(union\\(\\s-+all\\)?\\)\\|intersect\\|minus\\|except\\)?[ \t\r\n\f]*select\\|"
|
||||
"\\(bulk[ \t\r\n\f]+collect[ \t\r\n\f]+\\)?into\\|"
|
||||
"perform\\|"
|
||||
"from\\|"
|
||||
"where\\|"
|
||||
"order[ \t\r\n\f]+by\\|"
|
||||
@@ -1110,7 +1110,8 @@ statement is found."
|
||||
(setq clause (replace-regexp-in-string "[ \t\r\n\f]" " " clause))
|
||||
(when (sqlind-same-level-statement (point) start)
|
||||
(cond
|
||||
((looking-at "select\\(\\s *\\_<\\(top\\s +[0-9]+\\|distinct\\|unique\\)\\_>\\)?")
|
||||
((or (looking-at "select\\(\\s *\\_<\\(top\\s +[0-9]+\\|distinct\\|unique\\)\\_>\\)?")
|
||||
(and (eq sql-product 'postgres) (looking-at "perform\\_>")))
|
||||
;; we are in the column selection section.
|
||||
(goto-char pos)
|
||||
(if (looking-at ",")
|
||||
@@ -1282,14 +1283,14 @@ statement is found."
|
||||
;;;;; Refine the syntax of an end statement.
|
||||
|
||||
(defun sqlind-refine-end-syntax (end-kind end-label end-pos context)
|
||||
"Return a 'block-end syntax for a line containing an \"end\" keyword.
|
||||
"Return a \\='block-end syntax when line contains an \"end\" keyword.
|
||||
|
||||
END-KIND contains the symbol after the end statement ('if if the
|
||||
statement is an \"end if\", 'loop if the statement is an \"end
|
||||
loop\", etc). This can be nil if there is a plain \"end\"
|
||||
END-KIND contains the symbol after the end statement (\\='if if
|
||||
the statement is an \"end if\", \\='loop if the statement is an
|
||||
\"end loop\", etc). This can be nil if there is a plain \"end\"
|
||||
keyword.
|
||||
|
||||
END-LABEL contains the label of the end statement, if there is
|
||||
END-LABEL contains the label of the end statement, when there is
|
||||
one.
|
||||
|
||||
END-POS is the position where the \"end\" keyword is.
|
||||
@@ -1298,12 +1299,13 @@ CONTEXT represents the syntactic context up to the current line.
|
||||
|
||||
The function will perform some validations, for example, an \"end
|
||||
if\" must close an if statement, an \"end loop\" must close a
|
||||
loop, etc. It will return a 'syntax-error syntax if the
|
||||
loop, etc. It will return a \\='syntax-error syntax if the
|
||||
validation fails.
|
||||
|
||||
If all checks pass, it will return a (block-end KIND LABEL) where
|
||||
KIND is the symbol determining the type of the block ('if, 'loop,
|
||||
'procedure, etc) and LABEL is the block label, if there is any."
|
||||
KIND is the symbol determining the type of the block (\\='if,
|
||||
\\='loop, \\='procedure, etc) and LABEL is the block label, if
|
||||
there is any."
|
||||
(catch 'done
|
||||
|
||||
(when (null context) ; can happen
|
||||
@@ -1563,6 +1565,9 @@ not a statement-continuation POS is the same as the
|
||||
(push (sqlind-syntax-in-with pos (point)) context))
|
||||
((looking-at "select")
|
||||
(push (sqlind-syntax-in-select pos (point)) context))
|
||||
((and (eq sql-product 'postgres)
|
||||
(looking-at "perform"))
|
||||
(push (sqlind-syntax-in-select pos (point)) context))
|
||||
((looking-at "insert")
|
||||
(push (sqlind-syntax-in-insert pos (point)) context))
|
||||
((looking-at "delete")
|
||||
@@ -1626,7 +1631,8 @@ not a statement-continuation POS is the same as the
|
||||
(push (cons (list 'block-start 'exception) anchor) context))
|
||||
|
||||
((and (eq syntax-symbol 'in-block)
|
||||
(memq (nth 1 syntax) '(then case)))
|
||||
(memq (nth 1 syntax) '(then case))
|
||||
(not (looking-at "end\\s-*\\_<\\(if\\|case\\)\\_>")))
|
||||
(if (looking-at "when\\_>")
|
||||
(push (cons (list 'block-start 'when) anchor) context)
|
||||
;; NOTE: the "when" case is handed above
|
||||
@@ -2076,7 +2082,7 @@ returned."
|
||||
;;;;; Indentation helper functions
|
||||
|
||||
(defun sqlind-report-sytax-error (syntax _base-indentation)
|
||||
"Report a syntax error for a 'syntax-error SYNTAX."
|
||||
"Report a syntax error for a \\='syntax-error SYNTAX."
|
||||
(cl-destructuring-bind (_sym msg start end) (sqlind-syntax syntax)
|
||||
(message "%s (%d %d)" msg start end))
|
||||
nil)
|
||||
@@ -2183,7 +2189,8 @@ first column after the SELECT clause we simply add
|
||||
`sqlind-basic-offset'."
|
||||
(save-excursion
|
||||
(goto-char (sqlind-anchor-point syntax))
|
||||
(when (looking-at "select\\s *\\(top\\s +[0-9]+\\|distinct\\|unique\\)?")
|
||||
(when (or (looking-at "select\\s *\\(top\\s +[0-9]+\\|distinct\\|unique\\)?")
|
||||
(and (eq sql-product 'postgres) (looking-at "perform\\_>")))
|
||||
(goto-char (match-end 0)))
|
||||
(skip-syntax-forward " ")
|
||||
(if (or (looking-at sqlind-comment-start-skip)
|
||||
@@ -2240,9 +2247,10 @@ Argument BASE-INDENTATION is updated."
|
||||
SYNTAX is the syntax of the current line, BASE-INDENTATION is the
|
||||
current indentation, which we need to update.
|
||||
|
||||
If this rule is added to the 'in-select-clause syntax after the
|
||||
`sqlind-lineup-to-clause-end' rule, it will adjust lines starting
|
||||
with AND, OR or NOT to be aligned so they sit under the WHERE clause."
|
||||
If this rule is added to the \\='in-select-clause syntax after
|
||||
the `sqlind-lineup-to-clause-end' rule, it will adjust lines
|
||||
starting with AND, OR or NOT to be aligned so they sit under the
|
||||
WHERE clause."
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(cl-destructuring-bind ((_sym clause) . anchor) (car syntax)
|
||||
@@ -2260,9 +2268,10 @@ with AND, OR or NOT to be aligned so they sit under the WHERE clause."
|
||||
SYNTAX is the syntax of the current line, BASE-INDENTATION is the
|
||||
current indentation, which we need to update.
|
||||
|
||||
If this rule is added to the 'in-select-clause syntax after the
|
||||
`sqlind-lineup-to-clause-end' rule, it will adjust lines starting
|
||||
with AND, OR or NOT to be aligned so they sit left under the WHERE clause."
|
||||
If this rule is added to the \\='in-select-clause syntax after
|
||||
the `sqlind-lineup-to-clause-end' rule, it will adjust lines
|
||||
starting with AND, OR or NOT to be aligned so they sit left under
|
||||
the WHERE clause."
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(cl-destructuring-bind ((_sym clause) . anchor) (car syntax)
|
||||
@@ -2381,9 +2390,9 @@ the FROM keyword."
|
||||
|
||||
(defun sqlind-lineup-open-paren-to-anchor (syntax base-indentation)
|
||||
"Align an open paranthesis with the anchor point of SYNTAX.
|
||||
If the line starts with an open paren '(', return the column of
|
||||
the anchor point. If line does not start with an open paren, the
|
||||
function returns BASE-INDENTATION, acting as a no-op."
|
||||
If the line starts with an open paren \\='(\\=', return the
|
||||
column of the anchor point. If line does not start with an open
|
||||
paren, the function returns BASE-INDENTATION, acting as a no-op."
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(if (looking-at "(")
|
||||
@@ -2408,11 +2417,11 @@ Return the column of the first non-whitespace char in a nested
|
||||
statement. For example:
|
||||
|
||||
( a,
|
||||
b, -- b is always aligned with 'a'
|
||||
b, -- b is always aligned with \\='a\\='
|
||||
)
|
||||
|
||||
This function only makes sense in a
|
||||
'nested-statement-continuation SYTNAX indentation rule."
|
||||
\\='nested-statement-continuation SYTNAX indentation rule."
|
||||
(save-excursion
|
||||
(goto-char (sqlind-anchor-point syntax))
|
||||
(end-of-line)
|
||||
@@ -2540,8 +2549,8 @@ will indent the line according to the syntactic context of the
|
||||
SQL statement being edited.
|
||||
|
||||
A set of alignment rules are also enabled with this minor mode.
|
||||
Selecting a region of text and typing `M-x align RET` will align
|
||||
the statements. This can be used, for example, to align the 'as'
|
||||
Selecting a region of text and typing `M-x align RET' will align
|
||||
the statements. This can be used, for example, to align the `as'
|
||||
column aliases in select statements."
|
||||
:lighter " sqlind"
|
||||
;; :group 'sqlind ;;FIXME: There's no such group!
|
||||
|
||||
Reference in New Issue
Block a user