From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Artem Boldarev Newsgroups: gmane.emacs.bugs Subject: bug#32280: 26.1; FLYSPELL-BUFFER sometimes misbehaves for some input in a large enough buffer Date: Tue, 7 Aug 2018 13:56:58 +0300 Message-ID: <678a1017-47c5-f74f-3b1b-2a15485b6a2d@gmail.com> References: <992503e5-5f88-30c7-e9b9-fe0a884d2e52@gmail.com> <20180727160048.GA30487@agmartin.aq.upm.es> <20180730132033.GA1182@agmartin.aq.upm.es> <3d036b32-01df-6595-a023-3fc243613813@gmail.com> <20180730164303.GA12241@agmartin.aq.upm.es> <41d68d6b-a687-30c1-818f-57659d7ec6c5@gmail.com> <83h8katnt7.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1533639390 17240 195.159.176.226 (7 Aug 2018 10:56:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2018 10:56:30 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cc: 32280@debbugs.gnu.org, agustin6martin@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 12:56:25 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmzf6-0004MD-13 for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2018 12:56:24 +0200 Original-Received: from localhost ([::1]:38377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzhC-00075F-Ek for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2018 06:58:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzgz-00071o-Rf for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 06:58:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzgh-000063-Ey for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 06:58:21 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzgg-00005Q-QY for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 06:58:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fmzgg-0007cy-BV for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 06:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Artem Boldarev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Aug 2018 10:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32280 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32280-submit@debbugs.gnu.org id=B32280.153363943429259 (code B ref 32280); Tue, 07 Aug 2018 10:58:02 +0000 Original-Received: (at 32280) by debbugs.gnu.org; 7 Aug 2018 10:57:14 +0000 Original-Received: from localhost ([127.0.0.1]:43195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmzfu-0007bq-6f for submit@debbugs.gnu.org; Tue, 07 Aug 2018 06:57:14 -0400 Original-Received: from mail-lj1-f196.google.com ([209.85.208.196]:38639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmzfs-0007ba-9B for 32280@debbugs.gnu.org; Tue, 07 Aug 2018 06:57:12 -0400 Original-Received: by mail-lj1-f196.google.com with SMTP id p6-v6so13079189ljc.5 for <32280@debbugs.gnu.org>; Tue, 07 Aug 2018 03:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=sMFONIC6TIXBoX/q6X0EseeJcINKnJpwlUp8v2FEIXs=; b=a/QkNanVkIQq5etOTmLcpPZ/UQvXLNSX4W17qdbVRo6piA/pthobYRjiOSFQXZlmC4 D/6A8eOk8hcVzv2l4NvO2yRGnNXqJLyTQg38Q0BsqQpTwFgFTffcU0xcv1HhHDiWs+ck 0KbwRdw75y4PC4855sC0wmn16lTHuikiNUdL9km8cJfmsbd9m107krTQGX45w+qWrc7r C/LKo8HMyYd55X5Ig9RDFrtGqwlZ3ZWsnBOfYXLKpvqVLOaT6vADVuSXHNUbaWuWgqqX S9T43EoGFIHaXKq0hhnuw+jLmaq9oZ2J6wCE/pmuL+a3d75BDXvZjAYy0JpXm6h4OCkB wk/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=sMFONIC6TIXBoX/q6X0EseeJcINKnJpwlUp8v2FEIXs=; b=anXijv0xYkYhWHfs6WzysijwVBYRhLxzcidLM1fZ1IakV7LDzfFlyOqQHo3N513Akj hQEIz4xMZs+6pNffQslfDyX1i1fc49bZjNfLZKZxvH9/E+O4KEMdvFDigKOZkGpA/xC0 M2PP4MUizhLMKGAwuLFLR41F3/RZJRjWQUQxdhttjXpJgPhJGt46MSsgDj4rhTnW5oqy D8eMTUC4bDkd2tM9UT3m71o6Zk/XpRTFeDtnG6nCoAUlglU17+7RTbT2yqL5EPAJfPs7 nEeLxtPZ8TuaNW/+o6wG1M8IPTLlsUgMtW5VuZKV89iubSkZTm9cHKqtw/UhRde5YJYF DW/A== X-Gm-Message-State: AOUpUlEIW5Ly1MlkglRSBiPUTj8KRYNXdddrHFwER++RqyXWQZn4SPSt WKU7iL9yX1wk0bUlBslW8xuKM7Ze X-Google-Smtp-Source: AAOMgpcpo2x4PDcSDoJzjExaEdFZafsA2TNlkFXwpBa/X3NOaHes25TjOYQGvry+RL23JyePxJkb8A== X-Received: by 2002:a2e:40ca:: with SMTP id r71-v6mr14895107lje.41.1533639425979; Tue, 07 Aug 2018 03:57:05 -0700 (PDT) Original-Received: from ?IPv6:2a01:d0:dec0:0:9411:9497:48c0:1f49? ([2a01:d0:dec0:0:9411:9497:48c0:1f49]) by smtp.gmail.com with ESMTPSA id b22-v6sm186476ljj.93.2018.08.07.03.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:57:00 -0700 (PDT) In-Reply-To: <83h8katnt7.fsf@gnu.org> Content-Language: ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149309 Archived-At: Hi, Thanks, Eli! I have tried the proposed patch, and it seems to solve the problem. Thanks to everyone who have helped to track down the problem. By the way, are there any chances to see these changes incorporated into Emacs 26.2? Kind regards, Artem >> I have tried to do as you suggested. The result is the same as in my >> previous letter. > And now I understand why. The problem is not with comparing the > length of the misspelled word, the problem is with this part of > flyspell-external-point-words: > > ;; Iterate on string search until string is found as word, > ;; not as substring. > (while keep > (if (search-forward word > flyspell-large-region-end t) > (let* ((found-list > (save-excursion > ;; Move back into the match > ;; so flyspell-get-word will find it. > (forward-char -1) > (flyspell-get-word))) <<<<<<<<<<<<<<<<<<<<<< > (found (car found-list)) > (found-length (length found)) > (misspell-length (length word))) > > When the misspelled word doesn't match CASECHARS, the call to > flyspell-get-word will find an entirely different word than the one > which was originally found as misspelled: it will find the first word > before point that matches CASECHARS. In your case, since the > misspelled words were in English, flyspell-get-word will find the > first Cyrillic word before point. From there on, the logic of the > code in flyspell-external-point-words completely breaks down, and > yields results that are more-or-less random. > > IOW, the assumption of the current logic in > flyspell-external-point-words is that the misspelled word is from the > same language that is supported by the current dictionary, and in your > case this assumption is false. This is why the problem disappeared as > soon as you added Latin alphabetic characters to CASECHARS. > > So please try this patch for flyspell.el, it should fix your problem > with the original setup of ru_RU (it also fixes an unrelated wrong > assumption which goes back to the days when the spell-checking program > could only be either Ispell or Aspell): > > diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el > index 5726bd8..4d7a189 100644 > --- a/lisp/textmodes/flyspell.el > +++ b/lisp/textmodes/flyspell.el > @@ -1420,10 +1420,20 @@ flyspell-external-point-words > The list of incorrect words should be in `flyspell-external-ispell-buffer'. > \(We finish by killing that buffer and setting the variable to nil.) > The buffer to mark them in is `flyspell-large-region-buffer'." > - (let (words-not-found > - (ispell-otherchars (ispell-get-otherchars)) > - (buffer-scan-pos flyspell-large-region-beg) > - case-fold-search) > + (let* (words-not-found > + (flyspell-casechars (flyspell-get-casechars)) > + (ispell-otherchars (ispell-get-otherchars)) > + (ispell-many-otherchars-p (ispell-get-many-otherchars-p)) > + (word-chars (concat flyspell-casechars > + "+\\(" > + (if (not (string= "" ispell-otherchars)) > + (concat ispell-otherchars "?")) > + flyspell-casechars > + "+\\)" > + (if ispell-many-otherchars-p > + "*" "?"))) > + (buffer-scan-pos flyspell-large-region-beg) > + case-fold-search) > (with-current-buffer flyspell-external-ispell-buffer > (goto-char (point-min)) > ;; Loop over incorrect words, in the order they were reported, > @@ -1453,11 +1463,18 @@ flyspell-external-point-words > ;; Move back into the match > ;; so flyspell-get-word will find it. > (forward-char -1) > - (flyspell-get-word))) > + ;; Is this a word that matches the > + ;; current dictionary? > + (if (looking-at word-chars) > + (flyspell-get-word)))) > (found (car found-list)) > (found-length (length found)) > (misspell-length (length word))) > (when (or > + ;; Misspelled word is not from the > + ;; language supported by the current > + ;; dictionary. > + (null found) > ;; Size matches, we really found it. > (= found-length misspell-length) > ;; Matches as part of a boundary-char separated > @@ -1479,13 +1496,21 @@ flyspell-external-point-words > ;; backslash) and none of the previous > ;; conditions match. > (and (not ispell-really-aspell) > + (not ispell-really-hunspell) > + (not ispell-really-enchant) > (save-excursion > (goto-char (- (nth 1 found-list) 1)) > (if (looking-at "[\\]" ) > t > nil)))) > (setq keep nil) > - (flyspell-word nil t) > + ;; Don't try spell-checking words whose > + ;; characters don't match CASECHARS, because > + ;; flyspell-word will then consider as > + ;; misspelling the preceding word that matches > + ;; CASECHARS. > + (or (null found) > + (flyspell-word nil t)) > ;; Search for next misspelled word will begin from > ;; end of last validated match. > (setq buffer-scan-pos (point))))