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

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

[elpa] externals/transient 0ad64ddc5d 010/366: transient-remove-suffix:


From: Jonas Bernoulli
Subject: [elpa] externals/transient 0ad64ddc5d 010/366: transient-remove-suffix: Fix removal of last child of a group
Date: Tue, 25 Jan 2022 18:54:22 -0500 (EST)

branch: externals/transient
commit 0ad64ddc5db466fb3bcac67b931b30393cdbc0a5
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient-remove-suffix: Fix removal of last child of a group
    
    Fixes #6.
---
 lisp/transient.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index 1dc8158eca..8420485096 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -812,9 +812,7 @@ PREFIX is a prefix command, a symbol.
 LOC is a command, a key vector or a key description
   (a string as returned by `key-description')."
   (declare (indent defun))
-  (when-let ((mem (transient--layout-member prefix loc)))
-    (setcar mem (cadr mem))
-    (setcdr mem (cddr mem))))
+  (transient--layout-member prefix loc 'remove))
 
 (defun transient-get-suffix (prefix loc)
   "Return the suffix at LOC from PREFIX.
@@ -836,7 +834,7 @@ PROP has to be a keyword.  What keywords and values
     (setf (nth 2 elt)
           (plist-put (nth 2 elt) prop value))))
 
-(defun transient--layout-member (prefix loc)
+(defun transient--layout-member (prefix loc &optional remove)
   (if-let ((layout (get prefix 'transient--layout)))
       (cl-labels
           ((key (loc)
@@ -854,9 +852,13 @@ PROP has to be a keyword.  What keywords and values
                   (if (vectorp (car (aref layout 3)))
                       (--any (mem it loc)
                              (aref layout 3))
-                    (cl-member-if (lambda (suffix)
-                                    (mem suffix loc))
-                                  (aref layout 3))))
+                    (let* ((list (aref layout 3))
+                           (cons (cl-member-if (lambda (suffix) (mem suffix 
loc))
+                                               list)))
+                      (if remove
+                          (prog1 nil
+                            (aset layout 3 (delq (car cons) list)))
+                        cons))))
                  ((and (listp layout)
                        (if (symbolp loc)
                            (eq (plist-get (nth 2 layout) :command) loc)



reply via email to

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