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

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

[nongnu] elpa/git-commit ee6fbba360 2/5: magit-insert-section-body: Limi


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit ee6fbba360 2/5: magit-insert-section-body: Limit scope of a binding
Date: Fri, 3 May 2024 09:57:59 -0400 (EDT)

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

    magit-insert-section-body: Limit scope of a binding
    
    Only the lambda may run delayed, outside a `magit-insert-section'.
    BODY must not use `magit-insert-section--current'; if it must have
    access to the section it is inserting, `magit-insert-section's
    SECTION must be used.
---
 lisp/magit-section.el | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 0869ccc20f..d42bbba403 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1550,19 +1550,19 @@ is explicitly expanded."
   (let ((f (cl-gensym))
         (s (cl-gensym))
         (l (cl-gensym)))
-    `(let ((,f (lambda () ,@body))
-           (,s magit-insert-section--current))
-       (if (oref ,s hidden)
-           (oset ,s washer
-                 (lambda ()
-                   (let ((,l (magit-section-lineage ,s t)))
-                     (dolist (s ,l)
-                       (set-marker-insertion-type (oref s end) t))
-                     (funcall ,f)
-                     (dolist (s ,l)
-                       (set-marker-insertion-type (oref s end) nil))
-                     (magit-section-maybe-remove-heading-map ,s)
-                     (magit-section-maybe-remove-visibility-indicator ,s))))
+    `(let ((,f (lambda () ,@body)))
+       (if (oref magit-insert-section--current hidden)
+           (oset magit-insert-section--current washer
+                 (let ((,s magit-insert-section--current))
+                   (lambda ()
+                     (let ((,l (magit-section-lineage ,s t)))
+                       (dolist (s ,l)
+                         (set-marker-insertion-type (oref s end) t))
+                       (funcall ,f)
+                       (dolist (s ,l)
+                         (set-marker-insertion-type (oref s end) nil))
+                       (magit-section-maybe-remove-heading-map ,s)
+                       (magit-section-maybe-remove-visibility-indicator ,s)))))
          (funcall ,f)))))
 
 (defun magit-insert-headers (hook)



reply via email to

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