all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#52331: M-$ doesn't respect subword mode
@ 2021-12-06 15:09 Paul Pogonyshev
  2021-12-06 16:34 ` André A. Gomes
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Pogonyshev @ 2021-12-06 15:09 UTC (permalink / raw)
  To: 52331

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 930 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#52331: M-$ doesn't respect subword mode
  2021-12-06 15:09 bug#52331: M-$ doesn't respect subword mode Paul Pogonyshev
@ 2021-12-06 16:34 ` André A. Gomes
  2021-12-06 16:46   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: André A. Gomes @ 2021-12-06 16:34 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 52331

Paul Pogonyshev <pogonyshev@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"





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#52331: M-$ doesn't respect subword mode
  2021-12-06 16:34 ` André A. Gomes
@ 2021-12-06 16:46   ` Eli Zaretskii
  2021-12-06 17:21     ` André A. Gomes
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-12-06 16:46 UTC (permalink / raw)
  To: André A. Gomes; +Cc: 52331, pogonyshev

> From: André A. Gomes <andremegafone@gmail.com>
> Date: Mon, 06 Dec 2021 16:34:43 +0000
> Cc: 52331@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#52331: M-$ doesn't respect subword mode
  2021-12-06 16:46   ` Eli Zaretskii
@ 2021-12-06 17:21     ` André A. Gomes
  2021-12-06 17:45       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: André A. Gomes @ 2021-12-06 17:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52331, pogonyshev

Eli Zaretskii <eliz@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"





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#52331: M-$ doesn't respect subword mode
  2021-12-06 17:21     ` André A. Gomes
@ 2021-12-06 17:45       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2021-12-06 17:45 UTC (permalink / raw)
  To: André A. Gomes; +Cc: 52331, pogonyshev

> From: André A. Gomes <andremegafone@gmail.com>
> Cc: pogonyshev@gmail.com,  52331@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-06 17:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-06 15:09 bug#52331: M-$ doesn't respect subword mode Paul Pogonyshev
2021-12-06 16:34 ` André A. Gomes
2021-12-06 16:46   ` Eli Zaretskii
2021-12-06 17:21     ` André A. Gomes
2021-12-06 17:45       ` 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.