From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Roni Kallio Newsgroups: gmane.emacs.bugs Subject: bug#50443: Fwd: Flyspell error traversal additions Date: Thu, 09 Sep 2021 23:58:19 +0300 Message-ID: <87a6kle9fp.fsf@kallio.app> References: <87sg6lchgc.fsf@kallio.app> <87r1m5ch9n.fsf@kallio.app> <831r61q66n.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22568"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.0; emacs 28.0.50 Cc: 50443@debbugs.gnu.org, Stefan Kangas To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 09 23:59:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOS4k-0005ig-0D for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Sep 2021 23:59:18 +0200 Original-Received: from localhost ([::1]:53654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOS4i-0002vJ-HK for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Sep 2021 17:59:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOS4U-0002uu-LV for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 17:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOS4U-00069B-Dy for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 17:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOS4U-00014T-9E for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 17:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Roni Kallio Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Sep 2021 21:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50443 X-GNU-PR-Package: emacs Original-Received: via spool by 50443-submit@debbugs.gnu.org id=B50443.16312247254088 (code B ref 50443); Thu, 09 Sep 2021 21:59:02 +0000 Original-Received: (at 50443) by debbugs.gnu.org; 9 Sep 2021 21:58:45 +0000 Original-Received: from localhost ([127.0.0.1]:36365 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOS4C-00013r-Fk for submit@debbugs.gnu.org; Thu, 09 Sep 2021 17:58:44 -0400 Original-Received: from mail-lj1-f171.google.com ([209.85.208.171]:37796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mORPe-0008VO-JS for 50443@debbugs.gnu.org; Thu, 09 Sep 2021 17:16:51 -0400 Original-Received: by mail-lj1-f171.google.com with SMTP id r3so5168862ljc.4 for <50443@debbugs.gnu.org>; Thu, 09 Sep 2021 14:16:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version; bh=HIDMK9N1JFnuFlimxPT9UQar639yTZNCXkkmPPMQkGE=; b=tzY225NUSnLFa1EdPk3FcytM4KrM+d7AiKcNJsJcbE3dEu44AGb0WF29JyGUIUfbMo Ae15NUXzV0YFFM8CAdj9eXInTyTfj4s3Dg3V3h2lX3diKEH974+KvmHufdbB8Lwz+xEY Ph2r7HKQrINcQb88qIj7Zw9p5KQSTdC1uaizc7OtAFHRBCldwO3jPL3W3rzmHinC4xBB yc48+CPELDyhre9+vl01KZdaBDqlgtz7cy6HZMuEO+4ni4GOcURBHxsIMLW57vS3hRi9 IsqYXI/kfLX0hLhQFFo6VVWkkG4UHz4SH+7wEPM7HSjXVFMY2JnDvV8ZjsZ9JBR1FNiX G10g== X-Gm-Message-State: AOAM531CHrPYPYhMeYsV1BGB1CPg2WNOA0B20zYaRtk0/6OdUjghsZlP rlXJNqLxYmfsPk/i1eBV/wHMeeGHWGo= X-Google-Smtp-Source: ABdhPJwP1uxYDjlR3SGFg3s0iOmGVheRgbcuWSVP+XhPAO1VH1eFXU4vcG24ecQ5gC5EEfNKj6bVXA== X-Received: by 2002:a05:651c:503:: with SMTP id o3mr1486106ljp.528.1631222204281; Thu, 09 Sep 2021 14:16:44 -0700 (PDT) Original-Received: from phobos.gmail.com (cable-hml-50dcf4-126.dhcp.inet.fi. [80.220.244.126]) by smtp.gmail.com with ESMTPSA id m15sm313349lfg.59.2021.09.09.14.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 14:16:43 -0700 (PDT) In-reply-to: <831r61q66n.fsf@gnu.org> X-Mailman-Approved-At: Thu, 09 Sep 2021 17:58:43 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:213948 Archived-At: >> IMO the best course of action would be to modify >> `flyspell-goto-next-error' to accept a prefix argument. The prefix >> would control the direction and number of jumps performed; negative >> arguments would jump backwards -ARG errors (by calling >> flyspell-goto-previous-error), while positive arguments would jump >> forwards ARG errors. This would be similar to how commands like >> `forward-word' handle prefix arguments. This would allow us to leave >> the mode-map unchanged, but still distribute the improvement to all >> users. > > Yes, I agree. Can you change the patch to work this way? I've been using this updated patch for a while now, hope it comes through ok. diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 975f540936..b80626bb12 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -1708,39 +1708,77 @@ flyspell-old-pos-error ;;*---------------------------------------------------------------------*/ ;;* flyspell-goto-next-error ... */ ;;*---------------------------------------------------------------------*/ -(defun flyspell-goto-next-error () - "Go to the next previously detected error. -In general FLYSPELL-GOTO-NEXT-ERROR must be used after -FLYSPELL-BUFFER." - (interactive) - (let ((pos (point)) - (max (point-max))) - (if (and (eq (current-buffer) flyspell-old-buffer-error) - (eq pos flyspell-old-pos-error)) - (progn - (if (= flyspell-old-pos-error max) - ;; goto beginning of buffer - (progn - (message "Restarting from beginning of buffer") - (goto-char (point-min))) - (forward-word 1)) - (setq pos (point)))) - ;; seek the next error - (while (and (< pos max) - (let ((ovs (overlays-at pos)) - (r '())) - (while (and (not r) (consp ovs)) - (if (flyspell-overlay-p (car ovs)) - (setq r t) - (setq ovs (cdr ovs)))) - (not r))) - (setq pos (1+ pos))) - ;; save the current location for next invocation - (setq flyspell-old-pos-error pos) - (setq flyspell-old-buffer-error (current-buffer)) - (goto-char pos) - (if (= pos max) - (message "No more miss-spelled word!")))) +(defun flyspell-goto-next-error (&optional arg) + "Go to the detected error that is ARG errors forward. +In general `flyspell-goto-next-error' must be used after +`flyspell-buffer'." + (interactive "p") + (cond + ((= arg 0) nil) + ((< arg 0) (flyspell-goto-previous-error (abs arg))) + (t + (let ((pos (point)) + (max (point-max))) + (if (and (eq (current-buffer) flyspell-old-buffer-error) + (eq pos flyspell-old-pos-error)) + (progn + (if (= flyspell-old-pos-error max) + ;; goto beginning of buffer + (progn + (message "Restarting from beginning of buffer") + (goto-char (point-min))) + (forward-word 1)) + (setq pos (point)))) + ;; seek the next error + (while (and (< pos max) + (let ((ovs (overlays-at pos)) + (r '())) + (while (and (not r) (consp ovs)) + (if (flyspell-overlay-p (car ovs)) + (setq r t) + (setq ovs (cdr ovs)))) + (not r))) + (setq pos (1+ pos))) + ;; save the current location for next invocation + (setq flyspell-old-pos-error pos) + (setq flyspell-old-buffer-error (current-buffer)) + (goto-char pos) + (if (= pos max) + (message "No more miss-spelled word!"))) + (flyspell-goto-next-error (1- arg))))) + +(defun flyspell-goto-previous-error (&optional arg) + "Go to the detected error ARG errors backward. +In general `flyspell-goto-previous-error' must be used after +`flyspell-buffer'." + (interactive "p") + (cond + ((= arg 0) nil) + ((< arg 0) (flyspell-goto-next-error (abs arg))) + (t + (let ((min (point-min))) + (when (and (eq (current-buffer) flyspell-old-buffer-error) + (eq (point) flyspell-old-pos-error)) + (when (= (point) min) + (message "Restarting from end of buffer") + (goto-char (point-max))) + (backward-word 1)) + (while (and (> (point) min) + (let ((ovs (overlays-at (point))) + (r nil)) + ;; look for a flyspell overlay + (while (and (not r) (consp ovs)) + (if (flyspell-overlay-p (car ovs)) + (setq r t) + (setq ovs (cdr ovs)))) + (not r))) + ;; go to previous word if no overlay was found + (backward-word 1)) + (setq flyspell-old-pos-error (point)) + (setq flyspell-old-buffer-error (current-buffer)) + (when (= (point) min) + (message "No more miss-spelled word!"))) + (flyspell-goto-previous-error (1- arg))))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-overlay-p ... */ > Also, the patch is long enough to require a copyright assignment from > you. Would you be willing to start your legal paperwork at this time, > so we could accept your contribution when it is complete? Sure, can you direct me to what I need to do to sign? -- Roni Kallio