From 4a8a7e027104b4f03fc40b37bf3affed31e19914 Mon Sep 17 00:00:00 2001 From: Thibaut Verron Date: Thu, 21 Nov 2019 13:02:03 +0100 Subject: [PATCH 1/5] git-auto-commit-mode.el --- git-auto-commit-mode.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 33ffa1a..9e12fab 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -75,6 +75,21 @@ is subject to its limitations." (const :tag "Off" nil))) (make-variable-buffer-local 'gac-debounce-interval) +(defcustom gac-default-message nil + "Default message for automatic commits. + +It can be: +- nil to use the default FILENAME +- a string which is used +- a function returning a string, called without argument in the + current buffer, the result being used as message +" + :tag "Default commit message" + :group 'git-auto-commit-mode + :type '(choice (string :tag "Commit message") + (const :tag "Default: FILENAME" nil) + (function :tag "Function"))) + (defun gac-relative-file-name (filename) "Find the path to FILENAME relative to the git directory." (let* ((git-dir @@ -123,7 +138,7 @@ STRING is the output line from PROC." Default to FILENAME." (let ((relative-filename (gac-relative-file-name filename))) (if (not gac-ask-for-summary-p) - relative-filename + (or gac-default-message relative-filename) (read-string "Summary: " nil nil relative-filename)))) (defun gac-commit (buffer) From a597d6920a16618d99c02c7e1aff696f49b034fd Mon Sep 17 00:00:00 2001 From: Thibaut Verron Date: Thu, 21 Nov 2019 13:04:33 +0100 Subject: [PATCH 2/5] git-auto-commit-mode.el --- git-auto-commit-mode.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 9e12fab..2cd627f 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -138,6 +138,11 @@ STRING is the output line from PROC." Default to FILENAME." (let ((relative-filename (gac-relative-file-name filename))) (if (not gac-ask-for-summary-p) + (if gac-default-message + (if (functionp gac-default-message) + (gac-default-message) + gac-default-message) + relative-filename) (or gac-default-message relative-filename) (read-string "Summary: " nil nil relative-filename)))) From 392ca731784ad0767ee49acbb1dd93d72a6f484e Mon Sep 17 00:00:00 2001 From: Thibaut Verron Date: Thu, 21 Nov 2019 13:07:48 +0100 Subject: [PATCH 3/5] Auto commit: /home/guests/verron/Development/git-auto-commit-mode/git-auto-commit-mode.el --- git-auto-commit-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 2cd627f..99d4eb0 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -140,7 +140,7 @@ Default to FILENAME." (if (not gac-ask-for-summary-p) (if gac-default-message (if (functionp gac-default-message) - (gac-default-message) + (funcall gac-default-message filename) gac-default-message) relative-filename) (or gac-default-message relative-filename) From ea3b5c0d9132561df518746d7d2359fe986e6afe Mon Sep 17 00:00:00 2001 From: Thibaut Verron Date: Thu, 21 Nov 2019 13:08:30 +0100 Subject: [PATCH 4/5] Auto commit: /home/guests/verron/Development/git-auto-commit-mode/git-auto-commit-mode.el --- git-auto-commit-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 99d4eb0..5797784 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -81,8 +81,8 @@ is subject to its limitations." It can be: - nil to use the default FILENAME - a string which is used -- a function returning a string, called without argument in the - current buffer, the result being used as message +- a function returning a string, called with FILENAME as + argument, the result being used as message " :tag "Default commit message" :group 'git-auto-commit-mode From 24c8e7b0fe25fa06dcfbb9beea1e6a88a26b30c6 Mon Sep 17 00:00:00 2001 From: Thibaut Verron Date: Thu, 21 Nov 2019 13:08:47 +0100 Subject: [PATCH 5/5] Add setting for changing the default message --- git-auto-commit-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 5797784..444266b 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -82,7 +82,7 @@ It can be: - nil to use the default FILENAME - a string which is used - a function returning a string, called with FILENAME as - argument, the result being used as message + argument, in which case the result is used as commit message " :tag "Default commit message" :group 'git-auto-commit-mode