diff options
| author | Adam Jones <adam.jones@ravelin.com> | 2024-02-19 17:40:34 +0000 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2024-02-21 15:45:10 +0100 |
| commit | 09961f67a403c53b62669f40a088d5720dc77270 (patch) | |
| tree | c07c044f25e7e855e0f0ebb7f24468b3281bbeb7 /lisp/git-commit.el | |
| parent | f5ddce8c8459ffcbb2bd3ae759259d6b627c69cd (diff) | |
git-commit-turn-on-flyspell: Don't check below cut-line
When `commit.verbose' is set to true in git's configuration, a special
line will be added to the (temporary) commit message. All content below
this will be ignored by git when constructing the eventual commit
message. This is defined as `cut_line' in wt-status.c in git's source:
https://github.com/git/git/blob/3e0d3cd5c7def4808247caf168e17f2bbf47892b/wt-status.c#L38-L39
I noticed that, for exceptionally large commits, magit was triggering
a commensurately large flyspell operation. This appears to be a small
oversight in the logic of `git-commit-turn-on-flyspell'.
This commit attempts fix the performance issue by instructing flyspell
to ignore all lines after `cut_line'.
Diffstat (limited to 'lisp/git-commit.el')
| -rw-r--r-- | lisp/git-commit.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/git-commit.el b/lisp/git-commit.el index 440bc03..c4d094d 100644 --- a/lisp/git-commit.el +++ b/lisp/git-commit.el @@ -675,16 +675,21 @@ turning on `orglink-mode'." (defun git-commit-turn-on-flyspell () "Unconditionally turn on Flyspell mode. -Also prevent comments from being checked and -finally check current non-comment text." +Also check text that is already in the buffer, while avoiding to check +most text that Git will strip from the final message, such as the last +comment and anything below the cut line (\"--- >8 ---\")." (require 'flyspell) (turn-on-flyspell) (setq flyspell-generic-check-word-predicate #'git-commit-flyspell-verify) - (let ((end) + (let ((end nil) + ;; The "cut line" is defined in "git/wt-status.c". It appears + ;; in the commit message when `commit.verbose' is set to true. + (cut-line-regex (format "^%s -\\{8,\\} >8 -\\{8,\\}$" comment-start)) (comment-start-regex (format "^\\(%s\\|$\\)" comment-start))) (save-excursion - (goto-char (point-max)) + (goto-char (or (re-search-forward cut-line-regex nil t) + (point-max))) (while (and (not (bobp)) (looking-at comment-start-regex)) (forward-line -1)) (unless (looking-at comment-start-regex) |
