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

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

[elpa] externals/agitate f9dd3b3f91 41/67: Add agitate-vc-git-kill-commi


From: ELPA Syncer
Subject: [elpa] externals/agitate f9dd3b3f91 41/67: Add agitate-vc-git-kill-commit-message command
Date: Wed, 28 Sep 2022 16:57:28 -0400 (EDT)

branch: externals/agitate
commit f9dd3b3f91ccd22754a6bdabcbe6f48195dfa007
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add agitate-vc-git-kill-commit-message command
---
 README.org |  7 +++++++
 agitate.el | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/README.org b/README.org
index e50ee05df1..10fea286d5 100644
--- a/README.org
+++ b/README.org
@@ -165,6 +165,13 @@ think most of those are superfluous.  Less is more.
   Git repository.  Use the original ~vc-git-grep~ for its other
   features.
 
+#+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.
+
 #+findex: agitate-vc-git-push-prompt-for-remote
 + ~agitate-vc-git-push-prompt-for-remote~ :: Behave like ~vc-git-push~
   but prompt for a remote, if needed.  The meaning of =PROMPT= is the
diff --git a/agitate.el b/agitate.el
index 6d3e112aea..ac15422f9d 100644
--- a/agitate.el
+++ b/agitate.el
@@ -277,6 +277,29 @@ features."
         (completing-read "Select Git remote: " remotes nil t)
       (car remotes))))
 
+(defvar agitate--vc-git-kill-commit-message-history nil
+  "Minibuffer history of `agitate-vc-git-kill-commit-message'.")
+
+(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)))
+
+;;;###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.
+
+This is useful to quote a past commit message."
+  (interactive (list (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" "--"))
+     (buffer-substring-no-properties (point-min) (point-max)))))
+
 ;; TODO 2022-09-27: We can have something similar which prompts for a
 ;; branch to push to.  There are lots of possibilities.  The idea is
 ;; that the user can pick the function they are most likely to use as



reply via email to

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