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

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

[nongnu] elpa/git-commit 8a8ac32def 12/15: magit--transient-args-and-fil


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 8a8ac32def 12/15: magit--transient-args-and-files: New function
Date: Mon, 31 Jul 2023 10:00:21 -0400 (EDT)

branch: elpa/git-commit
commit 8a8ac32def48799d532b392449e60eedeb54b428
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit--transient-args-and-files: New function
---
 lisp/magit-diff.el      | 8 ++------
 lisp/magit-log.el       | 8 ++------
 lisp/magit-transient.el | 9 +++++++++
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 233534f154..745b203db6 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -836,9 +836,7 @@ and `:slant'."
 (defun magit-diff-arguments (&optional mode)
   "Return the current diff arguments."
   (if (memq transient-current-command '(magit-diff magit-diff-refresh))
-      (pcase-let ((`(,args ,alist)
-                   (-separate #'atom (transient-get-value))))
-        (list args (cdr (assoc "--" alist))))
+      (magit--transient-args-and-files)
     (magit-diff--get-value (or mode 'magit-diff-mode))))
 
 (defun magit-diff--get-value (mode &optional use-buffer-args)
@@ -871,9 +869,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 ,alist)
-                (-separate #'atom (transient-get-value)))
-               (files (cdr (assoc "--" alist))))
+               (`(,args ,files) (magit--transient-args-and-files)))
     (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 c0010c20a5..60f8956d55 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -348,9 +348,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))
-      (pcase-let ((`(,args ,alist)
-                   (-separate #'atom (transient-get-value))))
-        (list args (cdr (assoc "--" alist))))
+      (magit--transient-args-and-files)
     (magit-log--get-value (or mode 'magit-log-mode))))
 
 (defun magit-log--get-value (mode &optional use-buffer-args)
@@ -383,9 +381,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 ,alist)
-                (-separate #'atom (transient-get-value)))
-               (files (cdr (assoc "--" alist))))
+               (`(,args ,files) (magit--transient-args-and-files)))
     (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 6dda38a2a1..364c20ac2d 100644
--- a/lisp/magit-transient.el
+++ b/lisp/magit-transient.el
@@ -219,6 +219,15 @@
                                       'transient-value))))))
      (propertize "]" 'face 'transient-inactive-value))))
 
+;;; 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)
 ;;; magit-transient.el ends here



reply via email to

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