GNU bug report logs -
#73499
31.0.50; sql-interactive-mode problem with package caps-lock-mode
Previous Next
Reported by: Stephen Berman <stephen.berman <at> gmx.net>
Date: Thu, 26 Sep 2024 12:45:01 UTC
Severity: normal
Found in version 31.0.50
Done: Stephen Berman <stephen.berman <at> gmx.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#73499: 31.0.50; sql-interactive-mode problem with package caps-lock-mode
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 73499 <at> debbugs.gnu.org.
--
73499: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73499
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
On Sat, 05 Oct 2024 22:03:59 +0200 Stephen Berman <stephen.berman <at> gmx.net> wrote:
> On Sat, 05 Oct 2024 13:22:02 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>>> From: Andrea Corallo <acorallo <at> gnu.org>
>>> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stephen Berman <stephen.berman <at> gmx.net>,
>>> Stefan Kangas <stefankangas <at> gmail.com>, 73499 <at> debbugs.gnu.org
>>> Date: Tue, 01 Oct 2024 14:44:13 -0400
>>>
>>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>>>
>>> >> Stefan, Andrea, Stefan: any opinions on which way is better?
>>> >
>>> > My vote is clearly for `post-self-insert-hook`.
>>>
>>> Same
>>
>> OK, so Stephen, please do it that way, and thanks.
>
> Sure; however, my testing of the patch before posting it was inadequate,
> and the patch needs to be amended. As is it now, if you customize
> sql-electric-stuff to use sql-magic-go and then type "go" at the prompt
> in a comint-derived mode other than sql-interactive-mode, that wrongly
> calls comint-send-input. E.g. in shell-mode, this results in the shell
> output "bash: go: command not found". And in an arbitary buffer not
> derived from comint-mode, typing "go" at BOB causes a ding and shows the
> message "Current buffer has no process". These problems are because the
> patch adds sql-magic-go to post-self-insert-hook globally; since this is
> done when customizing sql-electric-stuff, the current buffer need not
> (and probably won't) be in sql-interactive-mode, so the hook can't be
> added locally. AFAICS the simplest fix is to check (eq major-mode
> 'sql-interactive-mode) in sql-magic-go, as in the attached patch. If
> there's no objection to this, then I'll go ahead and commit the amended
> patch to master.
It's been over a week with no objection, so I pushed the amended patch
to master as commit da048c69270 and am closing the bug.
Steve Berman
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
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):
[Message part 5 (text/x-patch, attachment)]
[Message part 6 (text/plain, inline)]
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:
[Message part 7 (text/x-patch, attachment)]
[Message part 8 (text/plain, inline)]
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
This bug report was last modified 273 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.