update of packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
(define-package "git-commit" "20221127.2227" "Edit Git commit messages."
|
||||
(define-package "git-commit" "20231030.2243" "Edit Git commit messages."
|
||||
'((emacs "25.1")
|
||||
(compat "28.1.1.2")
|
||||
(transient "20210920")
|
||||
(with-editor "20211001"))
|
||||
:commit "3cf308c1c4cdb9404e3d3c6f9935ad9f628311d9" :authors
|
||||
(compat "29.1.3.4")
|
||||
(transient "20230201")
|
||||
(with-editor "20230118"))
|
||||
:commit "5cf664cd32010d3a5207c09da60e0c8f0c37b496" :authors
|
||||
'(("Jonas Bernoulli" . "jonas@bernoul.li")
|
||||
("Sebastian Wiesner" . "lunaryorn@gmail.com")
|
||||
("Florian Ragwitz" . "rafl@debian.org")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; git-commit.el --- Edit Git commit messages -*- lexical-binding:t; coding:utf-8 -*-
|
||||
|
||||
;; Copyright (C) 2008-2022 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Sebastian Wiesner <lunaryorn@gmail.com>
|
||||
@@ -14,7 +14,8 @@
|
||||
;; Package-Version: 3.3.0.50-git
|
||||
;; Package-Requires: (
|
||||
;; (emacs "25.1")
|
||||
;; (compat "28.1.1.2")
|
||||
;; (compat "29.1.3.4")
|
||||
;; (seq "2.24")
|
||||
;; (transient "0.3.6")
|
||||
;; (with-editor "3.0.5"))
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
;; actually passing it a message. Git then invokes the `$GIT_EDITOR'
|
||||
;; (or if that is undefined `$EDITOR') asking the user to provide the
|
||||
;; message by editing the file ".git/COMMIT_EDITMSG" (or another file
|
||||
;; in that directory, e.g. ".git/MERGE_MSG" for merge commits).
|
||||
;; in that directory, e.g., ".git/MERGE_MSG" for merge commits).
|
||||
|
||||
;; When `global-git-commit-mode' is enabled, which it is by default,
|
||||
;; then opening such a file causes the features described below, to
|
||||
@@ -76,7 +77,7 @@
|
||||
;; Aborting the commit does not cause the message to be lost, but
|
||||
;; relying solely on the file not being tampered with is risky. This
|
||||
;; package additionally stores all aborted messages for the duration
|
||||
;; of the current session (i.e. until you close Emacs). To get back
|
||||
;; of the current session (i.e., until you close Emacs). To get back
|
||||
;; an aborted message use M-p and M-n while editing a message.
|
||||
;;
|
||||
;; M-p Replace the buffer contents with the previous message
|
||||
@@ -86,17 +87,10 @@
|
||||
;; M-n Replace the buffer contents with the next message from
|
||||
;; the message ring, after storing the current content.
|
||||
|
||||
;; Some support for pseudo headers as used in some projects is
|
||||
;; provided by these commands:
|
||||
;; Support for inserting Git trailers (as described in the manpage
|
||||
;; git-interpret-trailers(1)) is available.
|
||||
;;
|
||||
;; C-c C-s Insert a Signed-off-by header.
|
||||
;; C-c C-a Insert a Acked-by header.
|
||||
;; C-c C-m Insert a Modified-by header.
|
||||
;; C-c C-t Insert a Tested-by header.
|
||||
;; C-c C-r Insert a Reviewed-by header.
|
||||
;; C-c C-o Insert a Cc header.
|
||||
;; C-c C-p Insert a Reported-by header.
|
||||
;; C-c C-i Insert a Suggested-by header.
|
||||
;; C-c C-i Insert a trailer selected from a transient menu.
|
||||
|
||||
;; When Git requests a commit message from the user, it does so by
|
||||
;; having her edit a file which initially contains some comments,
|
||||
@@ -117,26 +111,30 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'seq)
|
||||
(require 'compat)
|
||||
(require 'subr-x)
|
||||
|
||||
(when (and (featurep' seq)
|
||||
(not (fboundp 'seq-keep)))
|
||||
(unload-feature 'seq 'force))
|
||||
(require 'seq)
|
||||
|
||||
(require 'log-edit)
|
||||
(require 'ring)
|
||||
(require 'rx)
|
||||
(require 'server)
|
||||
(require 'transient)
|
||||
(require 'with-editor)
|
||||
|
||||
;; For historic reasons Magit isn't a hard dependency.
|
||||
(unless (and (require 'magit-base nil t)
|
||||
(require 'magit-git nil t))
|
||||
(declare-function magit-completing-read "magit-base"
|
||||
( prompt collection &optional predicate require-match
|
||||
initial-input hist def fallback))
|
||||
(declare-function magit-expand-git-file-name "magit-git" (filename))
|
||||
(declare-function magit-git-lines "magit-git" (&rest args))
|
||||
(declare-function magit-hook-custom-get "magit-base" (symbol))
|
||||
(declare-function magit-list-local-branch-names "magit-git" ()))
|
||||
(require 'magit-base nil t)
|
||||
(require 'magit-git nil t)
|
||||
(declare-function magit-completing-read "magit-base"
|
||||
( prompt collection &optional predicate require-match
|
||||
initial-input hist def fallback))
|
||||
(declare-function magit-expand-git-file-name "magit-git" (filename))
|
||||
(declare-function magit-git-lines "magit-git" (&rest args))
|
||||
(declare-function magit-hook-custom-get "magit-base" (symbol))
|
||||
(declare-function magit-list-local-branch-names "magit-git" ())
|
||||
|
||||
(defvar diff-default-read-only)
|
||||
(defvar flyspell-generic-check-word-predicate)
|
||||
@@ -182,6 +180,7 @@ full loading."
|
||||
|
||||
(defcustom git-commit-major-mode #'text-mode
|
||||
"Major mode used to edit Git commit messages.
|
||||
|
||||
The major mode configured here is turned on by the minor mode
|
||||
`git-commit-mode'."
|
||||
:group 'git-commit
|
||||
@@ -205,8 +204,7 @@ The major mode configured here is turned on by the minor mode
|
||||
git-commit-setup-changelog-support
|
||||
git-commit-turn-on-auto-fill
|
||||
git-commit-propertize-diff
|
||||
bug-reference-mode
|
||||
with-editor-usage-message)
|
||||
bug-reference-mode)
|
||||
"Hook run at the end of `git-commit-setup'."
|
||||
:group 'git-commit
|
||||
:type 'hook
|
||||
@@ -218,8 +216,7 @@ The major mode configured here is turned on by the minor mode
|
||||
git-commit-turn-on-orglink
|
||||
git-commit-turn-on-flyspell
|
||||
git-commit-propertize-diff
|
||||
bug-reference-mode
|
||||
with-editor-usage-message))
|
||||
bug-reference-mode))
|
||||
|
||||
(defcustom git-commit-post-finish-hook nil
|
||||
"Hook run after the user finished writing a commit message.
|
||||
@@ -230,10 +227,10 @@ to edit a commit message. If a commit is created without the
|
||||
user typing a message into a buffer, then this hook is not run.
|
||||
|
||||
This hook is not run until the new commit has been created. If
|
||||
doing so takes Git longer than one second, then this hook isn't
|
||||
run at all. For certain commands such as `magit-rebase-continue'
|
||||
this hook is never run because doing so would lead to a race
|
||||
condition.
|
||||
that takes Git longer than `git-commit-post-finish-hook-timeout'
|
||||
seconds, then this hook isn't run at all. For certain commands
|
||||
such as `magit-rebase-continue' this hook is never run because
|
||||
doing so would lead to a race condition.
|
||||
|
||||
This hook is only run if `magit' is available.
|
||||
|
||||
@@ -242,6 +239,17 @@ Also see `magit-post-commit-hook'."
|
||||
:type 'hook
|
||||
:get (and (featurep 'magit-base) #'magit-hook-custom-get))
|
||||
|
||||
(defcustom git-commit-post-finish-hook-timeout 1
|
||||
"Time in seconds to wait for git to create a commit.
|
||||
|
||||
The hook `git-commit-post-finish-hook' (which see) is run only
|
||||
after git is done creating a commit. If it takes longer than
|
||||
`git-commit-post-finish-hook-timeout' seconds to create the
|
||||
commit, then the hook is not run at all."
|
||||
:group 'git-commit
|
||||
:safe 'numberp
|
||||
:type 'number)
|
||||
|
||||
(defcustom git-commit-finish-query-functions
|
||||
'(git-commit-check-style-conventions)
|
||||
"List of functions called to query before performing commit.
|
||||
@@ -261,6 +269,7 @@ usually honor this wish and return non-nil."
|
||||
|
||||
(defcustom git-commit-style-convention-checks '(non-empty-second-line)
|
||||
"List of checks performed by `git-commit-check-style-conventions'.
|
||||
|
||||
Valid members are `non-empty-second-line' and `overlong-summary-line'.
|
||||
That function is a member of `git-commit-finish-query-functions'."
|
||||
:options '(non-empty-second-line overlong-summary-line)
|
||||
@@ -280,36 +289,29 @@ to consider doing so."
|
||||
:safe 'numberp
|
||||
:type 'number)
|
||||
|
||||
(defcustom git-commit-fill-column nil
|
||||
"Override `fill-column' in commit message buffers.
|
||||
(defcustom git-commit-trailers
|
||||
'("Acked-by"
|
||||
"Modified-by"
|
||||
"Reviewed-by"
|
||||
"Signed-off-by"
|
||||
"Tested-by"
|
||||
"Cc"
|
||||
"Reported-by"
|
||||
"Suggested-by"
|
||||
"Co-authored-by"
|
||||
"Co-developed-by")
|
||||
"A list of Git trailers to be highlighted.
|
||||
|
||||
If this is non-nil, then it should be an integer. If that is the
|
||||
case and the buffer-local value of `fill-column' is not already
|
||||
set by the time `git-commit-turn-on-auto-fill' is called as a
|
||||
member of `git-commit-setup-hook', then that function sets the
|
||||
buffer-local value of `fill-column' to the value of this option.
|
||||
|
||||
This option exists mostly for historic reasons. If you are not
|
||||
already using it, then you probably shouldn't start doing so."
|
||||
:group 'git-commit
|
||||
:safe 'numberp
|
||||
:type '(choice (const :tag "use regular fill-column")
|
||||
number))
|
||||
|
||||
(make-obsolete-variable 'git-commit-fill-column 'fill-column
|
||||
"Magit 2.11.0" 'set)
|
||||
|
||||
(defcustom git-commit-known-pseudo-headers
|
||||
'("Signed-off-by" "Acked-by" "Modified-by" "Cc"
|
||||
"Suggested-by" "Reported-by" "Tested-by" "Reviewed-by"
|
||||
"Co-authored-by" "Co-developed-by")
|
||||
"A list of Git pseudo headers to be highlighted."
|
||||
See also manpage git-interpret-trailer(1). This package does
|
||||
not use that Git command, but the initial description still
|
||||
serves as a good introduction."
|
||||
:group 'git-commit
|
||||
:safe (lambda (val) (and (listp val) (seq-every-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. If
|
||||
Magit isn't available, then setting this to a non-nil value has
|
||||
@@ -347,17 +349,14 @@ no effect."
|
||||
In this context a \"keyword\" is text surrounded by brackets."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(define-obsolete-face-alias 'git-commit-note
|
||||
'git-commit-keyword "Git-Commit 3.0.0")
|
||||
|
||||
(defface git-commit-pseudo-header
|
||||
'((t :inherit font-lock-string-face))
|
||||
"Face used for pseudo headers in commit messages."
|
||||
(defface git-commit-trailer-token
|
||||
'((t :inherit font-lock-keyword-face))
|
||||
"Face used for Git trailer tokens in commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-known-pseudo-header
|
||||
'((t :inherit font-lock-keyword-face))
|
||||
"Face used for the keywords of known pseudo headers in commit messages."
|
||||
(defface git-commit-trailer-value
|
||||
'((t :inherit font-lock-string-face))
|
||||
"Face used for Git trailer values in commit messages."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-branch-local
|
||||
@@ -367,9 +366,6 @@ In this context a \"keyword\" is text surrounded by brackets."
|
||||
"Face used for names of local branches in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(define-obsolete-face-alias 'git-commit-comment-branch
|
||||
'git-commit-comment-branch-local "Git-Commit 2.12.0")
|
||||
|
||||
(defface git-commit-comment-branch-remote
|
||||
(if (featurep 'magit)
|
||||
'((t :inherit magit-branch-remote))
|
||||
@@ -384,12 +380,12 @@ This is only used if Magit is available."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-heading
|
||||
'((t :inherit git-commit-known-pseudo-header))
|
||||
'((t :inherit git-commit-trailer-token))
|
||||
"Face used for headings in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
(defface git-commit-comment-file
|
||||
'((t :inherit git-commit-pseudo-header))
|
||||
'((t :inherit git-commit-trailer-value))
|
||||
"Face used for file names in commit message comments."
|
||||
:group 'git-commit-faces)
|
||||
|
||||
@@ -400,24 +396,30 @@ This is only used if Magit is available."
|
||||
|
||||
;;; Keymap
|
||||
|
||||
(defvar git-commit-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "M-p") #'git-commit-prev-message)
|
||||
(define-key map (kbd "M-n") #'git-commit-next-message)
|
||||
(define-key map (kbd "C-c M-p") #'git-commit-search-message-backward)
|
||||
(define-key map (kbd "C-c M-n") #'git-commit-search-message-forward)
|
||||
(define-key map (kbd "C-c C-i") #'git-commit-insert-pseudo-header)
|
||||
(define-key map (kbd "C-c C-a") #'git-commit-ack)
|
||||
(define-key map (kbd "C-c M-i") #'git-commit-suggested)
|
||||
(define-key map (kbd "C-c C-m") #'git-commit-modified)
|
||||
(define-key map (kbd "C-c C-o") #'git-commit-cc)
|
||||
(define-key map (kbd "C-c C-p") #'git-commit-reported)
|
||||
(define-key map (kbd "C-c C-r") #'git-commit-review)
|
||||
(define-key map (kbd "C-c C-s") #'git-commit-signoff)
|
||||
(define-key map (kbd "C-c C-t") #'git-commit-test)
|
||||
(define-key map (kbd "C-c M-s") #'git-commit-save-message)
|
||||
map)
|
||||
"Key map used by `git-commit-mode'.")
|
||||
(defvar-keymap git-commit-redundant-bindings
|
||||
:doc "Bindings made redundant by `git-commit-insert-trailer'.
|
||||
This keymap is used as the parent of `git-commit-mode-map',
|
||||
to avoid upsetting muscle-memory. If you would rather avoid
|
||||
the redundant bindings, then set this to nil, before loading
|
||||
`git-commit'."
|
||||
"C-c C-a" #'git-commit-ack
|
||||
"C-c M-i" #'git-commit-suggested
|
||||
"C-c C-m" #'git-commit-modified
|
||||
"C-c C-o" #'git-commit-cc
|
||||
"C-c C-p" #'git-commit-reported
|
||||
"C-c C-r" #'git-commit-review
|
||||
"C-c C-s" #'git-commit-signoff
|
||||
"C-c C-t" #'git-commit-test)
|
||||
|
||||
(defvar-keymap git-commit-mode-map
|
||||
:doc "Keymap used by `git-commit-mode'."
|
||||
:parent git-commit-redundant-bindings
|
||||
"M-p" #'git-commit-prev-message
|
||||
"M-n" #'git-commit-next-message
|
||||
"C-c M-p" #'git-commit-search-message-backward
|
||||
"C-c M-n" #'git-commit-search-message-forward
|
||||
"C-c C-i" #'git-commit-insert-trailer
|
||||
"C-c M-s" #'git-commit-save-message)
|
||||
|
||||
;;; Menu
|
||||
|
||||
@@ -428,26 +430,27 @@ This is only used if Magit is available."
|
||||
["Previous" git-commit-prev-message t]
|
||||
["Next" git-commit-next-message t]
|
||||
"-"
|
||||
["Ack" git-commit-ack :active t
|
||||
:help "Insert an 'Acked-by' header"]
|
||||
["Sign-Off" git-commit-signoff :active t
|
||||
:help "Insert a 'Signed-off-by' header"]
|
||||
["Modified-by" git-commit-modified :active t
|
||||
:help "Insert a 'Modified-by' header"]
|
||||
["Tested-by" git-commit-test :active t
|
||||
:help "Insert a 'Tested-by' header"]
|
||||
["Reviewed-by" git-commit-review :active t
|
||||
:help "Insert a 'Reviewed-by' header"]
|
||||
["Ack" git-commit-ack t
|
||||
:help "Insert an 'Acked-by' trailer"]
|
||||
["Modified-by" git-commit-modified t
|
||||
:help "Insert a 'Modified-by' trailer"]
|
||||
["Reviewed-by" git-commit-review t
|
||||
:help "Insert a 'Reviewed-by' trailer"]
|
||||
["Sign-Off" git-commit-signoff t
|
||||
:help "Insert a 'Signed-off-by' trailer"]
|
||||
["Tested-by" git-commit-test t
|
||||
:help "Insert a 'Tested-by' trailer"]
|
||||
"-"
|
||||
["CC" git-commit-cc t
|
||||
:help "Insert a 'Cc' header"]
|
||||
["Reported" git-commit-reported :active t
|
||||
:help "Insert a 'Reported-by' header"]
|
||||
:help "Insert a 'Cc' trailer"]
|
||||
["Reported" git-commit-reported t
|
||||
:help "Insert a 'Reported-by' trailer"]
|
||||
["Suggested" git-commit-suggested t
|
||||
:help "Insert a 'Suggested-by' header"]
|
||||
:help "Insert a 'Suggested-by' trailer"]
|
||||
["Co-authored-by" git-commit-co-authored t
|
||||
:help "Insert a 'Co-authored-by' header"]
|
||||
:help "Insert a 'Co-authored-by' trailer"]
|
||||
["Co-developed-by" git-commit-co-developed t
|
||||
:help "Insert a 'Co-developed-by' header"]
|
||||
:help "Insert a 'Co-developed-by' trailer"]
|
||||
"-"
|
||||
["Save" git-commit-save-message t]
|
||||
["Cancel" with-editor-cancel t]
|
||||
@@ -465,16 +468,16 @@ This is only used if Magit is available."
|
||||
(add-to-list 'with-editor-file-name-history-exclude git-commit-filename-regexp)
|
||||
|
||||
(defun git-commit-setup-font-lock-in-buffer ()
|
||||
(and buffer-file-name
|
||||
(string-match-p git-commit-filename-regexp buffer-file-name)
|
||||
(git-commit-setup-font-lock)))
|
||||
(when (and buffer-file-name
|
||||
(string-match-p git-commit-filename-regexp buffer-file-name))
|
||||
(git-commit-setup-font-lock)))
|
||||
|
||||
(add-hook 'after-change-major-mode-hook #'git-commit-setup-font-lock-in-buffer)
|
||||
|
||||
(defun git-commit-setup-check-buffer ()
|
||||
(and buffer-file-name
|
||||
(string-match-p git-commit-filename-regexp buffer-file-name)
|
||||
(git-commit-setup)))
|
||||
(when (and buffer-file-name
|
||||
(string-match-p git-commit-filename-regexp buffer-file-name))
|
||||
(git-commit-setup)))
|
||||
|
||||
(defvar git-commit-mode)
|
||||
|
||||
@@ -507,29 +510,35 @@ This is only used if Magit is available."
|
||||
(when (eq system-type 'windows-nt)
|
||||
(add-hook 'find-file-not-found-functions #'git-commit-file-not-found))
|
||||
|
||||
(defconst git-commit-usage-message "\
|
||||
(defconst git-commit-default-usage-message "\
|
||||
Type \\[with-editor-finish] to finish, \
|
||||
\\[with-editor-cancel] to cancel, and \
|
||||
\\[git-commit-prev-message] and \\[git-commit-next-message] \
|
||||
to recover older messages")
|
||||
|
||||
(defvar git-commit-usage-message git-commit-default-usage-message
|
||||
"Message displayed when editing a commit message.
|
||||
When this is nil, then `with-editor-usage-message' is displayed
|
||||
instead. One of these messages has to be displayed; otherwise
|
||||
the user gets to see the message displayed by `server-execute'.
|
||||
That message is misleading and because we cannot prevent it from
|
||||
being displayed, we have to immediately show another message to
|
||||
prevent the user from seeing it.")
|
||||
|
||||
(defvar git-commit-header-line-format nil
|
||||
"If non-nil, header line format used by `git-commit-mode'.
|
||||
Used as the local value of `header-line-format', in buffer using
|
||||
`git-commit-mode'. If it is a string, then it is passed through
|
||||
`substitute-command-keys' first. A useful setting may be:
|
||||
(setq git-commit-header-line-format git-commit-default-usage-message)
|
||||
(setq git-commit-usage-message nil) ; show a shorter message")
|
||||
|
||||
(defun git-commit-setup ()
|
||||
(when (fboundp 'magit-toplevel)
|
||||
;; `magit-toplevel' is autoloaded and defined in magit-git.el,
|
||||
;; That library declares this functions without loading
|
||||
;; magit-process.el, which defines it.
|
||||
(require 'magit-process nil t))
|
||||
(when git-commit-major-mode
|
||||
(let ((auto-mode-alist (list (cons (concat "\\`"
|
||||
(regexp-quote buffer-file-name)
|
||||
"\\'")
|
||||
git-commit-major-mode)))
|
||||
;; The major-mode hook might want to consult these minor
|
||||
;; modes, while the minor-mode hooks might want to consider
|
||||
;; the major mode.
|
||||
(git-commit-mode t)
|
||||
(with-editor-mode t))
|
||||
(normal-mode t)))
|
||||
;; Pretend that git-commit-mode is a major-mode,
|
||||
;; so that directory-local settings can be used.
|
||||
(let ((default-directory
|
||||
@@ -546,9 +555,26 @@ to recover older messages")
|
||||
(major-mode 'git-commit-mode)) ; trick dir-locals-collect-variables
|
||||
(hack-dir-local-variables)
|
||||
(hack-local-variables-apply)))
|
||||
;; Show our own message using our hook.
|
||||
(when git-commit-major-mode
|
||||
(let ((auto-mode-alist
|
||||
;; `set-auto-mode--apply-alist' removes the remote part from
|
||||
;; the file-name before looking it up in `auto-mode-alist'.
|
||||
;; For our temporary entry to be found, we have to modify the
|
||||
;; file-name the same way.
|
||||
(list (cons (concat "\\`"
|
||||
(regexp-quote
|
||||
(or (file-remote-p buffer-file-name 'localname)
|
||||
buffer-file-name))
|
||||
"\\'")
|
||||
git-commit-major-mode)))
|
||||
;; The major-mode hook might want to consult these minor
|
||||
;; modes, while the minor-mode hooks might want to consider
|
||||
;; the major mode.
|
||||
(git-commit-mode t)
|
||||
(with-editor-mode t))
|
||||
(normal-mode t)))
|
||||
;; Below we instead explicitly show a message.
|
||||
(setq with-editor-show-usage nil)
|
||||
(setq with-editor-usage-message git-commit-usage-message)
|
||||
(unless with-editor-mode
|
||||
;; Maybe already enabled when using `shell-command' or an Emacs shell.
|
||||
(with-editor-mode 1))
|
||||
@@ -588,6 +614,12 @@ to recover older messages")
|
||||
(open-line 1)))
|
||||
(with-demoted-errors "Error running git-commit-setup-hook: %S"
|
||||
(run-hooks 'git-commit-setup-hook))
|
||||
(when git-commit-usage-message
|
||||
(setq with-editor-usage-message git-commit-usage-message))
|
||||
(with-editor-usage-message)
|
||||
(when-let ((format git-commit-header-line-format))
|
||||
(setq header-line-format
|
||||
(if (stringp format) (substitute-command-keys format) format)))
|
||||
(set-buffer-modified-p nil))
|
||||
|
||||
(defun git-commit-run-post-finish-hook (previous)
|
||||
@@ -596,7 +628,8 @@ to recover older messages")
|
||||
(fboundp 'magit-rev-parse))
|
||||
(cl-block nil
|
||||
(let ((break (time-add (current-time)
|
||||
(seconds-to-time 1))))
|
||||
(seconds-to-time
|
||||
git-commit-post-finish-hook-timeout))))
|
||||
(while (equal (magit-rev-parse "HEAD") previous)
|
||||
(if (time-less-p (current-time) break)
|
||||
(sit-for 0.01)
|
||||
@@ -621,13 +654,7 @@ Don't use it directly, instead enable `global-git-commit-mode'."
|
||||
(setq-local paragraph-start (concat paragraph-start "\\|\\*\\|(")))
|
||||
|
||||
(defun git-commit-turn-on-auto-fill ()
|
||||
"Unconditionally turn on Auto Fill mode.
|
||||
If `git-commit-fill-column' is non-nil, and `fill-column'
|
||||
doesn't already have a buffer-local value, then set that
|
||||
to `git-commit-fill-column'."
|
||||
(when (and (numberp git-commit-fill-column)
|
||||
(not (local-variable-p 'fill-column)))
|
||||
(setq fill-column git-commit-fill-column))
|
||||
"Unconditionally turn on Auto Fill mode."
|
||||
(setq-local comment-auto-fill-only-comments nil)
|
||||
(turn-on-auto-fill))
|
||||
|
||||
@@ -793,12 +820,13 @@ Save current message first."
|
||||
(unless (eq (char-before) ?\n)
|
||||
(insert ?\n))
|
||||
(setq str (buffer-string)))
|
||||
(unless (string-match "\\`[ \t\n\r]*\\'" str)
|
||||
(when (string-match "\\`\n\\{2,\\}" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
(when (string-match "\n\\{2,\\}\\'" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
str)))
|
||||
(and (not (string-match "\\`[ \t\n\r]*\\'" str))
|
||||
(progn
|
||||
(when (string-match "\\`\n\\{2,\\}" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
(when (string-match "\n\\{2,\\}\\'" str)
|
||||
(setq str (replace-match "\n" t t str)))
|
||||
str))))
|
||||
|
||||
;;; Utilities
|
||||
|
||||
@@ -807,11 +835,18 @@ Save current message first."
|
||||
(magit-git-executable)
|
||||
"git"))
|
||||
|
||||
;;; Headers
|
||||
;;; Trailers
|
||||
|
||||
(transient-define-prefix git-commit-insert-pseudo-header ()
|
||||
"Insert a commit message pseudo header."
|
||||
[["Insert ... by yourself"
|
||||
(transient-define-prefix git-commit-insert-trailer ()
|
||||
"Insert a commit message trailer.
|
||||
|
||||
See also manpage git-interpret-trailer(1). This command does
|
||||
not use that Git command, but the initial description still
|
||||
serves as a good introduction."
|
||||
[[:description (lambda ()
|
||||
(cond (prefix-arg
|
||||
"Insert ... by someone ")
|
||||
("Insert ... by yourself")))
|
||||
("a" "Ack" git-commit-ack)
|
||||
("m" "Modified" git-commit-modified)
|
||||
("r" "Reviewed" git-commit-review)
|
||||
@@ -825,74 +860,90 @@ Save current message first."
|
||||
("C-d" "Co-developed" git-commit-co-developed)]])
|
||||
|
||||
(defun git-commit-ack (name mail)
|
||||
"Insert a header acknowledging that you have looked at the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Acked-by" name mail))
|
||||
"Insert a trailer acknowledging that you have looked at the commit."
|
||||
(interactive (git-commit-get-ident "Acked-by"))
|
||||
(git-commit--insert-ident-trailer "Acked-by" name mail))
|
||||
|
||||
(defun git-commit-modified (name mail)
|
||||
"Insert a header to signal that you have modified the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Modified-by" name mail))
|
||||
"Insert a trailer to signal that you have modified the commit."
|
||||
(interactive (git-commit-get-ident "Modified-by"))
|
||||
(git-commit--insert-ident-trailer "Modified-by" name mail))
|
||||
|
||||
(defun git-commit-review (name mail)
|
||||
"Insert a header acknowledging that you have reviewed the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Reviewed-by" name mail))
|
||||
"Insert a trailer acknowledging that you have reviewed the commit.
|
||||
With a prefix argument, prompt for another person who performed a
|
||||
review."
|
||||
(interactive (git-commit-get-ident "Reviewed-by"))
|
||||
(git-commit--insert-ident-trailer "Reviewed-by" name mail))
|
||||
|
||||
(defun git-commit-signoff (name mail)
|
||||
"Insert a header to sign off the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Signed-off-by" name mail))
|
||||
"Insert a trailer to sign off the commit.
|
||||
With a prefix argument, prompt for another person who signed off."
|
||||
(interactive (git-commit-get-ident "Signed-off-by"))
|
||||
(git-commit--insert-ident-trailer "Signed-off-by" name mail))
|
||||
|
||||
(defun git-commit-test (name mail)
|
||||
"Insert a header acknowledging that you have tested the commit."
|
||||
(interactive (git-commit-self-ident))
|
||||
(git-commit-insert-header "Tested-by" name mail))
|
||||
"Insert a trailer acknowledging that you have tested the commit.
|
||||
With a prefix argument, prompt for another person who tested."
|
||||
(interactive (git-commit-get-ident "Tested-by"))
|
||||
(git-commit--insert-ident-trailer "Tested-by" name mail))
|
||||
|
||||
(defun git-commit-cc (name mail)
|
||||
"Insert a header mentioning someone who might be interested."
|
||||
"Insert a trailer mentioning someone who might be interested."
|
||||
(interactive (git-commit-read-ident "Cc"))
|
||||
(git-commit-insert-header "Cc" name mail))
|
||||
(git-commit--insert-ident-trailer "Cc" name mail))
|
||||
|
||||
(defun git-commit-reported (name mail)
|
||||
"Insert a header mentioning the person who reported the issue."
|
||||
"Insert a trailer mentioning the person who reported the issue."
|
||||
(interactive (git-commit-read-ident "Reported-by"))
|
||||
(git-commit-insert-header "Reported-by" name mail))
|
||||
(git-commit--insert-ident-trailer "Reported-by" name mail))
|
||||
|
||||
(defun git-commit-suggested (name mail)
|
||||
"Insert a header mentioning the person who suggested the change."
|
||||
"Insert a trailer mentioning the person who suggested the change."
|
||||
(interactive (git-commit-read-ident "Suggested-by"))
|
||||
(git-commit-insert-header "Suggested-by" name mail))
|
||||
(git-commit--insert-ident-trailer "Suggested-by" name mail))
|
||||
|
||||
(defun git-commit-co-authored (name mail)
|
||||
"Insert a header mentioning the person who co-authored the commit."
|
||||
"Insert a trailer mentioning the person who co-authored the commit."
|
||||
(interactive (git-commit-read-ident "Co-authored-by"))
|
||||
(git-commit-insert-header "Co-authored-by" name mail))
|
||||
(git-commit--insert-ident-trailer "Co-authored-by" name mail))
|
||||
|
||||
(defun git-commit-co-developed (name mail)
|
||||
"Insert a header mentioning the person who co-developed the commit."
|
||||
"Insert a trailer mentioning the person who co-developed the commit."
|
||||
(interactive (git-commit-read-ident "Co-developed-by"))
|
||||
(git-commit-insert-header "Co-developed-by" name mail))
|
||||
(git-commit--insert-ident-trailer "Co-developed-by" name mail))
|
||||
|
||||
(defun git-commit-self-ident ()
|
||||
(list (or (getenv "GIT_AUTHOR_NAME")
|
||||
(getenv "GIT_COMMITTER_NAME")
|
||||
(with-demoted-errors "Error running 'git config user.name': %S"
|
||||
(car (process-lines
|
||||
(git-commit-executable) "config" "user.name")))
|
||||
user-full-name
|
||||
(read-string "Name: "))
|
||||
(or (getenv "GIT_AUTHOR_EMAIL")
|
||||
(getenv "GIT_COMMITTER_EMAIL")
|
||||
(getenv "EMAIL")
|
||||
(with-demoted-errors "Error running 'git config user.email': %S"
|
||||
(car (process-lines
|
||||
(git-commit-executable) "config" "user.email")))
|
||||
(read-string "Email: "))))
|
||||
(defun git-commit-get-ident (&optional prompt)
|
||||
"Return name and email of the user or read another name and email.
|
||||
If PROMPT and `current-prefix-arg' are both non-nil, read name
|
||||
and email using `git-commit-read-ident' (which see), otherwise
|
||||
return name and email of the current user (you)."
|
||||
(if (and prompt current-prefix-arg)
|
||||
(git-commit-read-ident prompt)
|
||||
(list (or (getenv "GIT_AUTHOR_NAME")
|
||||
(getenv "GIT_COMMITTER_NAME")
|
||||
(with-demoted-errors "Error running 'git config user.name': %S"
|
||||
(car (process-lines
|
||||
(git-commit-executable) "config" "user.name")))
|
||||
user-full-name
|
||||
(read-string "Name: "))
|
||||
(or (getenv "GIT_AUTHOR_EMAIL")
|
||||
(getenv "GIT_COMMITTER_EMAIL")
|
||||
(getenv "EMAIL")
|
||||
(with-demoted-errors "Error running 'git config user.email': %S"
|
||||
(car (process-lines
|
||||
(git-commit-executable) "config" "user.email")))
|
||||
(read-string "Email: ")))))
|
||||
|
||||
(defalias 'git-commit-self-ident #'git-commit-get-ident)
|
||||
|
||||
(defvar git-commit-read-ident-history nil)
|
||||
|
||||
(defun git-commit-read-ident (prompt)
|
||||
"Read a name and email, prompting with PROMPT, and return them.
|
||||
If Magit is available, read them using a single prompt, offering
|
||||
past commit authors as completion candidates. The input must
|
||||
have the form \"NAME <EMAIL>\"."
|
||||
(if (require 'magit-git nil t)
|
||||
(let ((str (magit-completing-read
|
||||
prompt
|
||||
@@ -908,20 +959,34 @@ Save current message first."
|
||||
(list (read-string "Name: ")
|
||||
(read-string "Email: "))))
|
||||
|
||||
(defun git-commit-insert-header (header name email)
|
||||
(setq header (format "%s: %s <%s>" header name email))
|
||||
(defun git-commit--insert-ident-trailer (trailer name email)
|
||||
(git-commit--insert-trailer trailer (format "%s <%s>" name email)))
|
||||
|
||||
(defun git-commit--insert-trailer (trailer value)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(cond ((re-search-backward "^[-a-zA-Z]+: [^<]+? <[^>]+>" nil t)
|
||||
(end-of-line)
|
||||
(insert ?\n header)
|
||||
(unless (= (char-after) ?\n)
|
||||
(insert ?\n)))
|
||||
(t
|
||||
(while (re-search-backward (concat "^" comment-start) nil t))
|
||||
(unless (looking-back "\n\n" nil)
|
||||
(insert ?\n))
|
||||
(insert header ?\n)))
|
||||
(let ((string (format "%s: %s" trailer value))
|
||||
(leading-comment-end nil))
|
||||
;; Make sure we skip forward past any leading comments.
|
||||
(goto-char (point-min))
|
||||
(while (looking-at comment-start)
|
||||
(forward-line))
|
||||
(setq leading-comment-end (point))
|
||||
(goto-char (point-max))
|
||||
(cond
|
||||
;; Look backwards for existing trailers.
|
||||
((re-search-backward (git-commit--trailer-regexp) nil t)
|
||||
(end-of-line)
|
||||
(insert ?\n string)
|
||||
(unless (= (char-after) ?\n)
|
||||
(insert ?\n)))
|
||||
;; Or place the new trailer right before the first non-leading
|
||||
;; comments.
|
||||
(t
|
||||
(while (re-search-backward (concat "^" comment-start)
|
||||
leading-comment-end t))
|
||||
(unless (looking-back "\n\n" nil)
|
||||
(insert ?\n))
|
||||
(insert string ?\n))))
|
||||
(unless (or (eobp) (= (char-after) ?\n))
|
||||
(insert ?\n))))
|
||||
|
||||
@@ -941,6 +1006,11 @@ something like:
|
||||
\"NOTES_EDITMSG\")
|
||||
(setq git-commit-need-summary-line nil))))")
|
||||
|
||||
(defun git-commit--trailer-regexp ()
|
||||
(format
|
||||
"^\\(?:\\(%s:\\)\\( .*\\)\\|\\([-a-zA-Z]+\\): \\([^<\n]+? <[^>\n]+>\\)\\)"
|
||||
(regexp-opt git-commit-trailers)))
|
||||
|
||||
(defun git-commit-summary-regexp ()
|
||||
(if git-commit-need-summary-line
|
||||
(concat
|
||||
@@ -979,11 +1049,12 @@ Added to `font-lock-extend-region-functions'."
|
||||
"Also fontified outside of comments in `git-commit-font-lock-keywords-2'.")
|
||||
|
||||
(defconst git-commit-font-lock-keywords-1
|
||||
'(;; Pseudo headers
|
||||
(eval . `(,(format "^\\(%s:\\)\\( .*\\)"
|
||||
(regexp-opt git-commit-known-pseudo-headers))
|
||||
(1 'git-commit-known-pseudo-header)
|
||||
(2 'git-commit-pseudo-header)))
|
||||
'(;; Trailers
|
||||
(eval . `(,(git-commit--trailer-regexp)
|
||||
(1 'git-commit-trailer-token)
|
||||
(2 'git-commit-trailer-value)
|
||||
(3 'git-commit-trailer-token)
|
||||
(4 'git-commit-trailer-value)))
|
||||
;; Summary
|
||||
(eval . `(,(git-commit-summary-regexp)
|
||||
(1 'git-commit-summary)))
|
||||
@@ -1011,11 +1082,12 @@ Added to `font-lock-extend-region-functions'."
|
||||
(1 'git-commit-comment-action t t)
|
||||
(2 'git-commit-comment-file t)))
|
||||
;; "commit HASH"
|
||||
(eval . `(,(rx bol "commit " (1+ alnum) eol)
|
||||
(0 'git-commit-pseudo-header)))
|
||||
(eval . '("^commit [[:alnum:]]+$"
|
||||
(0 'git-commit-trailer-value)))
|
||||
;; `git-commit-comment-headings' (but not in commented lines)
|
||||
(eval . `(,(rx-to-string `(seq bol (or ,@git-commit-comment-headings) (1+ blank) (1+ nonl) eol))
|
||||
(0 'git-commit-pseudo-header)))))
|
||||
(eval . `(,(format "\\(?:^%s[[:blank:]]+.+$\\)"
|
||||
(regexp-opt git-commit-comment-headings))
|
||||
(0 'git-commit-trailer-value)))))
|
||||
|
||||
(defconst git-commit-font-lock-keywords-3
|
||||
`(,@git-commit-font-lock-keywords-2
|
||||
@@ -1070,8 +1142,16 @@ Added to `font-lock-extend-region-functions'."
|
||||
(buffer-substring (point) (line-end-position)))))
|
||||
"#"))
|
||||
(setq-local comment-start-skip (format "^%s+[\s\t]*" comment-start))
|
||||
(setq-local comment-end "")
|
||||
(setq-local comment-end-skip "\n")
|
||||
(setq-local comment-use-syntax nil)
|
||||
(when (and (derived-mode-p 'markdown-mode)
|
||||
(fboundp 'markdown-fill-paragraph))
|
||||
(setq-local fill-paragraph-function
|
||||
(lambda (&optional justify)
|
||||
(and (not (= (char-after (line-beginning-position))
|
||||
(aref comment-start 0)))
|
||||
(markdown-fill-paragraph justify)))))
|
||||
(setq-local git-commit--branch-name-regexp
|
||||
(if (and (featurep 'magit-git)
|
||||
;; When using cygwin git, we may end up in a
|
||||
@@ -1131,7 +1211,7 @@ Added to `font-lock-extend-region-functions'."
|
||||
(define-derived-mode git-commit-elisp-text-mode text-mode "ElText"
|
||||
"Major mode for editing commit messages of elisp projects.
|
||||
This is intended for use as `git-commit-major-mode' for projects
|
||||
that expect `symbols' to look like this. I.e. like they look in
|
||||
that expect `symbols' to look like this. I.e., like they look in
|
||||
Elisp doc-strings, including this one. Unlike in doc-strings,
|
||||
\"strings\" also look different than the other text."
|
||||
(setq font-lock-defaults '(git-commit-elisp-text-mode-keywords)))
|
||||
@@ -1142,5 +1222,27 @@ Elisp doc-strings, including this one. Unlike in doc-strings,
|
||||
("\"[^\"]*\"" (0 font-lock-string-face prepend))))
|
||||
|
||||
;;; _
|
||||
|
||||
(define-obsolete-function-alias
|
||||
'git-commit-insert-pseudo-header
|
||||
'git-commit-insert-trailer
|
||||
"git-commit 4.0.0")
|
||||
(define-obsolete-function-alias
|
||||
'git-commit-insert-header
|
||||
'git-commit--insert-ident-trailer
|
||||
"git-commit 4.0.0")
|
||||
(define-obsolete-variable-alias
|
||||
'git-commit-known-pseudo-headers
|
||||
'git-commit-trailer
|
||||
"git-commit 4.0.0")
|
||||
(define-obsolete-face-alias
|
||||
'git-commit-pseudo-header
|
||||
'git-commit-trailer-value
|
||||
"git-commit 4.0.0")
|
||||
(define-obsolete-face-alias
|
||||
'git-commit-known-pseudo-header
|
||||
'git-commit-trailer-token
|
||||
"git-commit 4.0.0")
|
||||
|
||||
(provide 'git-commit)
|
||||
;;; git-commit.el ends here
|
||||
|
||||
Reference in New Issue
Block a user