From: Jordon Biondo <jordonbiondo@gmail.com>
To: emacs-devel@gnu.org
Subject: giving `setq-local' the same signature as `setq'
Date: Wed, 18 Mar 2015 11:26:01 -0400 [thread overview]
Message-ID: <B44CB2F3-655B-4263-BB1F-588C67F8017B@gmail.com> (raw)
I’ve often run into an issue when assuming `setq-local’ behave like `setq’ by accepting multiple [SYM VAL] pairs and returning the value assigned to the last symbol rather than only accepting one symbol and one value.
This is my patch that modifies `setq-local’ to behave this way. Please advise on why this can or shouldn’t be applied.
Note that I have not filled out the copyright assignment paperwork, so if it is to be applied, please send send in the right direction to get the paperwork taken care of.
Thank You
- Jordon Biondo
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d61a0a6..8154d60 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-18 Jordon Biondo <jordonbiondo@gmail.com>
+
+ * lisp/subr.el (setq-local): Can now set multiple local variables
+ like `setq'.
+
2015-03-18 Dima Kogan <dima@secretsauce.net>
Have gud-display-line not display source buffer in gud window.
diff --git a/lisp/subr.el b/lisp/subr.el
index deadca6..41340f0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -116,10 +116,21 @@ BODY should be a list of Lisp expressions.
;; depend on backquote.el.
(list 'function (cons 'lambda cdr)))
-(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.
- (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.
next reply other threads:[~2015-03-18 15:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 15:26 Jordon Biondo [this message]
2015-03-18 16:24 ` giving `setq-local' the same signature as `setq' Stefan Monnier
2015-03-19 14:08 ` Richard Stallman
2015-03-19 14:48 ` Jordon Biondo
2015-03-19 15:11 ` Drew Adams
2015-03-19 15:17 ` Oleh Krehel
2015-03-19 15:39 ` Drew Adams
2015-03-19 15:55 ` Oleh Krehel
2015-03-19 17:25 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B44CB2F3-655B-4263-BB1F-588C67F8017B@gmail.com \
--to=jordonbiondo@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).