GNU bug report logs - #26923
25.2; `setq-local': allow multiple assignments or add optional buffer arg

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 14 May 2017 14:16:01 UTC

Severity: wishlist

Tags: fixed

Found in version 25.2

Fixed in version 27.1

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

Bug is archived. No further changes may be made.

Forwarded to http://lists.gnu.org/archive/html/emacs-devel/2017-02/msg00374.html

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26923 in the body.
You can then email your comments to 26923 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#26923; Package emacs. (Sun, 14 May 2017 14:16:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 May 2017 14:16:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.2; `setq-local': allow multiple assignments or add optional buffer
 arg
Date: Sun, 14 May 2017 07:15:16 -0700 (PDT)
1. I believe this has been discussed before, and presumably the result
   (decision or lack of one) has been not to make the change, but I'd
   still suggest that `setq-local', like `setq', should allow multiple
   assignment pairs.

2. If that's definitely rejected then please consider this other
   enhancement instead: Allow a buffer argument:

   (setq-local VAR VALUE &optional BUFFER)

   This would be essentially just a convenience.

   See this emacs.SE question:
   https://emacs.stackexchange.com/q/32787/105

In GNU Emacs 25.2.1 (x86_64-w64-mingw32)
 of 2017-04-24
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''




Set bug forwarded-to-address to 'http://lists.gnu.org/archive/html/emacs-devel/2017-02/msg00374.html'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 15 May 2017 00:33:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Wed, 09 Oct 2019 08:17:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2; `setq-local': allow multiple assignments or
 add optional buffer arg
Date: Wed, 09 Oct 2019 10:15:49 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> 1. I believe this has been discussed before, and presumably the result
>    (decision or lack of one) has been not to make the change, but I'd
>    still suggest that `setq-local', like `setq', should allow multiple
>    assignment pairs.

This was implemented by

Jordon Biondo <jordonbiondo <at> gmail.com>

but never applied.  Biondo has copyright assignment papers on file, but
apparently the final movement here was this email from Eli:

> > From: Jordon Biondo <jordonbiondo <at> gmail.com>
> > Date: Wed, 8 Feb 2017 10:59:19 -0500
> > Cc: John Wiegley <jwiegley <at> gmail.com>, Emacs development discussions
> > <emacs-devel <at> gnu.org>
> > 
> > My paperwork is now complete, if that's the only thing holding up this patch.
>
> Thanks.  Could you please re-submit your patch, and add to it suitable
> changes to NEWS and to the ELisp manual?

Eli, if you still think this is something that should be done, I can add
the NEWS entry and the manual changes.  I've re-spun the patch for the
current trunk:

diff --git a/lisp/subr.el b/lisp/subr.el
index e361b8324f..8cb8bcef69 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -143,11 +143,22 @@ setq-default
       (push `(set-default ',(pop args) ,(pop args)) exps))
     `(progn . ,(nreverse exps))))
 
-(defmacro setq-local (var val)
-  "Set variable VAR to value VAL in current buffer."
+(defmacro setq-local (&rest args)
+  "Set each SYM to the value of its VAL in the current buffer.
+
+\(fn [SYM VAL]...)"
   ;; Can't use backquote here, it's too early in the bootstrap.
   (declare (debug (symbolp form)))
-  (list 'set (list 'make-local-variable (list 'quote var)) val))
+  (let ((expr))
+    (while args
+      (setq expr
+            (cons
+             (list 'set
+                   (list 'make-local-variable (list 'quote (car args)))
+                   (car (cdr args)))
+             expr))
+      (setq args (cdr (cdr args))))
+    (cons 'progn (nreverse expr))))
 
 (defmacro defvar-local (var val &optional docstring)
   "Define VAR as a buffer-local variable with default value VAL.


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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Thu, 10 Oct 2019 10:34:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: drew.adams <at> oracle.com, 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2;
 `setq-local': allow multiple assignments or add optional buffer arg
Date: Thu, 10 Oct 2019 13:33:34 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Wed, 09 Oct 2019 10:15:49 +0200
> Cc: 26923 <at> debbugs.gnu.org
> 
> > Thanks.  Could you please re-submit your patch, and add to it suitable
> > changes to NEWS and to the ELisp manual?
> 
> Eli, if you still think this is something that should be done, I can add
> the NEWS entry and the manual changes.

Yes, please, and thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Thu, 10 Oct 2019 13:03:02 GMT) Full text and rfc822 format available.

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

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2; `setq-local': allow multiple assignments or
 add optional buffer arg
Date: Thu, 10 Oct 2019 15:02:15 +0200
>>>>> On Thu, 10 Oct 2019 13:33:34 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Lars Ingebrigtsen <larsi <at> gnus.org>
    >> Date: Wed, 09 Oct 2019 10:15:49 +0200
    >> Cc: 26923 <at> debbugs.gnu.org
    >> 
    >> > Thanks.  Could you please re-submit your patch, and add to it suitable
    >> > changes to NEWS and to the ELisp manual?
    >> 
    >> Eli, if you still think this is something that should be done, I can add
    >> the NEWS entry and the manual changes.

    Eli> Yes, please, and thanks.

Unlike 'setq', this new version of 'setq-local' does not enforce an
even number of arguments, so the last arg gets set to nil.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Thu, 10 Oct 2019 13:47:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: larsi <at> gnus.org, 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2; `setq-local': allow multiple assignments or
 add optional buffer arg
Date: Thu, 10 Oct 2019 16:45:46 +0300
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,  26923 <at> debbugs.gnu.org
> Date: Thu, 10 Oct 2019 15:02:15 +0200
> 
> Unlike 'setq', this new version of 'setq-local' does not enforce an
> even number of arguments

Maybe it should, for consistency (less things to remember)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Fri, 11 Oct 2019 05:57:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Robert Pluim <rpluim <at> gmail.com>, 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2; `setq-local': allow multiple assignments or
 add optional buffer arg
Date: Fri, 11 Oct 2019 07:56:24 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Unlike 'setq', this new version of 'setq-local' does not enforce an
>> even number of arguments
>
> Maybe it should, for consistency (less things to remember)?

Yes, I think so.  I'll rework the patch to check for that.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26923; Package emacs. (Fri, 11 Oct 2019 06:30:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Robert Pluim <rpluim <at> gmail.com>, 26923 <at> debbugs.gnu.org
Subject: Re: bug#26923: 25.2; `setq-local': allow multiple assignments or
 add optional buffer arg
Date: Fri, 11 Oct 2019 08:29:44 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Unlike 'setq', this new version of 'setq-local' does not enforce an
>>> even number of arguments
>>
>> Maybe it should, for consistency (less things to remember)?
>
> Yes, I think so.  I'll rework the patch to check for that.

I've now done this, as well as updating the documentation and NEWS, and
I've made nntp.el use the new syntax (as a test case).

-- 
(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. (Fri, 11 Oct 2019 06:30:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 26923 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 11 Oct 2019 06:30: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. (Fri, 08 Nov 2019 12:24:03 GMT) Full text and rfc822 format available.

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

Previous Next


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