[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26923: 25.2; `setq-local': allow multiple assignments or add optiona
From: |
Lars Ingebrigtsen |
Subject: |
bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg |
Date: |
Wed, 09 Oct 2019 10:15:49 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
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
- bug#26923: 25.2; `setq-local': allow multiple assignments or add optional buffer arg,
Lars Ingebrigtsen <=