git-commit-use-local-message-ring: New option
Closes #4503.
Jonas Bernoulli
2 years ago
304 | 304 | :group 'git-commit |
305 | 305 | :safe (lambda (val) (and (listp val) (-all-p 'stringp val))) |
306 | 306 | :type '(repeat string)) |
307 | ||
308 | (defcustom git-commit-use-local-message-ring nil | |
309 | "Whether to use a local message ring instead of the global one. | |
310 | This can be set globally, in which case every repository gets its | |
311 | own commit message ring, or locally for a single repository." | |
312 | :group 'git-commit | |
313 | :safe 'booleanp | |
314 | :type 'boolean) | |
307 | 315 | |
308 | 316 | ;;;; Faces |
309 | 317 | |
554 | 562 | (magit-wip-maybe-add-commit-hook))) |
555 | 563 | (setq with-editor-cancel-message |
556 | 564 | 'git-commit-cancel-message) |
557 | (make-local-variable 'log-edit-comment-ring-index) | |
558 | 565 | (git-commit-mode 1) |
559 | 566 | (git-commit-setup-font-lock) |
567 | (git-commit-prepare-message-ring) | |
560 | 568 | (when (boundp 'save-place) |
561 | 569 | (setq save-place nil)) |
562 | 570 | (save-excursion |
704 | 712 | (when-let ((message (git-commit-buffer-message))) |
705 | 713 | (when-let ((index (ring-member log-edit-comment-ring message))) |
706 | 714 | (ring-remove log-edit-comment-ring index)) |
707 | (ring-insert log-edit-comment-ring message))) | |
715 | (ring-insert log-edit-comment-ring message) | |
716 | (when git-commit-use-local-message-ring | |
717 | (magit-repository-local-set 'log-edit-comment-ring | |
718 | log-edit-comment-ring)))) | |
719 | ||
720 | (defun git-commit-prepare-message-ring () | |
721 | (make-local-variable 'log-edit-comment-ring-index) | |
722 | (when git-commit-use-local-message-ring | |
723 | (setq-local log-edit-comment-ring | |
724 | (magit-repository-local-get | |
725 | 'log-edit-comment-ring | |
726 | (make-ring log-edit-maximum-comment-ring-size))))) | |
708 | 727 | |
709 | 728 | (defun git-commit-buffer-message () |
710 | 729 | (let ((flush (concat "^" comment-start)) |