1

I want to log to a file the ispell replacements that get made (whether manual r, or from a list 0...)

Every time a "correction" is made, there are two words that are relevant:

  1. The word that ispell identifies as incorrect.
  2. The word that ends up in its place. [maybe "" when its skipped]

I just want to log these pairs to a file for "analysis" (and possibly flashcards)

I am still browsing code to see if there is a place to wedge this in. I see ispell-update-post-hook used in ispell-command-loop but I'm not sure if that's what I want. I also am not sure how I'd both get the above pair of words and write them to a file, as the hook doesn't (elisp ignorance?) seem to provide access.

Captain Midday
  • 659
  • 8
  • 18
  • Store the file before and after the correction, check the `ediff` for the changes. – choroba Sep 30 '21 at 16:56
  • Thanks @choroba. I was hoping to not go outside of emacs. Also, the goal is to collect a long list of word pairs. I'd have to use `--word-diff` and a lot of fancy regex-ing in order to pop out the two words, isolated. I basically am just trying to automatically record my own spelling mistakes so I can LEARN (slept through fourth grade) to spell those thankfully few words correctly. I want a histogram of my spelling mistakes in other words. Paper and pen is an option, honestly. – Captain Midday Oct 01 '21 at 14:33
  • You don't have to leave emacs. Store the contents before and after the correction in two buffers, then run `ediff-buffers`. – choroba Oct 01 '21 at 14:44

1 Answers1

1

This code does what you've requested. It does not check for duplicates in the file that's generated, it simply appends to the existing file.

(defvar save-ispell-words-file "~/spell_check.txt")
(defadvice ispell-command-loop (after save-ispell-words activate)
  "Save the misspelled words and their replacements"
  (when (or (null ad-return-value)
            (stringp ad-return-value))
    (save-excursion
      (set-buffer (find-file-noselect save-ispell-words-file))
      (goto-char (point-max))
      (insert (format "%s %s\n" (ad-get-arg 2) (if (null ad-return-value) "\"\"" ad-return-value)))
      (save-buffer))))

Tested with Emacs 27.2.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229