emacs-diffs
[Top][All Lists]
Advanced

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

master c97716e: * lisp/mpc.el (mpc-format): Fix inf-loop in constructed


From: Stefan Monnier
Subject: master c97716e: * lisp/mpc.el (mpc-format): Fix inf-loop in constructed predicate
Date: Sat, 29 May 2021 14:24:28 -0400 (EDT)

branch: master
commit c97716e9a201c8b5fe0aad414f1846ace878258e
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/mpc.el (mpc-format): Fix inf-loop in constructed predicate
---
 lisp/mpc.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index f730275..9addb70 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -1027,10 +1027,14 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
                      (let ((dir (file-name-directory (cdr (assq 'file info)))))
                        ;; (debug)
                        (setq pred
-                             (lambda (info)
-                               (and (funcall pred info)
-                                    (equal dir (file-name-directory
-                                                (cdr (assq 'file info)))))))
+                             ;; We want the closure to capture the current
+                             ;; value of `pred' and not a reference to the
+                             ;; variable itself.
+                             (let ((oldpred pred))
+                               (lambda (info)
+                                 (and (funcall oldpred info)
+                                      (equal dir (file-name-directory
+                                                  (cdr (assq 'file info))))))))
                        (if-let* ((covers '(".folder.png" "cover.jpg" 
"folder.jpg"))
                                  (cover (cl-loop for file in (directory-files 
(mpc-file-local-copy dir))
                                                  if (member (downcase file) 
covers)
@@ -1057,9 +1061,13 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
                          (when (and (null val) (eq tag 'Title))
                            (setq val (cdr (assq 'file info))))
                          (setq pred
-                               (lambda (info)
-                                 (and (funcall pred info)
-                                      (equal val (cdr (assq ',tag info))))))
+                               ;; We want the closure to capture the current
+                               ;; value of `pred' and not a reference to the
+                               ;; variable itself.
+                               (let ((oldpred pred))
+                                 (lambda (info)
+                                   (and (funcall oldpred info)
+                                        (equal val (cdr (assq tag info)))))))
                          (cond
                           ((not (and (eq tag 'Date) (stringp val))) val)
                           ;; For "date", only keep the year!



reply via email to

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