I want to be able to edit Git commit message without having to either manually break up the text into multiple lines as I write (I do that afterwords using M-x fill-region
) or having to scroll horizontally to read everything that I have already written, and therefore want to set truncate-lines
to nil
to make Emacs wrap the lines at the window edge (it would be even better if I could get it to do Word Wrap (Visual Line Mode) instead, but I don't know what value to set truncate-lines
to for that to happen). This works well if I use M-x set-variable
to set the value of the variable, but I want this to happen automatically whenever I edit Git commit messages, and I have therefore added this to my ~/.emacs
:
(define-derived-mode git-commit-message-mode fundamental-mode "Git commit message"
"Major mode for composing or editing Git commit messages"
((lambda () ;; Create a lambda and call it immediately. Could maybe be solved differently...
(require 'fill-column-indicator)
(cond ((not fci-mode) (fci-mode))) ;; Activate fill column indicator if not already activated
(setq line-move-visual nil)
(custom-set-variables
'(show-paren-mode t)
'(fci-rule-column 70) ;; Git recommends using a max line length of 70 characters in the commit message body
'(truncate-lines nil) ;; This is the line that doesn't seem to have any effect
)
)))
However, while the mode seems to be activated when I edit Git commits (it properly activates and sets up the fill column indicator), this does not work for making a persistent change to truncate-lines
. Why not? Is truncate-lines
changed to nil
temporarily and then changed to some other value shortly after? How can I change truncate-lines
changed to nil
and make it keep that value?