* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
@ 2023-05-11 7:10 Daniel Fleischer
2023-05-11 8:29 ` Eli Zaretskii
2023-05-11 11:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 11+ messages in thread
From: Daniel Fleischer @ 2023-05-11 7:10 UTC (permalink / raw)
To: 63438
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 7:10 bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words Daniel Fleischer
@ 2023-05-11 8:29 ` Eli Zaretskii
2023-05-11 9:00 ` Daniel Fleischer
2023-05-11 11:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-11 8:29 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
severity 63438 wishlist
thanks
> From: Daniel Fleischer <danflscr@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?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 8:29 ` Eli Zaretskii
@ 2023-05-11 9:00 ` Daniel Fleischer
2023-05-11 10:39 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Fleischer @ 2023-05-11 9:00 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 63438
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 9:00 ` Daniel Fleischer
@ 2023-05-11 10:39 ` Eli Zaretskii
2023-05-11 11:03 ` Daniel Fleischer
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-11 10:39 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
> From: Daniel Fleischer <danflscr@gmail.com>
> Cc: 63438@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?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 10:39 ` Eli Zaretskii
@ 2023-05-11 11:03 ` Daniel Fleischer
2023-05-11 11:28 ` Daniel Fleischer
2023-05-11 13:07 ` Eli Zaretskii
0 siblings, 2 replies; 11+ messages in thread
From: Daniel Fleischer @ 2023-05-11 11:03 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 63438
[-- Attachment #1: Type: text/plain, Size: 716 bytes --]
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 11:03 ` Daniel Fleischer
@ 2023-05-11 11:28 ` Daniel Fleischer
2023-05-11 13:09 ` Eli Zaretskii
2023-05-11 13:07 ` Eli Zaretskii
1 sibling, 1 reply; 11+ messages in thread
From: Daniel Fleischer @ 2023-05-11 11:28 UTC (permalink / raw)
To: 63438
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 7:10 bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words Daniel Fleischer
2023-05-11 8:29 ` Eli Zaretskii
@ 2023-05-11 11:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 14:18 ` Daniel Fleischer
1 sibling, 1 reply; 11+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-11 11:45 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
Daniel Fleischer <danflscr@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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 11:03 ` Daniel Fleischer
2023-05-11 11:28 ` Daniel Fleischer
@ 2023-05-11 13:07 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-11 13:07 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
> From: Daniel Fleischer <danflscr@gmail.com>
> Cc: 63438@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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 11:28 ` Daniel Fleischer
@ 2023-05-11 13:09 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-11 13:09 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
> From: Daniel Fleischer <danflscr@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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 11:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-05-11 14:18 ` Daniel Fleischer
2023-05-11 15:49 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Fleischer @ 2023-05-11 14:18 UTC (permalink / raw)
To: 63438
Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words
2023-05-11 14:18 ` Daniel Fleischer
@ 2023-05-11 15:49 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2023-05-11 15:49 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: 63438
> From: Daniel Fleischer <danflscr@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.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-05-11 15:49 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-11 7:10 bug#63438: 30.0.50; abbrev mode wrongly capitalizes with mixed capitalized words Daniel Fleischer
2023-05-11 8:29 ` Eli Zaretskii
2023-05-11 9:00 ` Daniel Fleischer
2023-05-11 10:39 ` Eli Zaretskii
2023-05-11 11:03 ` Daniel Fleischer
2023-05-11 11:28 ` Daniel Fleischer
2023-05-11 13:09 ` Eli Zaretskii
2023-05-11 13:07 ` Eli Zaretskii
2023-05-11 11:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 14:18 ` Daniel Fleischer
2023-05-11 15:49 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.