help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: count all ispell(flyspell) errors in a buffer


From: Emanuel Berg
Subject: Re: count all ispell(flyspell) errors in a buffer
Date: Mon, 27 Nov 2023 01:36:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Uwe Brauer wrote:

> I usually use flyspell on most of my buffers, but sometimes
> are interested to run ispell-region.
>
> Is there any way to find out how many errors ispell finds
> when the program starts, if I run it interactive, how many
> corrections of errors I accepted?
>
> I googled a bit but could not find anything.

(require 'cl-lib)
(require 'ispell)

(defun ispell-count (&optional beg end)
  (interactive
    (when (use-region-p)
      (list (region-beginning) (region-end)) ))
  (or beg (setq beg (point-min)))
  (or end (setq end (point-max)))
  (save-mark-and-excursion
    (goto-char beg)
    (backward-word)
    (forward-to-word)
    (cl-loop
      with errors = 0
      while (< (point) end)
      do (let ((word (thing-at-point 'word t)))
           (unless (ispell-lookup-words word) ; inefficient
             (cl-incf errors) )
           (forward-to-word) )
      finally (message "errors: %s" errors)) ))

;; this is a region wiht two
;; worsd spelled incorrectly

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]