Commit 3035b156 authored by Miles Bader's avatar Miles Bader
Browse files

(sql-magic-go): Use comint-bol instead of explicitly matching

  comint-prompt-regexp.
(sql-copy-column): Use comint-line-beginning-position instead of
  explicitly matching comint-prompt-regexp.
parent 28bc09d6
...@@ -664,8 +664,8 @@ can be changed by some entry functions to provide more hilighting.") ...@@ -664,8 +664,8 @@ can be changed by some entry functions to provide more hilighting.")
(self-insert-command (prefix-numeric-value arg)) (self-insert-command (prefix-numeric-value arg))
(if (and (equal sql-electric-stuff 'go) (if (and (equal sql-electric-stuff 'go)
(save-excursion (save-excursion
(beginning-of-line) (comint-bol nil)
(looking-at (concat sql-prompt-regexp "go\\b")))) (looking-at "go\\b")))
(comint-send-input))) (comint-send-input)))
(defun sql-magic-semicolon (arg) (defun sql-magic-semicolon (arg)
...@@ -885,21 +885,21 @@ Inserts SELECT or commas if appropriate." ...@@ -885,21 +885,21 @@ Inserts SELECT or commas if appropriate."
(progn (forward-char 1) (backward-sexp 1) (point)) (progn (forward-char 1) (backward-sexp 1) (point))
(progn (forward-sexp 1) (point)))) (progn (forward-sexp 1) (point))))
(goto-char (point-max)) (goto-char (point-max))
(let ((bol (comint-line-beginning-position)))
(cond (cond
;; if empty command line, insert SELECT ;; if empty command line, insert SELECT
((save-excursion (beginning-of-line) ((= bol (point))
(looking-at (concat comint-prompt-regexp "$")))
(insert "SELECT ")) (insert "SELECT "))
;; else if appending to INTO .* (, SELECT or ORDER BY, insert a comma ;; else if appending to INTO .* (, SELECT or ORDER BY, insert a comma
((save-excursion ((save-excursion
(re-search-backward "\\b\\(\\(into\\s-+\\S-+\\s-+(\\)\\|select\\|order by\\) .+" (re-search-backward "\\b\\(\\(into\\s-+\\S-+\\s-+(\\)\\|select\\|order by\\) .+"
(save-excursion (beginning-of-line) (point)) t)) bol t))
(insert ", ")) (insert ", "))
;; else insert a space ;; else insert a space
(t (t
(if (eq (preceding-char) ? ) (if (eq (preceding-char) ? )
nil nil
(insert " ")))) (insert " ")))))
;; in any case, insert the column ;; in any case, insert the column
(insert column) (insert column)
(message "%s" column)))) (message "%s" column))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment