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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73499 in the body.
You can then email your comments to 73499 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Thu, 26 Sep 2024 12:45:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stephen Berman <stephen.berman <at> gmx.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 26 Sep 2024 12:45:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (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 2 (text/x-patch, attachment)]
[Message part 3 (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 4 (text/x-patch, attachment)]
[Message part 5 (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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Sat, 28 Sep 2024 11:16:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 73499 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 26 Sep 2024 14:44:12 +0200
> From: Stephen Berman via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> 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):
>
>
> 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:
Stefan, Andrea, Stefan: any opinions on which way is better?
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Sat, 28 Sep 2024 15:04:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 73499 <at> debbugs.gnu.org (full text, mbox):
> Stefan, Andrea, Stefan: any opinions on which way is better?
My vote is clearly for `post-self-insert-hook`.
I added this hook specifically to solve these kinds of problems.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Sun, 29 Sep 2024 20:40:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 73499 <at> debbugs.gnu.org (full text, mbox):
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`.
+1, it seems like the cleaner option, and will fix this not only for
`caps-lock-mode' but other similar modes as well.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Tue, 01 Oct 2024 18:45:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 73499 <at> debbugs.gnu.org (full text, mbox):
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
Andrea
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Sat, 05 Oct 2024 10:23:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 73499 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73499
; Package
emacs
.
(Sat, 05 Oct 2024 20:05:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 73499 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
Steve Berman
[Message part 2 (text/x-patch, attachment)]
Reply sent
to
Stephen Berman <stephen.berman <at> gmx.net>
:
You have taken responsibility.
(Sun, 13 Oct 2024 09:22:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Stephen Berman <stephen.berman <at> gmx.net>
:
bug acknowledged by developer.
(Sun, 13 Oct 2024 09:22:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 73499-done <at> debbugs.gnu.org (full text, mbox):
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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 10 Nov 2024 12:24:14 GMT)
Full text and
rfc822 format available.
This bug report was last modified 271 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.