GNU bug report logs - #20543
24.5; <SPC> in ispell-buffer accepts spelling for the whole line

Previous Next

Package: emacs;

Reported by: Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>

Date: Sun, 10 May 2015 18:40:04 UTC

Severity: normal

Found in version 24.5

To reply to this bug, email your comments to 20543 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#20543; Package emacs. (Sun, 10 May 2015 18:40:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 10 May 2015 18:40:05 GMT) Full text and rfc822 format available.

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

From: Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 24.5; <SPC> in ispell-buffer accepts spelling for the whole line
Date: Sun, 10 May 2015 18:05:25 +0200
Using GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.2)--but
this applies to former Emacs versions also--I found the following puzzling
behavior of ispell-buffer:

If a suspicious word is accepted once by pressing <SPC> in an interactive
ispell-buffer session, all further occurrences of the same spelling on the
same line are skipped, i.e. considered as accepted too.

Here is an example:

Open an Emacs 24.5 session (it is the same with Emacs 24.4) by

   LC_ALL=C emacs -Q

and enter the following line (with or without newline does not matter) in the
*scratch* buffer:

   The term charset is short for charset.

Assume that the last word is a typo that should read "character set". Now
change the dictionary to american and run ispell-buffer. The first occurrence
of "charset" gets highlighted, but since it is correct here, we use <SPC> to
accept it once and proceed. But oops... the spell-check finishes immediately
without giving us the chance to correct the second occurrence of "charset" in
that line.

