unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-devel@gnu.org
Subject: Re: count all spelling typos in a given buffer.
Date: Thu, 30 Nov 2023 10:28:06 +0100	[thread overview]
Message-ID: <87il5j615l.fsf@mat.ucm.es> (raw)
In-Reply-To: 87leagb7rp.fsf@dataswamp.org


[-- Attachment #1.1: Type: text/plain, Size: 2184 bytes --]

>>> "EB" == Emanuel Berg <incal@dataswamp.org> writes:

> 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.

Thanks very much


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

I also tried to download spell.el but that file needs dwim.el
which I don't have and can't find in the emacs git tree (just pulled)


However I tried your code, and I also downloaded some of your packages, including your misc.el 

Be it as it may., when I execute ispell-count, I receive

Starting "look" process...
let: Autoloading file /home/oub/emacs/site-lisp/packages/berg-code/misc.el failed to define function forward-to-word
Quit

When I rename your misc.el, restart emacs.
I try it again and then I obtain another error which I attach

Maybe I need a actualised version of your misc.el?

Thanks 


> (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

-- 
I strongly condemn Hamas heinous atrocities on Israel, especially the despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 


[-- Attachment #1.2: ispell-count-bug.txt --]
[-- Type: text/plain, Size: 2178 bytes --]

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
  forward-to-word()
  (let ((word (thing-at-point 'word t))) (if (ispell-lookup-words word) nil (setq errors (1+ errors))) (setq words (1+ words)) (forward-to-word))
  (while (< (point) end) (let ((word (thing-at-point 'word t))) (if (ispell-lookup-words word) nil (setq errors (1+ errors))) (setq words (1+ words)) (forward-to-word)))
  (let* ((words 0) (errors 0)) (while (< (point) end) (let ((word (thing-at-point 'word t))) (if (ispell-lookup-words word) nil (setq errors (1+ errors))) (setq words (1+ words)) (forward-to-word))) (message "%s words checked, %s errors" words errors) nil)
  (save-excursion (goto-char beg) (forward-word) (backward-word) (let* ((words 0) (errors 0)) (while (< (point) end) (let ((word (thing-at-point 'word t))) (if (ispell-lookup-words word) nil (setq errors (1+ errors))) (setq words (1+ words)) (forward-to-word))) (message "%s words checked, %s errors" words errors) nil))
  (unwind-protect (save-excursion (goto-char beg) (forward-word) (backward-word) (let* ((words 0) (errors 0)) (while (< (point) end) (let ((word (thing-at-point ... t))) (if (ispell-lookup-words word) nil (setq errors (1+ errors))) (setq words (1+ words)) (forward-to-word))) (message "%s words checked, %s errors" words errors) nil)) (save-mark-and-excursion--restore saved-marker))
  (let ((saved-marker (save-mark-and-excursion--save))) (unwind-protect (save-excursion (goto-char beg) (forward-word) (backward-word) (let* ((words 0) (errors 0)) (while (< (point) end) (let ((word ...)) (if (ispell-lookup-words word) nil (setq errors ...)) (setq words (1+ words)) (forward-to-word))) (message "%s words checked, %s errors" words errors) nil)) (save-mark-and-excursion--restore saved-marker)))
  ispell-count(1779 1837)
  funcall-interactively(ispell-count 1779 1837)
  call-interactively(ispell-count record nil)
  command-execute(ispell-count record)
  execute-extended-command(nil "ispell-count" "ispell-cou")
  funcall-interactively(execute-extended-command nil "ispell-count" "ispell-cou")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

  reply	other threads:[~2023-11-30  9:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 13:36 count all spelling typos in a given buffer Uwe Brauer
2023-11-29 20:54 ` Emanuel Berg
2023-11-30  9:28   ` Uwe Brauer [this message]
2023-11-30  9:49   ` [SOLVED] (was: count all spelling typos in a given buffer.) Uwe Brauer
2023-12-01  5:59     ` Emanuel Berg
2023-12-01  6:56       ` [SOLVED] Uwe Brauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il5j615l.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).