Last active
February 14, 2024 18:30
-
-
Save tkurtbond/bf8c1b3dff4a1c56aeb43271726d276b to your computer and use it in GitHub Desktop.
Don't want the first line of a git commit COMMIT_EDITMSG buffer in Emacs to wrap?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun tkb-magit-commit-fill-nobreak-p () | |
"Don't fill on the first line of a magit commit message." | |
(= 1 (line-number-at-pos))) | |
(defun tkb-magit-commit-find-file-hook () | |
(interactive) | |
(when (string-match "COMMIT_EDITMSG\\'" (buffer-file-name)) | |
(make-local-variable 'fill-nobreak-predicate) | |
(add-to-list 'fill-nobreak-predicate #'tkb-magit-commit-fill-nobreak-p))) | |
;; Using add-to-list without specifying APPEND didn't work because | |
;; that added it to the front of the list and the | |
;; git-commit-setup-check-buffer find file hook ran later. The | |
;; git-commit-setup-check-buffer runs git-commit-setup which runs | |
;; normal-mode which runs kill-all-local-variables, which wiped out | |
;; what tkb-magit-commit-find-file-hook was trying to do. | |
(add-to-list 'find-file-hook #'tkb-magit-commit-find-file-hook t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment