From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73499: 31.0.50; sql-interactive-mode problem with package caps-lock-mode Date: Thu, 26 Sep 2024 14:44:12 +0200 Message-ID: <87tte2oa8z.fsf@gmx.net> Reply-To: Stephen Berman Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5794"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 73499@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 26 14:45:13 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1stnrr-0001FP-2e for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Sep 2024 14:45:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stnrS-0008DU-7V; Thu, 26 Sep 2024 08:44:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stnrI-0008D4-Vj for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 08:44:39 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1stnrH-00075H-Qs for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 08:44:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=qxLn0twivd2/16xaH1UjIQa2nfyL5A//fkJJW2QzNKU=; b=ZvJs4z9240nYG5c388B8B5QLhyi5Tcx6AiH/npscWd2eloHtH3XDs67zDspGqcTv6z47AvXAbFj6cUTvJwpTkNWFUlKvBeJzVLu1jaEzHpmdIqKdbN6Z+XqplfZIfftbcTHwUr3Rs3BMVx57JD0+P7IJaKEKCk4GsNX+AV6AZUuslltPkmQMOfu9fufPAcuU9D59GRtrJpwC/+tGnLl4aCi+3y5M3AFZJrduLJwYREKWw5GkgxCdWc0rRhXn6VJpu7wRYQUow5cAFahtWzV6eX6XYwGbh0fzahNaD/HIMSRB+rPGG2x27M4RBI0VVjL8yPOy/0yOSYnxQwqWm5636Q==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stnrh-0004u5-Uv for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 08:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Sep 2024 12:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73499 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172735469618811 (code B ref -1); Thu, 26 Sep 2024 12:45:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Sep 2024 12:44:56 +0000 Original-Received: from localhost ([127.0.0.1]:60312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stnrb-0004tL-NV for submit@debbugs.gnu.org; Thu, 26 Sep 2024 08:44:56 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:32924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stnrZ-0004t8-OP for submit@debbugs.gnu.org; Thu, 26 Sep 2024 08:44:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stnr6-0008CU-FR for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 08:44:26 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stnr2-00073W-6V for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 08:44:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1727354653; x=1727959453; i=stephen.berman@gmx.net; bh=qxLn0twivd2/16xaH1UjIQa2nfyL5A//fkJJW2QzNKU=; h=X-UI-Sender-Class:From:To:Subject:Date:Message-ID:MIME-Version: Content-Type:cc:content-transfer-encoding:content-type:date:from: message-id:mime-version:reply-to:subject:to; b=lwPT5WHLH+kdSRScsAfnKtS+tIa/3aJ/745DPMZa24yzFfHT3Huii/PYgmoNv6QC 3BzzeY/ZVbLLdfWI6eiPcVhl6h12sMk6JA5BDigu/2l8Igf9AwEBeqOlUCWR668lx 7HKqEEdhmdPohR8XBAQWYKQCfKGJrr4aS1yT9ntUVSiQMK81T29JkDvJjhr3iENte u8uyoosisQ71XzpkYaz9/d/se56hCT6ilyueTJ/iIyezwJYjHt9NO/qLDE2f1pa+D PMiwULMO5SUEuEGmoeKKYrZbrIvPcgW7LrQgol+YIu1Z6z307fpcSB9OJAR+p9Vob 0bNiZV03/W6STRh6Cg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.50.241]) by mail.gmx.net (mrgm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DZvDroL4Jwh/jAU6LykKWLHFdxiz/QtSAZq1VlLDLQ6 WVGmvd6Kvt2/5UIcGUHHJJKydhvJ6ghJm6STvUSGSsOC6kB91Fp4+tIjeW5vTQHb3Ze7Zvx8 Received-SPF: pass client-ip=212.227.15.18; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292459 Archived-At: --=-=-= Content-Type: text/plain 0. Install the GNU ELPA package caps-lock. 1. emacs -Q 2. M-x package-initialize 3. Start an SQL inferior process, e.g. with `M-x sql-sqlite RET test RET'. 4. In the *SQL: SQLite* buffer type `M-x caps-lock-mode' and at sqlite> prompt type "select * from". => The typed text appears as this: "SELECT * FRoM", with a lowercase "o" instead of an uppercase "O". This is because sql-interactive-mode-map binds both "o" and "O" to the command `sql-magic-go', but caps-lock-mode changes case only if the last key event either invoked `self-insert-command' or `isearch-printing-char' or if the command it invoked remaps self-insert-command, and since neither is the case here, no case change occurs. (You can of course enter "O" by typing S-o, but caps-lock-mode is supposed to obviate the need to do that.) This problem also happens with PostgreSQL and presumably other SQL interpreters supported by sql.el (but I have only tested SQLite and PostgreSQL). I have found two ways to fix this problem. One is simply to add `sql-magic-go' to the list `caps-lock-commands'. In caps-lock.el this is a defvar with the value '(self-insert-command isearch-printing-char). Instead of just changing this value in the source code, I think it would be better to make the variable a defcustom, since many packages bind letter keys to commands other than `self-insert-command' but may nevertheless want to change the case of these letters when caps-lock-mode is enabled. So it would be up to the user to add `sql-magic-go' to the value. Here's a patch that allows this (I don't have a local clone of the GNU ELPA repo, so it's just a plain diff): --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: caps-lock patch Content-Transfer-Encoding: quoted-printable diff -c /home/steve/.emacs.d/elpa/caps-lock-1.0/caps-lock.el_orig /home/st= eve/.emacs.d/elpa/caps-lock-1.0/caps-lock.el *** /home/steve/.emacs.d/elpa/caps-lock-1.0/caps-lock.el_orig 2024-06-27 1= 1:21:19.635674501 +0200 =2D-- /home/steve/.emacs.d/elpa/caps-lock-1.0/caps-lock.el 2024-09-26 11:1= 0:54.443573430 +0200 *************** *** 22,35 **** ;;; Code: ! (defvar caps-lock-commands ! '(self-insert-command isearch-printing-char) ! "List of commands that are subject to `caps-lock-mode'.") ;;;###autoload (define-minor-mode caps-lock-mode "Make self-inserting keys invert the capitalization." ! :global t (if caps-lock-mode (add-hook 'pre-command-hook #'caps-lock--pch) (remove-hook 'pre-command-hook #'caps-lock--pch))) =2D-- 22,38 ---- ;;; Code: ! (defcustom caps-lock-commands '(self-insert-command isearch-printing-cha= r) ! "List of commands that are subject to `caps-lock-mode'." ! :type '(repeat (restricted-sexp :match-alternatives (commandp null))) ! ;; FIXME: which group, or both or neither? (Fix below too?) ! ;; :group 'editing ! :group 'convenience) ;;;###autoload (define-minor-mode caps-lock-mode "Make self-inserting keys invert the capitalization." ! :global t :group 'convenience (if caps-lock-mode (add-hook 'pre-command-hook #'caps-lock--pch) (remove-hook 'pre-command-hook #'caps-lock--pch))) Diff finished. Thu Sep 26 12:05:47 2024 --=-=-= Content-Type: text/plain The alternative fix is to change the implemention of `sql-magic-go' so it doesn't interfere with caps-lock-mode; this would absolve the user from the responsability of customizing which commands trigger case change, but requires more invasive changes to sql.el (at least I haven't come up with a simpler change), specifically, (i) removing the bindings of "o" and "O", (ii) making `sql-magic-go' a function instead of a command, which checks if the last keyboard input was either of these letters and if so, does what `sql-magic-go' is supposed to do, and (iii) adding `sql-magic-go' to `post-self-insert-hook' if `sql-electric-stuff' is customized to give the string "go" special handling. Here's the patch: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: sql-magic-go patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 5273ba2bee1..f39eee1fb77 100644 =2D-- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -869,7 +869,13 @@ sql-electric-stuff :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 @@ sql-interactive-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,15 @@ sql-end-of-statement ;;; 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 (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) --=-=-= Content-Type: text/plain In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2) of 2024-09-22 built on strobelfssd Repository revision: 3fb966dc6392e1908304a1b6fe481da9f670cfbb Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101013 System Description: Linux From Scratch r12.2-5-systemd Configured using: 'configure -C 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt6/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB --=-=-=--