GNU bug report logs - #52331
M-$ doesn't respect subword mode

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Mon, 6 Dec 2021 15:11:02 UTC

Severity: normal

To reply to this bug, email your comments to 52331 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52331; Package emacs. (Mon, 06 Dec 2021 15:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 06 Dec 2021 15:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: M-$ doesn't respect subword mode
Date: Mon, 6 Dec 2021 16:09:49 +0100
[Message part 1 (text/plain, inline)]
To reproduce:

$ emacs --batch --eval "(global-subword-mode)" --eval "(insert
\"getBanana\")" --eval "(ispell-word)"

Expected output:
...
BANANA is correct

Expected output:
...
Checking spelling of GETBANANA...
C-h or ? for more options; SPC to leave unchanged, Character to replace word

Naturally, this also happens in interactive use.

Paul
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52331; Package emacs. (Mon, 06 Dec 2021 16:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 52331 <at> debbugs.gnu.org (full text, mbox):

From: André A. Gomes <andremegafone <at> gmail.com>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 52331 <at> debbugs.gnu.org
Subject: Re: bug#52331: M-$ doesn't respect subword mode
Date: Mon, 06 Dec 2021 16:34:43 +0000
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> To reproduce:
>
> $ emacs --batch --eval "(global-subword-mode)" --eval "(insert
> \"getBanana\")" --eval "(ispell-word)"
>
> Expected output:
> ...
> BANANA is correct
>
> Expected output:
> ...
> Checking spelling of GETBANANA... 

Thank you for the bug report.

There's only one speller checker that handles camelCase (AFAIK), which
is aspell since 0.60.8.  If you're using it, then you can add the
following to your init file:

(setq ispell-extra-args '("--camel-case"))

However, and the Emacs maintainers will probably agree, the
responsibility of sending the "right" word to the ispell sub-process
should be on Emacs' side.  I.e., when subword-mode is on, there should
be a call to word-at-point before sending it to the spell checker.


-- 
André A. Gomes
"Free Thought, Free World"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52331; Package emacs. (Mon, 06 Dec 2021 16:47:01 GMT) Full text and rfc822 format available.

Message #11 received at 52331 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: André A. Gomes <andremegafone <at> gmail.com>
Cc: 52331 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
Subject: Re: bug#52331: M-$ doesn't respect subword mode
Date: Mon, 06 Dec 2021 18:46:24 +0200
> From: André A. Gomes <andremegafone <at> gmail.com>
> Date: Mon, 06 Dec 2021 16:34:43 +0000
> Cc: 52331 <at> debbugs.gnu.org
> 
> > $ emacs --batch --eval "(global-subword-mode)" --eval "(insert
> > \"getBanana\")" --eval "(ispell-word)"
> >
> > Expected output:
> > ...
> > BANANA is correct
> >
> > Expected output:
> > ...
> > Checking spelling of GETBANANA... 
> 
> Thank you for the bug report.
> 
> There's only one speller checker that handles camelCase (AFAIK), which
> is aspell since 0.60.8.  If you're using it, then you can add the
> following to your init file:
> 
> (setq ispell-extra-args '("--camel-case"))
> 
> However, and the Emacs maintainers will probably agree, the
> responsibility of sending the "right" word to the ispell sub-process
> should be on Emacs' side.  I.e., when subword-mode is on, there should
> be a call to word-at-point before sending it to the spell checker.

It's not that easy, unfortunately.  ispell.el has its own rules for
what is a word, and the rules aren't static, they are determined
dynamically by the definition of the dictionary. That's because of at
least 2 reasons: (1) the rules must match what the dictionary
considers a word, and (2) spell-checking is expected to work in
buffers that mix several languages, so the rules need to be sensitive
to the language of the dictionary and reject "words" whose letters are
not part of the language.

So perhaps a better approach is to teach subword-mode about the word
rules of ispell.el, not the other way around.  Patches welcome.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52331; Package emacs. (Mon, 06 Dec 2021 17:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 52331 <at> debbugs.gnu.org (full text, mbox):

From: André A. Gomes <andremegafone <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 52331 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
Subject: Re: bug#52331: M-$ doesn't respect subword mode
Date: Mon, 06 Dec 2021 17:21:28 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> However, and the Emacs maintainers will probably agree, the
>> responsibility of sending the "right" word to the ispell sub-process
>> should be on Emacs' side.  I.e., when subword-mode is on, there should
>> be a call to word-at-point before sending it to the spell checker.
>
> It's not that easy, unfortunately.  ispell.el has its own rules for
> what is a word, and the rules aren't static, they are determined
> dynamically by the definition of the dictionary. That's because of at
> least 2 reasons: (1) the rules must match what the dictionary
> considers a word, and (2) spell-checking is expected to work in
> buffers that mix several languages, so the rules need to be sensitive
> to the language of the dictionary and reject "words" whose letters are
> not part of the language.

Correct, my comment was over simplistic.  But I don't see where my
reasoning fails.  I can't think of an example where calling
word-at-point before the ispell rules kick in would make harm.  What am
I missing?

> So perhaps a better approach is to teach subword-mode about the word
> rules of ispell.el, not the other way around.  Patches welcome.

I don't see how this could help.  Care to expand a bit?


--
André A. Gomes
"Free Thought, Free World"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52331; Package emacs. (Mon, 06 Dec 2021 17:46:01 GMT) Full text and rfc822 format available.

Message #17 received at 52331 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: André A. Gomes <andremegafone <at> gmail.com>
Cc: 52331 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
Subject: Re: bug#52331: M-$ doesn't respect subword mode
Date: Mon, 06 Dec 2021 19:45:35 +0200
> From: André A. Gomes <andremegafone <at> gmail.com>
> Cc: pogonyshev <at> gmail.com,  52331 <at> debbugs.gnu.org
> Date: Mon, 06 Dec 2021 17:21:28 +0000
> 
> > It's not that easy, unfortunately.  ispell.el has its own rules for
> > what is a word, and the rules aren't static, they are determined
> > dynamically by the definition of the dictionary. That's because of at
> > least 2 reasons: (1) the rules must match what the dictionary
> > considers a word, and (2) spell-checking is expected to work in
> > buffers that mix several languages, so the rules need to be sensitive
> > to the language of the dictionary and reject "words" whose letters are
> > not part of the language.
> 
> Correct, my comment was over simplistic.  But I don't see where my
> reasoning fails.  I can't think of an example where calling
> word-at-point before the ispell rules kick in would make harm.  What am
> I missing?

See ispell-get-word, I think it will explain what I meant.  This is
what ispell.el is using to determine what is a "word".

> > So perhaps a better approach is to teach subword-mode about the word
> > rules of ispell.el, not the other way around.  Patches welcome.
> 
> I don't see how this could help.  Care to expand a bit?

subword-mode uses regular expressions to find where the word begins
and ends.  Either use different regexps (derived from what ispell.el
uses) when spell-checking, or make ispell.el define its own
subword-forward/backward-functions for subword-mode to use instead of
its defaults.




This bug report was last modified 2 years and 134 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.