aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-07-22 13:24:31 -0400
committerStefan Monnier2013-07-22 13:24:31 -0400
commitc43a861814c2cbe65c67d0bfa5523b50eba1419f (patch)
tree0d33833c86470210adcf21b2088e18d3cb805d03
parent0ac26976f1da4921fd146851740a73b9185a054b (diff)
downloademacs-c43a861814c2cbe65c67d0bfa5523b50eba1419f.tar.gz
emacs-c43a861814c2cbe65c67d0bfa5523b50eba1419f.zip
* lisp/subr.el (add-to-list): Fix compiler-macro when `append' is
not constant. Don't use `cl-member' for the base case.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/subr.el21
2 files changed, 16 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bf243febe4f..38c79fc4279 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12013-07-22 Stefan Monnier <monnier@iro.umontreal.ca> 12013-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * subr.el (add-to-list): Fix compiler-macro when `append' is
4 not constant. Don't use `cl-member' for the base case.
5
3 * progmodes/subword.el: Fix boundary case (bug#13758). 6 * progmodes/subword.el: Fix boundary case (bug#13758).
4 (subword-forward-regexp): Make it a constant. Wrap optional \\W in its 7 (subword-forward-regexp): Make it a constant. Wrap optional \\W in its
5 own group. 8 own group.
diff --git a/lisp/subr.el b/lisp/subr.el
index 75c6b3a0620..7130639dbe5 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1498,9 +1498,10 @@ other hooks, such as major mode hooks, can do the job."
1498 ;; FIXME: Something like this could be used for `set' as well. 1498 ;; FIXME: Something like this could be used for `set' as well.
1499 (if (or (not (eq 'quote (car-safe list-var))) 1499 (if (or (not (eq 'quote (car-safe list-var)))
1500 (special-variable-p (cadr list-var)) 1500 (special-variable-p (cadr list-var))
1501 (and append compare-fn)) 1501 (not (macroexp-const-p append)))
1502 exp 1502 exp
1503 (let* ((sym (cadr list-var)) 1503 (let* ((sym (cadr list-var))
1504 (append (eval append))
1504 (msg (format "`add-to-list' can't use lexical var `%s'; use `push' or `cl-pushnew'" 1505 (msg (format "`add-to-list' can't use lexical var `%s'; use `push' or `cl-pushnew'"
1505 sym)) 1506 sym))
1506 ;; Big ugly hack so we only output a warning during 1507 ;; Big ugly hack so we only output a warning during
@@ -1513,13 +1514,17 @@ other hooks, such as major mode hooks, can do the job."
1513 (when (assq sym byte-compile--lexical-environment) 1514 (when (assq sym byte-compile--lexical-environment)
1514 (byte-compile-log-warning msg t :error)))) 1515 (byte-compile-log-warning msg t :error))))
1515 (code 1516 (code
1516 (if append 1517 (macroexp-let2 macroexp-copyable-p x element
1517 (macroexp-let2 macroexp-copyable-p x element 1518 `(unless ,(if compare-fn
1518 `(unless (member ,x ,sym) 1519 (progn
1519 (setq ,sym (append ,sym (list ,x))))) 1520 (require 'cl-lib)
1520 (require 'cl-lib) 1521 `(cl-member ,x ,sym :test ,compare-fn))
1521 `(cl-pushnew ,element ,sym 1522 ;; For bootstrapping reasons, don't rely on
1522 :test ,(or compare-fn '#'equal))))) 1523 ;; cl--compiler-macro-member for the base case.
1524 `(member ,x ,sym))
1525 ,(if append
1526 `(setq ,sym (append ,sym (list ,x)))
1527 `(push ,x ,sym))))))
1523 (if (not (macroexp--compiling-p)) 1528 (if (not (macroexp--compiling-p))
1524 code 1529 code
1525 `(progn 1530 `(progn