Skip to content

Commit 485cdb9

Browse files
wence-gitster
authored andcommitted
git.el: Don't use font-lock-compile-keywords
If font-lock is disabled, font-lock-compile-keywords complains. Really what we want to do is to replace log-edit's font-lock definitions with our own, so define a major mode deriving from log-edit and set up font-lock-defaults there. We then use the optional MODE argument to log-edit to set up the major mode of the commit buffer appropriately. Signed-off-by: Lawrence Mitchell <[email protected]> Acked-by: Alexandre Julliard <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6b3d83e commit 485cdb9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

contrib/emacs/git.el

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,13 @@ The FILES list must be sorted."
13101310
(when sign-off (git-append-sign-off committer-name committer-email)))
13111311
buffer))
13121312

1313+
(define-derived-mode git-log-edit-mode log-edit-mode "Git-Log-Edit"
1314+
"Major mode for editing git log messages.
1315+
1316+
Set up git-specific `font-lock-keywords' for `log-edit-mode'."
1317+
(set (make-local-variable 'font-lock-defaults)
1318+
'(git-log-edit-font-lock-keywords t t)))
1319+
13131320
(defun git-commit-file ()
13141321
"Commit the marked file(s), asking for a commit message."
13151322
(interactive)
@@ -1335,9 +1342,9 @@ The FILES list must be sorted."
13351342
(git-setup-log-buffer buffer (git-get-merge-heads) author-name author-email subject date))
13361343
(if (boundp 'log-edit-diff-function)
13371344
(log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files)
1338-
(log-edit-diff-function . git-log-edit-diff)) buffer)
1339-
(log-edit 'git-do-commit nil 'git-log-edit-files buffer))
1340-
(setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))
1345+
(log-edit-diff-function . git-log-edit-diff)) buffer 'git-log-edit-mode)
1346+
(log-edit 'git-do-commit nil 'git-log-edit-files buffer
1347+
'git-log-edit-mode))
13411348
(setq paragraph-separate (concat (regexp-quote git-log-msg-separator) "$\\|Author: \\|Date: \\|Merge: \\|Signed-off-by: \\|\f\\|[ ]*$"))
13421349
(setq buffer-file-coding-system coding-system)
13431350
(re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))

0 commit comments

Comments
 (0)