unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
@ 2017-05-14 14:15 Drew Adams
  2019-10-09  8:15 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2017-05-14 14:15 UTC (permalink / raw)
  To: 26923

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''





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2017-05-14 14:15 bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg Drew Adams
@ 2019-10-09  8:15 ` Lars Ingebrigtsen
  2019-10-10 10:33   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09  8:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: 26923

Drew Adams <drew.adams@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@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@gmail.com>
> > Date: Wed, 8 Feb 2017 10:59:19 -0500
> > Cc: John Wiegley <jwiegley@gmail.com>, Emacs development discussions
> > <emacs-devel@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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2019-10-09  8:15 ` Lars Ingebrigtsen
@ 2019-10-10 10:33   ` Eli Zaretskii
  2019-10-10 13:02     ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2019-10-10 10:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 26923

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 09 Oct 2019 10:15:49 +0200
> Cc: 26923@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2019-10-10 10:33   ` Eli Zaretskii
@ 2019-10-10 13:02     ` Robert Pluim
  2019-10-10 13:45       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2019-10-10 13:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 26923

>>>>> On Thu, 10 Oct 2019 13:33:34 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Lars Ingebrigtsen <larsi@gnus.org>
    >> Date: Wed, 09 Oct 2019 10:15:49 +0200
    >> Cc: 26923@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2019-10-10 13:02     ` Robert Pluim
@ 2019-10-10 13:45       ` Eli Zaretskii
  2019-10-11  5:56         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2019-10-10 13:45 UTC (permalink / raw)
  To: Robert Pluim; +Cc: larsi, 26923

> From: Robert Pluim <rpluim@gmail.com>
> Cc: Lars Ingebrigtsen <larsi@gnus.org>,  26923@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)?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2019-10-10 13:45       ` Eli Zaretskii
@ 2019-10-11  5:56         ` Lars Ingebrigtsen
  2019-10-11  6:29           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-11  5:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Pluim, 26923

Eli Zaretskii <eliz@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg
  2019-10-11  5:56         ` Lars Ingebrigtsen
@ 2019-10-11  6:29           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-11  6:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Pluim, 26923

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eli Zaretskii <eliz@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-11  6:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-14 14:15 bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg Drew Adams
2019-10-09  8:15 ` Lars Ingebrigtsen
2019-10-10 10:33   ` Eli Zaretskii
2019-10-10 13:02     ` Robert Pluim
2019-10-10 13:45       ` Eli Zaretskii
2019-10-11  5:56         ` Lars Ingebrigtsen
2019-10-11  6:29           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).