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

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

[elpa] externals/agitate 50251c7eff 64/67: Add agitate-log-view-kill-rev


From: ELPA Syncer
Subject: [elpa] externals/agitate 50251c7eff 64/67: Add agitate-log-view-kill-revision-expanded cmd
Date: Wed, 28 Sep 2022 16:57:30 -0400 (EDT)

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

    Add agitate-log-view-kill-revision-expanded cmd
---
 README.org |  4 ++++
 agitate.el | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/README.org b/README.org
index 74d4b68371..9f8655ac48 100644
--- a/README.org
+++ b/README.org
@@ -144,6 +144,10 @@ commits" are documented here: 
<https://www.conventionalcommits.org/en/v1.0.0/>.
   several lines), the revision is the one pertinent to the text at
   point.
 
+#+findex: agitate-log-view-kill-revision-expanded
++ ~agitate-log-view-kill-revision-expanded~ :: PROTOTYPE.  Append to
+  ~kill-ring~ expanded message of log-view revision at point.
+
 ** Extras for vc-git
 :PROPERTIES:
 :CUSTOM_ID: h:f1a1f462-b6db-415a-b8e6-ba23788cb6e3
diff --git a/agitate.el b/agitate.el
index 51f2f3df8c..730e0efa7e 100644
--- a/agitate.el
+++ b/agitate.el
@@ -230,6 +230,37 @@ to the text at point."
     (kill-new (format "%s" revision))
     (message "Copied: %s" revision)))
 
+(defun agitate--log-view-revision-expanded-bounds (&optional back)
+  "Return position of expanded log-view message.
+With optional BACK, find the beginning, else the end."
+  (let ((motion (if back
+                    (list 're-search-backward 'log-view-msg-prev 1)
+                  (list 're-search-forward 'log-view-msg-next -1))))
+    (save-excursion
+      (funcall (nth 0 motion) log-view-message-re nil t)
+      (forward-line (nth 2 motion))
+      (point))))
+
+  ;; TODO 2022-09-28: Maybe have a do-what-I-mean behaviour to expand
+  ;; the entry if necessary?  Or maybe expand it to get the message
+  ;; and then contract it again?  Keeping it simple seems appropriate,
+  ;; but we will see how this evolves.
+
+;;;###autoload
+(defun agitate-log-view-kill-revision-expanded ()
+  "PROTOTYPE Append to `kill-ring' expanded message of log-view revision at 
point."
+  (interactive nil log-view-mode)
+  (let ((pos (point)))
+    ;; TODO 2022-09-28: Also test when we are on the line of the
+    ;; revision, with the expanded entry right below.
+    (when (log-view-inside-comment-p pos)
+      (kill-new
+       (buffer-substring-no-properties
+        (agitate--log-view-revision-expanded-bounds :back)
+        (agitate--log-view-revision-expanded-bounds)))
+      (message "Copied message of `%s' revision"
+               (cadr (log-view-current-entry pos t))))))
+
 ;;;; Commands for vc-git (Git backend for the Version Control framework)
 
 (defun agitate--vc-git-get-hash-from-string (string)



reply via email to

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