emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit f805f6a 2/2: git-commit-use-local-message-ring:


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit f805f6a 2/2: git-commit-use-local-message-ring: New option
Date: Mon, 20 Sep 2021 09:57:36 -0400 (EDT)

branch: elpa/git-commit
commit f805f6a7720aeb894e9a58f0b36769ebdb53dd7c
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    git-commit-use-local-message-ring: New option
    
    Closes #4503.
---
 lisp/git-commit.el | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index 3d08144..9bd14fa 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -306,6 +306,14 @@ already using it, then you probably shouldn't start doing 
so."
   :safe (lambda (val) (and (listp val) (-all-p 'stringp val)))
   :type '(repeat string))
 
+(defcustom git-commit-use-local-message-ring nil
+  "Whether to use a local message ring instead of the global one.
+This can be set globally, in which case every repository gets its
+own commit message ring, or locally for a single repository."
+  :group 'git-commit
+  :safe 'booleanp
+  :type 'boolean)
+
 ;;;; Faces
 
 (defgroup git-commit-faces nil
@@ -555,9 +563,9 @@ to recover older messages")
       (magit-wip-maybe-add-commit-hook)))
   (setq with-editor-cancel-message
         'git-commit-cancel-message)
-  (make-local-variable 'log-edit-comment-ring-index)
   (git-commit-mode 1)
   (git-commit-setup-font-lock)
+  (git-commit-prepare-message-ring)
   (when (boundp 'save-place)
     (setq save-place nil))
   (save-excursion
@@ -705,7 +713,18 @@ With a numeric prefix ARG, go forward ARG comments."
   (when-let ((message (git-commit-buffer-message)))
     (when-let ((index (ring-member log-edit-comment-ring message)))
       (ring-remove log-edit-comment-ring index))
-    (ring-insert log-edit-comment-ring message)))
+    (ring-insert log-edit-comment-ring message)
+    (when git-commit-use-local-message-ring
+      (magit-repository-local-set 'log-edit-comment-ring
+                                  log-edit-comment-ring))))
+
+(defun git-commit-prepare-message-ring ()
+  (make-local-variable 'log-edit-comment-ring-index)
+  (when git-commit-use-local-message-ring
+    (setq-local log-edit-comment-ring
+                (magit-repository-local-get
+                 'log-edit-comment-ring
+                 (make-ring log-edit-maximum-comment-ring-size)))))
 
 (defun git-commit-buffer-message ()
   (let ((flush (concat "^" comment-start))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]