branch: externals/agitate commit dce39b452cefbe6bb719a9ae4a89f2657026070a Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Make agitate-vc-git-kill-commit-message use completion --- README.org | 8 ++++---- agitate.el | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.org b/README.org index a2149f0584..74d4b68371 100644 --- a/README.org +++ b/README.org @@ -179,10 +179,10 @@ commits" are documented here: <https://www.conventionalcommits.org/en/v1.0.0/>. #+findex: agitate-vc-git-kill-commit-message + ~agitate-vc-git-kill-commit-message~ :: Append to ~kill-ring~ - message of commit with =HASH= identifier. Prompt for =HASH= as a - string. When point is in a log-view buffer, make the revision at - point the default value of the prompt. This is useful to quote a - past commit message. + message of commit with HASH identifier. q When called interactively, + prompt for =HASH= using minibuffer completion. When point is in a + log-view buffer, make the revision at point the default value of the + prompt. This is useful to quote a past commit message. #+findex: agitate-vc-git-push-prompt-for-remote + ~agitate-vc-git-push-prompt-for-remote~ :: Behave like ~vc-git-push~ diff --git a/agitate.el b/agitate.el index 164d0fae73..51f2f3df8c 100644 --- a/agitate.el +++ b/agitate.el @@ -326,22 +326,34 @@ arguments." (defun agitate--vc-git-kill-commit-message-prompt () "Helper prompt for `agitate-vc-git-kill-commit-message'." - (if-let ((default-value (cadr (log-view-current-entry (point) t)))) - (read-string (format "Commit HASH [%s]: " default-value) - nil 'agitate--vc-git-kill-commit-message-history default-value) - (read-string "Commit HASH: " nil 'agitate--vc-git-kill-commit-message-history))) + (let* ((default-value (cadr (log-view-current-entry (point) t))) + (prompt (if default-value + (format "Commit HASH [%s]: " default-value) + "Commit HASH: ")) + (default-directory (vc-root-dir))) + (completing-read + prompt + (process-lines vc-git-program "log" "--oneline" "--") + nil t nil + 'agitate--vc-git-kill-commit-message-history default-value))) ;;;###autoload (defun agitate-vc-git-kill-commit-message (hash) "Append to `kill-ring' message of commit with HASH identifier. -Prompt for HASH as a string. When point is in a log-view buffer, -make the revision at point the default value of the prompt. +When called interactively, prompt for HASH using minibuffer +completion. + +When point is in a log-view buffer, make the revision at point +the default value of the prompt. This is useful to quote a past commit message." - (interactive (list (agitate--vc-git-kill-commit-message-prompt))) + (interactive + (list + (agitate--vc-git-get-hash-from-string + (agitate--vc-git-kill-commit-message-prompt)))) (kill-new (with-temp-buffer - (apply 'vc-git-command t nil nil (list "log" hash "-1" "--stat" "--no-color" "--")) + (apply 'vc-git-command t nil nil (list "show" hash "--stat" "--no-color" "--")) (buffer-substring-no-properties (point-min) (point-max)))) (message "Added %s commit message to `kill-ring'" hash))