From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21129: 24.5; Behaviour and docstring of flyspell-check-previous-highlighted-word Date: Sat, 25 Jul 2015 12:40:15 +0300 Message-ID: <83oaj01sow.fsf@gnu.org> References: <87fv4d4fws.fsf@moondust.localdomain> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1437817290 20181 80.91.229.3 (25 Jul 2015 09:41:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Jul 2015 09:41:30 +0000 (UTC) Cc: 21129-done@debbugs.gnu.org To: nljlistbox2@gmail.com (N. Jackson) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 25 11:41:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZIvx7-0007mS-VT for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jul 2015 11:41:10 +0200 Original-Received: from localhost ([::1]:47595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIvx7-0005WC-9X for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jul 2015 05:41:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIvx4-0005V1-2p for bug-gnu-emacs@gnu.org; Sat, 25 Jul 2015 05:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIvx0-0001y0-Se for bug-gnu-emacs@gnu.org; Sat, 25 Jul 2015 05:41:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIvx0-0001xv-Oy for bug-gnu-emacs@gnu.org; Sat, 25 Jul 2015 05:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZIvx0-0000SV-02 for bug-gnu-emacs@gnu.org; Sat, 25 Jul 2015 05:41:02 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Jul 2015 09:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 21129 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 21129@debbugs.gnu.org, eliz@gnu.org, nljlistbox2@gmail.com Original-Received: via spool by 21129-done@debbugs.gnu.org id=D21129.14378172191694 (code D ref 21129); Sat, 25 Jul 2015 09:41:01 +0000 Original-Received: (at 21129-done) by debbugs.gnu.org; 25 Jul 2015 09:40:19 +0000 Original-Received: from localhost ([127.0.0.1]:58359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZIvwI-0000RE-K4 for submit@debbugs.gnu.org; Sat, 25 Jul 2015 05:40:19 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:65330) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZIvwF-0000R5-DS for 21129-done@debbugs.gnu.org; Sat, 25 Jul 2015 05:40:16 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NS100K00EPZ0000@a-mtaout22.012.net.il> for 21129-done@debbugs.gnu.org; Sat, 25 Jul 2015 12:40:13 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NS100JRVEV1HZ80@a-mtaout22.012.net.il>; Sat, 25 Jul 2015 12:40:13 +0300 (IDT) In-reply-to: <87fv4d4fws.fsf@moondust.localdomain> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105118 Archived-At: > From: nljlistbox2@gmail.com (N. Jackson) > Date: Fri, 24 Jul 2015 14:35:47 -0300 > > flyspell-check-previous-highlighted-word (f-c-p-h-w) seems to me to have > (at least) two bugs (see below) and has typos in (and other problems > with) its docstring. Indeed; thanks for pointing that out. > 1. The docstring fails to state that, to be found, the misspelled word > must be highlighted by Flyspell. (It might not be if Flyspell has not > yet run over the buffer or region in question.) > > 2. Some other problems/typos with the docstring are pointed out with > carets below: > > Correct the closer misspelled word. > ^^ > This function scans a mis-spelled word before the cursor. If it > ^ ^ ^^^^^^^^^^ > finds one it proposes replacement for that word. With prefix arg, > ^ ^ > count that many misspelled words backwards. > > Perhaps a better docstring might be something like: > > Correct the closest previous word that is highlighted as misspelled. > This function scans for a word before point that has been > highlighted by Flyspell as misspelled. If it finds one it proposes a > replacement for that word. With a prefix arg, it scans for the nth > misspelled word before point, for n equal to ARG. I used this text with minor stylistic corrections, to make it use the same style as in other doc strings. > 3. Strangely, f-c-p-h-w uses the Ispell user interface rather than > the Flyspell user interface. This suits me fine as I like a > non-graphical interface, but it seems to me to be a bug. This is > Flyspell after all, and I think one would expect the same interface as > with, say, `M-x flyspell-correct-word-before-point'. I did nothing about this one, as this appears a deliberate design decision of the original author. > 4. Contrary to the docstring, if point is immediately after the last > character of a misspelled (and Flyspell-highlighted) word, f-c-p-h-w > skips to the previous misspelled (and Flyspell-highlighted) word, even > though the closest previous misspelled word was the one directly before > point. Fixed. > 5. Executing f-c-p-h-w with a prefix argument does not appear to work; > the behaviour is as if there was no prefix argument. E.g. with several > misspelled words in the buffer before point, `C-u 3 M-x > flyspell-check-previous-highlighted-word' acts on the final one just as > `M-x flyspell-check-previous-highlighted-word' does, rather than on the > 3rd from last one. A simple oversight in how the function's 'interactive' form was used; fixed. The patch appears below, so you could try it in Emacs 24.5. Thanks. diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index a5dff07..2329f29 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -1827,11 +1827,12 @@ (make-variable-buffer-local 'flyspell-auto-correct-word) ;;* flyspell-check-previous-highlighted-word ... */ ;;*---------------------------------------------------------------------*/ (defun flyspell-check-previous-highlighted-word (&optional arg) - "Correct the closer misspelled word. -This function scans a mis-spelled word before the cursor. If it finds one -it proposes replacement for that word. With prefix arg, count that many -misspelled words backwards." - (interactive) + "Correct the closest previous word that is highlighted as misspelled. +This function scans for a word which starts before point that has been +highlighted by Flyspell as misspelled. If it finds one, it proposes +a replacement for that word. With prefix arg N, check the Nth word +before point that's highlighted as misspelled." + (interactive "P") (let ((pos1 (point)) (pos (point)) (arg (if (or (not (numberp arg)) (< arg 1)) 1 arg)) @@ -1842,7 +1843,7 @@ (defun flyspell-check-previous-highlighted-word (&optional arg) (setq pos1 pos) (if (> pos (point-min)) (progn - (setq ovs (overlays-at (1- pos))) + (setq ovs (overlays-at pos)) (while (consp ovs) (setq ov (car ovs)) (setq ovs (cdr ovs))