GNU bug report logs - #47272
27.1; cl-progv binds variables in wrong order

Previous Next

Package: emacs;

Reported by: Toby Cubitt <toby <at> dr-qubit.org>

Date: Sat, 20 Mar 2021 00:28:01 UTC

Severity: normal

Tags: fixed

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47272 in the body.
You can then email your comments to 47272 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47272; Package emacs. (Sat, 20 Mar 2021 00:28:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Toby Cubitt <toby <at> dr-qubit.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 20 Mar 2021 00:28:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Toby Cubitt <toby <at> dr-qubit.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; cl-progv binds variables in wrong order
Date: Sat, 20 Mar 2021 00:27:03 +0000

The following

(cl-progv (test test) (1 2)
  test)

evaluates to 1. It should evaluate to 2.

The docstring states that cl-progv "much like a let form", and

(let ((test 1) (test 2))
 test)

evaluates to 2.


This bug in cl-progv breaks org agenda settings in
org-agenda-custom-commands, by preventing local variable settings in
agenda blocks from overriding variable settings in the overall agenda
command. (Broken since commit 129c33dddfa80202f23756ad5b513acdc036591c
in the org-mode repo, which switched the agenda varable setting code in
org-agenda to use cl-progv.)


Fixed implementation of cl-progv:

(defmacro cl-progv (symbols values &rest body)
  "Bind SYMBOLS to VALUES dynamically in BODY.
The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists.
Each symbol in the first list is bound to the corresponding value in the
second list (or to nil if VALUES is shorter than SYMBOLS); then the
BODY forms are executed and their result is returned.  This is much like
a `let' form, except that the list of symbols can be computed at run-time."
  (declare (indent 2) (debug (form form body)))
  (let ((bodyfun (make-symbol "body"))
        (binds (make-symbol "binds"))
        (syms (make-symbol "syms"))
        (vals (make-symbol "vals")))
    `(progn
       (let* ((,syms ,symbols)
              (,vals ,values)
              (,bodyfun (lambda () ,@body))
              (,binds ()))
         (while ,syms
           (push (list (pop ,syms) (list 'quote (pop ,vals))) ,binds))
	 (setq ,binds (nreverse ,binds))
         (eval (list 'let ,binds (list 'funcall (list 'quote ,bodyfun))))))))

--
Dr T. S. Cubitt
Reader (Associate Professor) in Quantum Information
Royal Society University Research Fellow
Department of Computer Science
University College London

email: tsc25 <at> cantab.net
web:   www.dr-qubit.org






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47272; Package emacs. (Sat, 20 Mar 2021 09:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 47272 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Toby Cubitt <toby <at> dr-qubit.org>
Cc: 47272 <at> debbugs.gnu.org
Subject: Re: bug#47272: 27.1; cl-progv binds variables in wrong order
Date: Sat, 20 Mar 2021 10:01:37 +0100
Toby Cubitt <toby <at> dr-qubit.org> writes:

> Fixed implementation of cl-progv:

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 20 Mar 2021 09:02:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47272 <at> debbugs.gnu.org and Toby Cubitt <toby <at> dr-qubit.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 20 Mar 2021 09:02:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 17 Apr 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.