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

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

[elpa] externals/agitate f91849b996 1/6: Add completion table to disable


From: ELPA Syncer
Subject: [elpa] externals/agitate f91849b996 1/6: Add completion table to disable sorting of commits
Date: Thu, 29 Sep 2022 07:57:18 -0400 (EDT)

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

    Add completion table to disable sorting of commits
    
    This is important as we want the list of commits to be in the order
    they appear in the logs.  Otherwise it is impossible to find what we
    are looking for.
---
 agitate.el | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/agitate.el b/agitate.el
index 37cfa363fb..4ccabeb357 100644
--- a/agitate.el
+++ b/agitate.el
@@ -70,6 +70,18 @@ will render those as their corresponding graphical emoji."
   :type '(repeat string)
   :group 'agitate)
 
+(defun agitate--completion-table-no-sort (candidates &optional category 
annotation)
+  "Make completion table for CANDIDATES with sorting disabled.
+CATEGORY is the completion category.
+ANNOTATION is an annotation function."
+  (lambda (str pred action)
+    (if (eq action 'metadata)
+        `(metadata (display-sort-function . identity)
+                   (cycle-sort-function . identity)
+                   (annotation-function . ,annotation)
+                   (category . ,category))
+      (complete-with-action action candidates str pred))))
+
 ;;;; Commands for diff-mode
 
 (defvar-local agitate--refine-diff-state nil
@@ -278,11 +290,17 @@ With optional LONG do not abbreviate commit hashes."
          (default-directory (vc-root-dir)))
     (completing-read
      prompt
-     (process-lines
-      vc-git-program "log"
-      (format "-n %d" vc-log-show-limit)
-      (if long "--pretty=oneline" "--oneline")
-      (or file "--"))
+     ;; TODO 2022-09-29: Define a completion category that can work
+     ;; with `consult', `embark', `marginalia', and friends?
+     ;;
+     ;; TODO 2022-09-29: Define an annotation function?  Though we can
+     ;; just tweak the git arguments.
+     (agitate--completion-table-no-sort
+      (process-lines
+       vc-git-program "log"
+       (format "-n %d" vc-log-show-limit)
+       (if long "--pretty=oneline" "--oneline")
+       (or file "--")))
      nil t)))
 
 (defvar agitate-vc-git-show-buffer "*agitate-vc-git-show*"



reply via email to

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