emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master da048c69270: Fix case problem with 'sql-magic-go' (bug#73499)


From: Stephen Berman
Subject: master da048c69270: Fix case problem with 'sql-magic-go' (bug#73499)
Date: Sun, 13 Oct 2024 05:19:10 -0400 (EDT)

branch: master
commit da048c6927020e71b7c3d0f39e0d37cdb3ae76ab
Author: Stephen Berman <stephen.berman@gmx.net>
Commit: Stephen Berman <stephen.berman@gmx.net>

    Fix case problem with 'sql-magic-go' (bug#73499)
    
    * lisp/progmodes/sql.el (sql-electric-stuff): Use :initialize and
    :set arguments to control presence of 'sql-magic-go' in
    'post-self-insert-hook'.
    (sql-interactive-mode-map): Remove key bindings for 'sql-magic-go'.
    (sql-magic-go): Reimplement as a non-interactive function
    restricted to 'sql-interactive-mode' and instead of using
    'self-insert-command' check value of 'last-command-event'.
---
 lisp/progmodes/sql.el | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index a0b350ce54f..13bf5e874b0 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -869,7 +869,13 @@ current input in the SQLi buffer to the process."
   :type '(choice (const :tag "Nothing" nil)
                 (const :tag "The semicolon `;'" semicolon)
                 (const :tag "The string `go' by itself" go))
-  :version "20.8")
+  :initialize #'custom-initialize-default
+  :set (lambda (symbol value)
+         (custom-set-default symbol value)
+         (if (eq value 'go)
+             (add-hook 'post-self-insert-hook 'sql-magic-go)
+           (remove-hook 'post-self-insert-hook 'sql-magic-go)))
+  :version "31.1")
 
 (defcustom sql-send-terminator nil
   "When non-nil, add a terminator to text sent to the SQL interpreter.
@@ -1359,8 +1365,6 @@ Based on `comint-mode-map'."
   :parent comint-mode-map
   "C-j"       #'sql-accumulate-and-indent
   "C-c C-w"   #'sql-copy-column
-  "O"         #'sql-magic-go
-  "o"         #'sql-magic-go
   ";"         #'sql-magic-semicolon
   "C-c C-l a" #'sql-list-all
   "C-c C-l t" #'sql-list-table)
@@ -3067,16 +3071,16 @@ displayed."
 
 ;;; Small functions
 
-(defun sql-magic-go (arg)
+(defun sql-magic-go ()
   "Insert \"o\" and call `comint-send-input'.
 `sql-electric-stuff' must be the symbol `go'."
-  (interactive "P")
-  (self-insert-command (prefix-numeric-value arg))
-  (if (and (equal sql-electric-stuff 'go)
-          (save-excursion
-            (comint-bol nil)
-            (looking-at "go\\b")))
-      (comint-send-input)))
+  (and (eq major-mode 'sql-interactive-mode)
+       (equal sql-electric-stuff 'go)
+       (or (eq last-command-event ?o) (eq last-command-event ?O))
+       (save-excursion
+        (comint-bol nil)
+        (looking-at "go\\b"))
+       (comint-send-input)))
 (put 'sql-magic-go 'delete-selection t)
 
 (defun sql-magic-semicolon (arg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]