emacs-devel
[Top][All Lists]
Advanced

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

Re: count all spelling typos in a given buffer.


From: Emanuel Berg
Subject: Re: count all spelling typos in a given buffer.
Date: Wed, 29 Nov 2023 21:54:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Uwe Brauer wrote:

> I asked this already on the emacs help list, but maybe
> somebody here, knows about the following feature, namely:
> Count all the typos, ispell (flyspell) finds in
> given buffer.

I posted this solution on gnu.emacs.help several days ago but
it hasn't appeared, anyway here you go.

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/spell.el

(require 'cl-lib)

(defun ispell-count (&optional beg end)
  (interactive
    (if (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)
    (forward-word)
    (backward-word)
    (cl-loop
      with words  = 0
      with errors = 0
      while (< (point) end)
      do (let ((word (thing-at-point 'word t)))
           (unless (ispell-lookup-words word)
             (cl-incf errors) )
           (cl-incf words)
           (forward-to-word) )
      finally (message "%s words checked, %s errors" words 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]