GNU bug report logs -
#63438
30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
Previous Next
To reply to this bug, email your comments to 63438 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 07:11:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Daniel Fleischer <danflscr <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 11 May 2023 07:11:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Recipe for recreating:
- Add some abbrev definition with mixed capitalization, e.g. "abc"
should expand to "aBC".
- Enable abbrev-mode.
- Write "aBC".
- Upon pressing space, abbrev-mode converts it into "ABC".
There is a code section in `abbrev-insert' that explicitly capitalizes
the first letter; I'm sure it's there for a reason but I think the
behavior I showed is unexpected. As for the example "aBC", there are
real use cases, just to mention one "iPhone".
--
Daniel Fleischer
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 08:30:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 63438 <at> debbugs.gnu.org (full text, mbox):
severity 63438 wishlist
thanks
> From: Daniel Fleischer <danflscr <at> gmail.com>
> Date: Thu, 11 May 2023 10:10:40 +0300
>
> Recipe for recreating:
>
> - Add some abbrev definition with mixed capitalization, e.g. "abc"
> should expand to "aBC".
> - Enable abbrev-mode.
> - Write "aBC".
> - Upon pressing space, abbrev-mode converts it into "ABC".
>
> There is a code section in `abbrev-insert' that explicitly capitalizes
> the first letter; I'm sure it's there for a reason but I think the
> behavior I showed is unexpected. As for the example "aBC", there are
> real use cases, just to mention one "iPhone".
What you see is the documented behavior: by default, if the abbrev was
triggered by a word that has some upper-case letters in it, Emacs
capitalizes the first letter of every word in the expansion (you can
optionally set abbrev-all-caps non-nil to up-case all the letters in
the expansion). In your case, capitalizing the first letter of "aBC"
yields "ABC", and that's what you see.
What did you expect to happen instead?
Severity set to 'wishlist' from 'normal'
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 11 May 2023 08:30:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 09:11:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 63438 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii [2023-05-11 Thu 11:29] wrote:
> What you see is the documented behavior: by default, if the
> abbrev was
> triggered by a word that has some upper-case letters in it,
> Emacs
> capitalizes the first letter of every word in the expansion (you
> can
> optionally set abbrev-all-caps non-nil to up-case all the
> letters in
> the expansion). In your case, capitalizing the first letter of
> "aBC"
> yields "ABC", and that's what you see.
>
> What did you expect to happen instead?
I would expect *nothing* to happen; abbrev is key-value mapping;
you
write a key and it replaces it with a value. If you write a word
that
is not a key, you expect nothing to happen. In this case, the word
is
one of the values, and suddenly something happens, unexpectedly. I
know realize that words are compared with keys ignoring the case,
but
using the case in the expansion. Still, if a user writes a word
identical to one the abbrev "keys", I would expect abbrev to leave
it
as is.
Thanks,
Daniel
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 10:39:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 63438 <at> debbugs.gnu.org (full text, mbox):
> From: Daniel Fleischer <danflscr <at> gmail.com>
> Cc: 63438 <at> debbugs.gnu.org
> Date: Thu, 11 May 2023 12:00:39 +0300
>
>
> Eli Zaretskii [2023-05-11 Thu 11:29] wrote:
>
> > What did you expect to happen instead?
>
> I would expect *nothing* to happen; abbrev is key-value mapping; you
> write a key and it replaces it with a value. If you write a word
> that is not a key, you expect nothing to happen. In this case, the
> word is one of the values, and suddenly something happens,
> unexpectedly. I know realize that words are compared with keys
> ignoring the case, but using the case in the expansion. Still, if a
> user writes a word identical to one the abbrev "keys", I would
> expect abbrev to leave it as is.
I guess there's a place for a new defcustom, under which no
case-conversion will happen at abbrev expansion time, ever. Is that
what you want? That is, if you have an abbrev foo -> foobarical, then
typing "Foo" or "FOO" will produce a literal "foobarical", each and
every time?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 11:18:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 63438 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii [2023-05-11 Thu 13:39] wrote:
> I guess there's a place for a new defcustom, under which no
> case-conversion will happen at abbrev expansion time, ever. Is that
> what you want? That is, if you have an abbrev foo -> foobarical, then
> typing "Foo" or "FOO" will produce a literal "foobarical", each and
> every time?
I think even simpler: make sure abbrev insertion only works when the
input word is strictly (case sensitive) different than the expansion
word; leave everything else as is.
Example: with a rule like "foobarical -> fooBarical" then
Foobarical -> FooBarical (as is today)
FOOBARICAL -> FOOBARICAL (as is today)
but fooBarical -> fooBarical, because it's already what we want.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 11:29:01 GMT)
Full text and
rfc822 format available.
Message #22 received at submit <at> debbugs.gnu.org (full text, mbox):
Daniel Fleischer [2023-05-11 Thu 14:03] wrote:
> Example: with a rule like "foobarical -> fooBarical" then
>
> Foobarical -> FooBarical (as is today)
> FOOBARICAL -> FOOBARICAL (as is today)
>
> but fooBarical -> fooBarical, because it's already what we want.
Maybe some context: I think some people, at least me, use abbrev mode to
properly capitalize words with unique casing, needs not met by regular
capitalization rules. It means abbrev keys and values sometimes contain
the same word but with different casing. That's why I want nothing to
happen when the user writes a word with the right casing, making an
abbrev expansion unnecessary.
--
Daniel Fleischer
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 11:46:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 63438 <at> debbugs.gnu.org (full text, mbox):
Daniel Fleischer <danflscr <at> gmail.com> writes:
> Recipe for recreating:
>
> - Add some abbrev definition with mixed capitalization, e.g. "abc"
> should expand to "aBC".
> - Enable abbrev-mode.
> - Write "aBC".
> - Upon pressing space, abbrev-mode converts it into "ABC".
>
> There is a code section in `abbrev-insert' that explicitly capitalizes
> the first letter; I'm sure it's there for a reason but I think the
> behavior I showed is unexpected. As for the example "aBC", there are
> real use cases, just to mention one "iPhone".
The docstring of define-abbrev describes that abbreviations support a
property list of options. One of them is :case-fixed:
‘:case-fixed’: non-nil means that abbreviations are looked up without
case-folding, and the expansion is not capitalized/upcased.
Perhaps we should make the interactive commands set the :case-fixed
property, if the user wants.
Or to avoid case-folding globally:
(abbrev-table-put global-abbrev-table :case-fixed t)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 13:07:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 63438 <at> debbugs.gnu.org (full text, mbox):
> From: Daniel Fleischer <danflscr <at> gmail.com>
> Cc: 63438 <at> debbugs.gnu.org
> Date: Thu, 11 May 2023 14:03:43 +0300
>
> I think even simpler: make sure abbrev insertion only works when the
> input word is strictly (case sensitive) different than the expansion
> word; leave everything else as is.
>
> Example: with a rule like "foobarical -> fooBarical" then
>
> Foobarical -> FooBarical (as is today)
> FOOBARICAL -> FOOBARICAL (as is today)
>
> but fooBarical -> fooBarical, because it's already what we want.
Sorry, that's an incompatible change in long-standing behavior. We
cannot do that unconditionally. We _can_ make this opt-in behavior.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 13:09:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 63438 <at> debbugs.gnu.org (full text, mbox):
> From: Daniel Fleischer <danflscr <at> gmail.com>
> Date: Thu, 11 May 2023 14:28:12 +0300
>
> Maybe some context: I think some people, at least me, use abbrev mode to
> properly capitalize words with unique casing, needs not met by regular
> capitalization rules. It means abbrev keys and values sometimes contain
> the same word but with different casing. That's why I want nothing to
> happen when the user writes a word with the right casing, making an
> abbrev expansion unnecessary.
I agree that your use pattern has a place, and have nothing against
implementing it. I just don't think we can change to it
unconditionally. So a new user option is in order, or perhaps a new
value of abbrev-all-caps.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 14:19:02 GMT)
Full text and
rfc822 format available.
Message #34 received at submit <at> debbugs.gnu.org (full text, mbox):
Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:
> The docstring of define-abbrev describes that abbreviations support a
> property list of options. One of them is :case-fixed:
>
> ‘:case-fixed’: non-nil means that abbreviations are looked up without
> case-folding, and the expansion is not capitalized/upcased.
>
> Perhaps we should make the interactive commands set the :case-fixed
> property, if the user wants.
>
> Or to avoid case-folding globally:
>
> (abbrev-table-put global-abbrev-table :case-fixed t)
Thanks, using `:case-fixed t' on the word and/or table solves my issue.
Maybe this options should be better exposed during abbrev creation step,
as you said.
Daniel
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63438
; Package
emacs
.
(Thu, 11 May 2023 15:49:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 63438 <at> debbugs.gnu.org (full text, mbox):
> From: Daniel Fleischer <danflscr <at> gmail.com>
> Date: Thu, 11 May 2023 17:18:13 +0300
>
> > Or to avoid case-folding globally:
> >
> > (abbrev-table-put global-abbrev-table :case-fixed t)
>
> Thanks, using `:case-fixed t' on the word and/or table solves my issue.
>
> Maybe this options should be better exposed during abbrev creation step,
> as you said.
Yes, that will be a useful addition.
This bug report was last modified 2 years and 39 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.