aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/sql.el
diff options
context:
space:
mode:
authorStefan Monnier2019-02-20 09:25:54 -0500
committerStefan Monnier2019-02-20 09:25:54 -0500
commit74240f231266ec9350116772d6834b90cb52f09d (patch)
tree47c031937d1b6370cfc695fe0059dbbf726024fa /lisp/progmodes/sql.el
parent15a2b2c0716079a078b1147a6d9e89ce4d343fd6 (diff)
downloademacs-74240f231266ec9350116772d6834b90cb52f09d.tar.gz
emacs-74240f231266ec9350116772d6834b90cb52f09d.zip
* lisp/progmodes/sql.el (sql-is-indent-available): Remove
(sql-indent-enable): Check (fboundp 'sqlind-minor-mode) without wondering which file might provide it. (sql-read-connection): η-reduce 'car'.
Diffstat (limited to 'lisp/progmodes/sql.el')
-rw-r--r--lisp/progmodes/sql.el31
1 files changed, 13 insertions, 18 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 014987b09e3..9bae3d86640 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -739,14 +739,9 @@ The package must be available to be loaded and activated."
739 :type 'booleanp 739 :type 'booleanp
740 :version "27.1") 740 :version "27.1")
741 741
742(defun sql-is-indent-available ()
743 "Check if sql-indent module is available."
744 (when (locate-library "sql-indent")
745 (fboundp 'sqlind-minor-mode)))
746
747(defun sql-indent-enable () 742(defun sql-indent-enable ()
748 "Enable `sqlind-minor-mode' if available and requested." 743 "Enable `sqlind-minor-mode' if available and requested."
749 (when (sql-is-indent-available) 744 (when (fboundp 'sqlind-minor-mode)
750 (sqlind-minor-mode (if sql-use-indent-support +1 -1)))) 745 (sqlind-minor-mode (if sql-use-indent-support +1 -1))))
751 746
752;; Secure Password wallet 747;; Secure Password wallet
@@ -925,7 +920,7 @@ Globally should be set to nil; it will be non-nil in `sql-mode',
925 920
926(defvaralias 'sql-pop-to-buffer-after-send-region 'sql-display-sqli-buffer-function) 921(defvaralias 'sql-pop-to-buffer-after-send-region 'sql-display-sqli-buffer-function)
927 922
928(defcustom sql-display-sqli-buffer-function 'display-buffer 923(defcustom sql-display-sqli-buffer-function #'display-buffer
929 "Function to be called to display a SQLi buffer after `sql-send-*'. 924 "Function to be called to display a SQLi buffer after `sql-send-*'.
930 925
931When set to a function, it will be called to display the buffer. 926When set to a function, it will be called to display the buffer.
@@ -3681,8 +3676,8 @@ Allows the suppression of continuation prompts.")
3681 3676
3682 ;; Count how many newlines in the string 3677 ;; Count how many newlines in the string
3683 (setq sql-output-newline-count 3678 (setq sql-output-newline-count
3684 (apply #'+ (mapcar (lambda (ch) 3679 (apply #'+ (mapcar (lambda (ch) (if (eq ch ?\n) 1 0))
3685 (if (eq ch ?\n) 1 0)) string))) 3680 string)))
3686 3681
3687 ;; Send the string 3682 ;; Send the string
3688 (comint-simple-send proc string))) 3683 (comint-simple-send proc string)))
@@ -4232,7 +4227,7 @@ must tell Emacs. Here's how to do that in your init file:
4232 ;; Set syntax and font-face highlighting 4227 ;; Set syntax and font-face highlighting
4233 ;; Catch changes to sql-product and highlight accordingly 4228 ;; Catch changes to sql-product and highlight accordingly
4234 (sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591 4229 (sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591
4235 (add-hook 'hack-local-variables-hook 'sql-highlight-product t t)) 4230 (add-hook 'hack-local-variables-hook #'sql-highlight-product t t))
4236 4231
4237 4232
4238 4233
@@ -4240,7 +4235,7 @@ must tell Emacs. Here's how to do that in your init file:
4240 4235
4241(put 'sql-interactive-mode 'mode-class 'special) 4236(put 'sql-interactive-mode 'mode-class 'special)
4242(put 'sql-interactive-mode 'custom-mode-group 'SQL) 4237(put 'sql-interactive-mode 'custom-mode-group 'SQL)
4243 4238;; FIXME: Why not use `define-derived-mode'?
4244(defun sql-interactive-mode () 4239(defun sql-interactive-mode ()
4245 "Major mode to use a SQL interpreter interactively. 4240 "Major mode to use a SQL interpreter interactively.
4246 4241
@@ -4302,13 +4297,15 @@ certain length.
4302 4297
4303\(add-hook \\='sql-interactive-mode-hook 4298\(add-hook \\='sql-interactive-mode-hook
4304 (function (lambda () 4299 (function (lambda ()
4305 (setq comint-output-filter-functions \\='comint-truncate-buffer)))) 4300 (setq comint-output-filter-functions #\\='comint-truncate-buffer))))
4306 4301
4307Here is another example. It will always put point back to the statement 4302Here is another example. It will always put point back to the statement
4308you entered, right above the output it created. 4303you entered, right above the output it created.
4309 4304
4310\(setq comint-output-filter-functions 4305\(setq comint-output-filter-functions
4311 (function (lambda (STR) (comint-show-output))))" 4306 (function (lambda (STR) (comint-show-output))))"
4307 ;; FIXME: The doc above uses `setq' on `comint-output-filter-functions',
4308 ;; whereas hooks should be manipulated with things like `add/remove-hook'.
4312 (delay-mode-hooks (comint-mode)) 4309 (delay-mode-hooks (comint-mode))
4313 4310
4314 ;; Get the `sql-product' for this interactive session. 4311 ;; Get the `sql-product' for this interactive session.
@@ -4340,7 +4337,7 @@ you entered, right above the output it created.
4340 (setq abbrev-all-caps 1) 4337 (setq abbrev-all-caps 1)
4341 ;; Exiting the process will call sql-stop. 4338 ;; Exiting the process will call sql-stop.
4342 (let ((proc (get-buffer-process (current-buffer)))) 4339 (let ((proc (get-buffer-process (current-buffer))))
4343 (when proc (set-process-sentinel proc 'sql-stop))) 4340 (when proc (set-process-sentinel proc #'sql-stop)))
4344 ;; Save the connection and login params 4341 ;; Save the connection and login params
4345 (set (make-local-variable 'sql-user) sql-user) 4342 (set (make-local-variable 'sql-user) sql-user)
4346 (set (make-local-variable 'sql-database) sql-database) 4343 (set (make-local-variable 'sql-database) sql-database)
@@ -4366,7 +4363,7 @@ you entered, right above the output it created.
4366 (make-local-variable 'sql-output-newline-count) 4363 (make-local-variable 'sql-output-newline-count)
4367 (make-local-variable 'sql-preoutput-hold) 4364 (make-local-variable 'sql-preoutput-hold)
4368 (add-hook 'comint-preoutput-filter-functions 4365 (add-hook 'comint-preoutput-filter-functions
4369 'sql-interactive-remove-continuation-prompt nil t) 4366 #'sql-interactive-remove-continuation-prompt nil t)
4370 (make-local-variable 'sql-input-ring-separator) 4367 (make-local-variable 'sql-input-ring-separator)
4371 (make-local-variable 'sql-input-ring-file-name) 4368 (make-local-variable 'sql-input-ring-file-name)
4372 ;; Run the mode hook (along with comint's hooks). 4369 ;; Run the mode hook (along with comint's hooks).
@@ -4415,8 +4412,7 @@ Sentinels will always get the two parameters PROCESS and EVENT."
4415 "Read a connection name." 4412 "Read a connection name."
4416 (let ((completion-ignore-case t)) 4413 (let ((completion-ignore-case t))
4417 (completing-read prompt 4414 (completing-read prompt
4418 (mapcar (lambda (c) (car c)) 4415 (mapcar #'car sql-connection-alist)
4419 sql-connection-alist)
4420 nil t initial 'sql-connection-history default))) 4416 nil t initial 'sql-connection-history default)))
4421 4417
4422;;;###autoload 4418;;;###autoload
@@ -5378,8 +5374,7 @@ The default comes from `process-coding-system-alist' and
5378your might try undecided-dos as a coding system. If this doesn't help, 5374your might try undecided-dos as a coding system. If this doesn't help,
5379Try to set `comint-output-filter-functions' like this: 5375Try to set `comint-output-filter-functions' like this:
5380 5376
5381\(setq comint-output-filter-functions (append comint-output-filter-functions 5377\(add-hook 'comint-output-filter-functions #\\='comint-strip-ctrl-m 'append)
5382 \\='(comint-strip-ctrl-m)))
5383 5378
5384\(Type \\[describe-mode] in the SQL buffer for a list of commands.)" 5379\(Type \\[describe-mode] in the SQL buffer for a list of commands.)"
5385 (interactive "P") 5380 (interactive "P")