* count all spelling typos in a given buffer.
@ 2023-11-29 13:36 Uwe Brauer
2023-11-29 20:54 ` Emanuel Berg
0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2023-11-29 13:36 UTC (permalink / raw)
To: emacs-devel
Hi
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 see two possibilities to make this work
1. run flyspell-region or flyspell-buffer and simply (?) Count the
highlighted expressions.
2. run a complete ispell session, accept some changes, reject
others, add new words (mostly names ispell does not know about)
to your private dictionary. Once that is finished, the number of
corrections+entry in the personal dictionary are counted and
displayed.
Anybody knows about something like this, or is somebody working on it?
Might be very useful for teachers or lectures for correcting submitted works.
Regards
Uwe Brauer
--
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: count all spelling typos in a given buffer.
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
2023-11-30 9:49 ` [SOLVED] (was: count all spelling typos in a given buffer.) Uwe Brauer
0 siblings, 2 replies; 6+ messages in thread
From: Emanuel Berg @ 2023-11-29 20:54 UTC (permalink / raw)
To: emacs-devel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: count all spelling typos in a given buffer.
2023-11-29 20:54 ` Emanuel Berg
@ 2023-11-30 9:28 ` Uwe Brauer
2023-11-30 9:49 ` [SOLVED] (was: count all spelling typos in a given buffer.) Uwe Brauer
1 sibling, 0 replies; 6+ messages in thread
From: Uwe Brauer @ 2023-11-30 9:28 UTC (permalink / raw)
To: emacs-devel
[-- 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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [SOLVED] (was: count all spelling typos in a given buffer.)
2023-11-29 20:54 ` Emanuel Berg
2023-11-30 9:28 ` Uwe Brauer
@ 2023-11-30 9:49 ` Uwe Brauer
2023-12-01 5:59 ` Emanuel Berg
1 sibling, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2023-11-30 9:49 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 775 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.
> ;; this is a region wiht two
> ;; worsd spelled incorrectly
Thanks with the latest misc.el from master, it works, great
--
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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [SOLVED] (was: count all spelling typos in a given buffer.)
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
0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2023-12-01 5:59 UTC (permalink / raw)
To: emacs-devel
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.
>
>> ;; this is a region wiht two
>> ;; worsd spelled incorrectly
>
> Thanks with the latest misc.el from master, it works, great
Right, I know what caused that, I had my own misc.el not
knowing there was such a file in Emacs already. Glad you got
it to work anyway and I renamed that file, so it improved my
Elisp as well, sweet.
If one is interested in "spell stats" one could do a more
integrated solution so it would report after each normal spell
run with ispell.
But I don't know how much that would be used, really, so maybe
that little Elisp is enough to just test and play with once in
a while. Or why did you want this to begin with? I guess there
are more people like me who just love to count things.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [SOLVED]
2023-12-01 5:59 ` Emanuel Berg
@ 2023-12-01 6:56 ` Uwe Brauer
0 siblings, 0 replies; 6+ messages in thread
From: Uwe Brauer @ 2023-12-01 6:56 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1755 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.
>>
>>> ;; this is a region wiht two
>>> ;; worsd spelled incorrectly
>>
>> Thanks with the latest misc.el from master, it works, great
> Right, I know what caused that, I had my own misc.el not
> knowing there was such a file in Emacs already. Glad you got
> it to work anyway and I renamed that file, so it improved my
> Elisp as well, sweet.
> If one is interested in "spell stats" one could do a more
> integrated solution so it would report after each normal spell
> run with ispell.
I think right now the best strategy is:
1. first run ispell/aspell to check for names and expression he does
not know and which should be inserted in your personal dictionary.
2. Only then use the counting function.
> But I don't know how much that would be used, really, so maybe
> that little Elisp is enough to just test and play with once in
> a while. Or why did you want this to begin with? I guess there
> are more people like me who just love to count things.
I think I will ask also in the org mailing list, maybe someone there is
interested.
--
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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-01 6:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.