gpt4 book ai didi

user-interface - Flyspell 正确单词的用户交互改进

转载 作者:行者123 更新时间:2023-12-04 06:08:03 25 4
gpt4 key购买 nike

我认为flyspell-correct-word的行为应该扩展为纠正所有出现的错误拼写的感兴趣单词的命令。这当然与基础拼写更正中的语法错误无关。我不知道 aspell/ispell 是否支持这种更正。它还希望将两者组合成一个命令,该命令询问用户是否要更正 query-replace 中的下一个事件。方式(y,n,q,Y,N,!)。有没有人实现过这些想法?

最佳答案

尝试将以下代码添加到您的 .emacs 中,这似乎可以满足您的要求(尽管它不会提示您进行替换(这似乎有点麻烦)):

(setq flyspell-insert-function 'flyspell-insert-and-replace-all)
(defvar flyspell-last-replacements nil)
(defun flyspell-insert-and-replace-all (word)
(unless (eq flyspell-auto-correct-pos pos) ; same check as done in flyspell-auto-correct-word
(setq flyspell-last-replacements nil))
(save-excursion
(dolist (word-markers flyspell-last-replacements)
(delete-region (car word-markers) (cdr word-markers))
(goto-char (car word-markers))
(insert word)))
(insert word)
(save-excursion
(let ((do-replacement (not flyspell-last-replacements)))
(while (re-search-forward (concat "\\<" flyspell-auto-correct-word "\\>") nil t)
(replace-match word)
;; and, when doing first search/replace, record all the positions
(when do-replacement
(let ((end-marker (point-marker))
(begin-marker (make-marker)))
(set-marker begin-marker (- (point) (length word)))
(set-marker-insertion-type end-marker t)
(set-marker-insertion-type begin-marker nil)
(add-to-list 'flyspell-last-replacements (cons begin-marker end-marker))))))))

关于user-interface - Flyspell 正确单词的用户交互改进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8122038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com