【问题标题】:How to log spelling replacements in emacs?如何在 emacs 中记录拼写替换?
【发布时间】:2023-03-12 07:48:01
【问题描述】:

我想将完成的 ispell 替换记录到文件中(无论是手动 r,还是来自列表 0...)

每次“更正”时,有两个词是相关的:

  1. ispell 标识的单词不正确。
  2. 最后出现在其位置的单词。 [可能是 "" 跳过时]

我只想将这些对记录到文件中以进行“分析”(可能还有抽认卡)

我仍在浏览代码以查看是否有可以插入的地方。我看到ispell-command-loop 中使用了ispell-update-post-hook,但我不确定这是否是我想要的。我也不确定如何获取上述一对单词并将它们写入文件,因为钩子(省略无知?)似乎提供访问权限。

【问题讨论】:

  • 存储修正前后的文件,检查ediff是否有变化。
  • 谢谢@choroba。我希望不要离开emacs。此外,目标是收集一长串单词对。我必须使用--word-diff 和许多花哨的正则表达式才能弹出两个单词,孤立的。我基本上只是想自动记录我自己的拼写错误,这样我就可以学习(睡到四年级)正确拼写那些谢天谢地的几个单词。换句话说,我想要一个我的拼写错误的直方图。老实说,纸和笔是一种选择。
  • 你不必离开 emacs。将校正前后的内容存储在两个缓冲区中,然后运行ediff-buffers

标签: emacs ispell


【解决方案1】:

此代码符合您的要求。它不检查生成的文件中的重复项,它只是附加到现有文件中。

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

使用 Emacs 27.2 测试。

【讨论】:

    猜你喜欢
    • 2021-06-01
    • 2015-07-10
    • 2013-12-26
    • 1970-01-01
    • 2019-05-08
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 2010-10-11
    相关资源
    最近更新 更多