This finding was shortly discussed in help-gnu-emacs
(http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/threads.html#00134)
and it was Eli Zaretskii who indicated that there is the following comment in
line 3651 of emacs-24.5/lisp/textmodes/ispell.el:

   ;; Do not recheck accepted word on this line.

This suggests that there might be a reason for that behavior. If this is
true, what is it?

Apart from that, I can not imagine why such a behavior might be desirable.

Juergen

 		 	   		  



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20543; Package emacs. (Fri, 08 Apr 2016 18:04:01 GMT) Full text and rfc822 format available.

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

From: Marcin Borkowski <mbork <at> mbork.pl>
To: Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>
Cc: 20543 <at> debbugs.gnu.org
Subject: Re: bug#20543: 24.5;
 <SPC> in ispell-buffer accepts spelling for the whole line
Date: Fri, 08 Apr 2016 20:02:57 +0200
On 2015-05-10, at 18:05, Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com> wrote:

> Using GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.2)--but
> this applies to former Emacs versions also--I found the following puzzling
> behavior of ispell-buffer:
>
> If a suspicious word is accepted once by pressing <SPC> in an interactive
> ispell-buffer session, all further occurrences of the same spelling on the
> same line are skipped, i.e. considered as accepted too.
>
> Here is an example:
>
> Open an Emacs 24.5 session (it is the same with Emacs 24.4) by
>
>    LC_ALL=C emacs -Q
>
> and enter the following line (with or without newline does not matter) in the
> *scratch* buffer:
>
>    The term charset is short for charset.
>
> Assume that the last word is a typo that should read "character set". Now
> change the dictionary to american and run ispell-buffer. The first occurrence
> of "charset" gets highlighted, but since it is correct here, we use <SPC> to
> accept it once and proceed. But oops... the spell-check finishes immediately
> without giving us the chance to correct the second occurrence of "charset" in
> that line.
>
> This finding was shortly discussed in help-gnu-emacs
> (http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/threads.html#00134)
> and it was Eli Zaretskii who indicated that there is the following comment in
> line 3651 of emacs-24.5/lisp/textmodes/ispell.el:
>
>    ;; Do not recheck accepted word on this line.
>
> This suggests that there might be a reason for that behavior. If this is
> true, what is it?

I've just seen this report.  I'm also very curious about that reason.

> Apart from that, I can not imagine why such a behavior might be desirable.
>
> Juergen


-- 
Marcin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20543; Package emacs. (Fri, 28 May 2021 00:12:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Marcin Borkowski <mbork <at> mbork.pl>
Cc: Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>,
 20543 <at> debbugs.gnu.org
Subject: Re: bug#20543: 24.5; <SPC> in ispell-buffer accepts spelling for
 the whole line
Date: Fri, 28 May 2021 02:10:50 +0200
Marcin Borkowski <mbork <at> mbork.pl> writes:

>> line 3651 of emacs-24.5/lisp/textmodes/ispell.el:
>>
>>    ;; Do not recheck accepted word on this line.

I think there's two meanings of "accepted" in that function -- one is
hitting SPC, and the other is when the word is already in the dictionary.

>> This suggests that there might be a reason for that behavior. If this is
>> true, what is it?
>
> I've just seen this report.  I'm also very curious about that reason.

It seems nonsensical to me -- just because you accept the word once on a
line, it might not be acceptable in the next instance.  So I've changed
this in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 28 May 2021 00:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 20543 <at> debbugs.gnu.org and Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 28 May 2021 00:12:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20543; Package emacs. (Fri, 28 May 2021 06:26:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: juergen_hartmann_ <at> hotmail.com, mbork <at> mbork.pl, 20543 <at> debbugs.gnu.org
Subject: Re: bug#20543: 24.5;
 <SPC> in ispell-buffer accepts spelling for the whole line
Date: Fri, 28 May 2021 09:25:16 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Fri, 28 May 2021 02:10:50 +0200
> Cc: Jürgen Hartmann <juergen_hartmann_ <at> hotmail.com>,
>  20543 <at> debbugs.gnu.org
> 
> Marcin Borkowski <mbork <at> mbork.pl> writes:
> 
> >> line 3651 of emacs-24.5/lisp/textmodes/ispell.el:
> >>
> >>    ;; Do not recheck accepted word on this line.
> 
> I think there's two meanings of "accepted" in that function -- one is
> hitting SPC, and the other is when the word is already in the dictionary.

No, the two meanings of "accepted" here are:

  . the user hits SPC to "leave the word unchanged"
  . the user hits 'a' to "accept the word for this session"

See below.

> >> This suggests that there might be a reason for that behavior. If this is
> >> true, what is it?
> >
> > I've just seen this report.  I'm also very curious about that reason.
> 
> It seems nonsensical to me -- just because you accept the word once on a
> line, it might not be acceptable in the next instance.  So I've changed
> this in Emacs 28.

This is wrong, because now 'a' doesn't work as expected.

Recipe:

  . emacs -Q
  . type into *scratch*:
    foobarical something foobarical something else
  . M-x ispell-buffer
  . a (to "accept" the first "foobarical")
  . observe Emacs stopping on the next "foobarical", instead of
    skipping it, as expected

The problem is that replace == nil means two things: either the user
pressed SPC or the user pressed 'a' (but NOT 'A').  However, the
"don't check the same line" logic should only be applied for 'a', not
for SPC.  So what we need to fix this is IMO adding a way to
distinguish between 'a' and SPC (perhaps by looking at
ispell-buffer-session-localwords?).

Note that the comments in ispell-process-line wrt the meaning of the
value of 'replace' are AFAICT inaccurate:

            ;; Insert correction if needed.
            (cond
             ((equal 0 replace)         ; INSERT
              (if (equal 0 replace)     ; BUFFER-LOCAL DICT ADD
                  (ispell-add-per-file-word-list (car poss)))
              ;; Do not recheck accepted word on this line.
              (setq accept-list (cons (car poss) accept-list)))
             (t
              ;; The user hit SPC, so accept this word, but keep
              ;; checking the rest of the line.
              (unless replace
                (setq accepted t)
                (setq replace (list (buffer-substring-no-properties
                                     (point) (+ word-len (point))))))

(This is also inelegant, as it tests 'replace' for being zero twice.)

Contrary to the comment, as can be seen from ispell-command-loop, the
value of 'replace' can be:

  nil if user pressed 'i' or 'u'
  nil if user pressed 'a'
  nil if user typed SPC
  0 if user pressed 'A'
  replacement word if user typed 'r' or 'R'
  t if the spelling session should end

So the above 'cond' is incorrect and should be fixed.

In any case, the change, as it is, is for the worse, because 'a' is by
far more important than SPC during spell-checking of technical text,
where there are many acronyms and jargon words unknown to the
dictionary.  If we don't have good ideas how to fix the SPC case, we
should revert the change and add a FIXME.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20543; Package emacs. (Sat, 29 May 2021 02:09:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: juergen_hartmann_ <at> hotmail.com, mbork <at> mbork.pl, 20543 <at> debbugs.gnu.org
Subject: Re: bug#20543: 24.5; <SPC> in ispell-buffer accepts spelling for
 the whole line
Date: Sat, 29 May 2021 04:08:47 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> If we don't have good ideas how to fix the SPC case, we
> should revert the change and add a FIXME.

Right; I'll revert and reopen this bug report.  Fixing the problem
should be possible, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug No longer marked as fixed in versions 28.1 and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 May 2021 02:10:02 GMT) Full text and rfc822 format available.

Removed tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 29 May 2021 02:10:02 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 25 days ago.

Previous Next


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