Last active
December 22, 2015 00:09
-
-
Save psachin/6386902 to your computer and use it in GitHub Desktop.
Custom commit.template for magit-1.2.0
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
;; Commit template location. | |
;; It can also be ~/.gitmessage.txt | |
(defcustom commit-template "./.git/COMMIT_EDITMSG" | |
"Path to custom message template file. If nil, no custom | |
message will be inserted to *magit-edit-log* buffer. The path can | |
be relative as well as absolute." | |
:group 'magit | |
:type 'string) | |
;; and modify this function accordingly | |
(defun magit-pop-to-log-edit (operation) | |
(let ((dir default-directory) | |
(magit-buf (current-buffer)) | |
(buf (get-buffer-create magit-log-edit-buffer-name))) | |
(setq magit-pre-log-edit-window-configuration | |
(current-window-configuration)) | |
(pop-to-buffer buf) | |
(setq default-directory dir) | |
(when (file-exists-p (concat (magit-git-dir) "MERGE_MSG")) | |
(insert-file-contents (concat (magit-git-dir) "MERGE_MSG"))) | |
(magit-log-edit-mode) | |
(make-local-variable 'magit-buffer-internal) | |
(setq magit-buffer-internal magit-buf) | |
;; -------- patch ------- | |
(with-current-buffer magit-log-edit-buffer-name | |
(if (= (point-min) (point-max)) | |
(progn | |
(goto-char (point-min)) | |
(if (file-exists-p commit-template) | |
(insert (format "%s" (with-temp-buffer | |
(insert-file-contents commit-template) | |
(buffer-string))))))) | |
(goto-char (point-min)) | |
(end-of-line)) | |
;; --------- patch ends here ---------- | |
(message "Type C-c C-c to %s (C-c C-k to cancel)." operation))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment