【问题标题】:How do I tell to flyspell to ignore comment lines on git-commit-mode?我如何告诉 flyspell 忽略 git-commit-mode 上的注释行?
【发布时间】:2016-05-19 21:05:51
【问题描述】:

我通常在编写 git 提交时更改字典,但是因为我有一个映射来更改字典并在我看到 flyspell 超出提交消息以检查以 # 开头的注释行后立即运行 (flyspell-buffer)

如何告诉“flyspell,请忽略以# 符号开头的行”

我读到我可以使用 flyspell-generic-check-word-predicate 但是我的 elisp 远非好 :(,我想出了这个:

(defun flyspell-ignore-comments ()
  "Used for 'flyspell-generic-check-word-predicate' to ignore comments."
  (not (string-match "^ *#" (thing-at-point 'line t))))
(put 'git-commit-mode 'flyspell-mode-predicate 'flyspell-ignore-comments)

但是它不起作用。我做错了什么?

【问题讨论】:

  • git-commit-setup-hook 中有 git-commit-turn-on-flyspell 吗?如果是这样,那应该将 flyspell-generic-check-word-predicate 设置为 git-commit-flyspell-verify,这会忽略 cmets。
  • 确实@kyle-meyer,我有那个设置,检查(describe-variable flyspell-generic-check-word-predicate) 给出类似Its value is git-commit-flyspell-verify Local in buffer COMMIT_EDITMSG; global value is nil 但仍然注释的行被标记为flyspell 错误(文件名,目录名,Untracked files 部分,等)
  • 使用 emacs -Q、Magit 2.7.0 和 (add-hook 'git-commit-setup-hook #'git-commit-turn-on-flyspell),我无法重现该问题(即,提交消息中的 cmets 被忽略,如预期的那样)。

标签: emacs magit flyspell


【解决方案1】:

好的,感谢@KyleMeyer 让我怀疑我的配置,问题是我在text-mode-hook 中启用了flyspell,这干扰了git-commit-mode 的配置。删除 flyspell 以加载到 text-mode-hook 解决了这个问题。

谢谢。

【讨论】:

  • 感谢您回答您自己的问题。您的解决方案让我在.emacs 中看到了一个问题。我在flyspell-mode-hook 中运行了flyspell-buffer,这也让我在提交缓冲区的cmets 中出现拼写错误。
猜你喜欢
  • 1970-01-01
  • 2014-06-15
  • 1970-01-01
  • 2013-10-13
  • 1970-01-01
  • 2017-10-24
  • 2013-07-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多