branch: elpa/magit
commit a328af043cd9c3ca855561167c0a00fee0ce4727
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    Use transient-args instead of transient-get-value
    
    Also instead of wrapping `transient-args', change its behavior for
    these classes by implementing `transient-prefix-value' methods.
---
 lisp/magit-diff.el      | 9 +++++++--
 lisp/magit-log.el       | 9 +++++++--
 lisp/magit-transient.el | 9 ---------
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 0b90655c33a..ee2a1e28f21 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -809,6 +809,11 @@ and `:slant'."
 
 ;;;; Prefix Methods
 
+(cl-defmethod transient-prefix-value ((obj magit-diff-prefix))
+  (let ((args (cl-call-next-method obj)))
+    (list (seq-filter #'atom args)
+          (cdr (assoc "--" args)))))
+
 (cl-defmethod transient-init-value ((obj magit-diff-prefix))
   (pcase-let ((`(,args ,files)
                (magit-diff--get-value 'magit-diff-mode 'prefix)))
@@ -834,7 +839,7 @@ and `:slant'."
 (defun magit-diff-arguments (&optional mode)
   "Return the current diff arguments."
   (if (memq transient-current-command '(magit-diff magit-diff-refresh))
-      (magit--transient-args-and-files)
+      (transient-args transient-current-command)
     (magit-diff--get-value (or mode 'magit-diff-mode) 'direct)))
 
 (defun magit-diff--get-value (mode &optional use-buffer-args)
@@ -873,7 +878,7 @@ and `:slant'."
   (pcase-let* ((obj  (oref obj prototype))
                (mode (or (oref obj major-mode) major-mode))
                (key  (intern (format "magit-diff:%s" mode)))
-               (`(,args ,files) (magit--transient-args-and-files)))
+               (`(,args ,files) (transient-args obj)))
     (put mode 'magit-diff-current-arguments args)
     (when save
       (setf (alist-get key transient-values) args)
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index c2c565a4a44..24ab4459879 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -371,6 +371,11 @@ commits before and half after."
 
 ;;;; Prefix Methods
 
+(cl-defmethod transient-prefix-value ((obj magit-log-prefix))
+  (let ((args (cl-call-next-method obj)))
+    (list (seq-filter #'atom args)
+          (cdr (assoc "--" args)))))
+
 (cl-defmethod transient-init-value ((obj magit-log-prefix))
   (pcase-let ((`(,args ,files)
                (magit-log--get-value 'magit-log-mode 'prefix)))
@@ -396,7 +401,7 @@ commits before and half after."
 (defun magit-log-arguments (&optional mode)
   "Return the current log arguments."
   (if (memq transient-current-command '(magit-log magit-log-refresh))
-      (magit--transient-args-and-files)
+      (transient-args transient-current-command)
     (magit-log--get-value (or mode 'magit-log-mode) 'direct)))
 
 (defun magit-log--get-value (mode &optional use-buffer-args)
@@ -435,7 +440,7 @@ commits before and half after."
   (pcase-let* ((obj  (oref obj prototype))
                (mode (or (oref obj major-mode) major-mode))
                (key  (intern (format "magit-log:%s" mode)))
-               (`(,args ,files) (magit--transient-args-and-files)))
+               (`(,args ,files) (transient-args obj)))
     (put mode 'magit-log-current-arguments args)
     (when save
       (setf (alist-get key transient-values) args)
diff --git a/lisp/magit-transient.el b/lisp/magit-transient.el
index ad7135b8397..2055117239d 100644
--- a/lisp/magit-transient.el
+++ b/lisp/magit-transient.el
@@ -228,15 +228,6 @@
                       (cons value choices)
                     choices)))))
 
-;;; Utilities
-
-(defun magit--transient-args-and-files ()
-  "Return (args files) for use by log and diff functions.
-The value derives from that returned by `transient-get-value'."
-  (let ((args (transient-get-value)))
-    (list (seq-filter #'atom args)
-          (cdr (assoc "--" args)))))
-
 ;;; _
 (provide 'magit-transient)
 ;; Local Variables:

Reply via email to