aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2015-01-28 01:31:15 -0300
committerFabián Ezequiel Gallina2015-01-28 01:31:15 -0300
commit5491fd1098d27b3ba3db054076b9ab60fb3558dc (patch)
tree65f6f54127714eb9634b83e5d780d75ab7d85252
parent028ddef7a2b6662ac602ea70d308deecbc69b4db (diff)
parent2668ac1aaecfe62c80a4fbdfc27a38e384594d26 (diff)
downloademacs-5491fd1098d27b3ba3db054076b9ab60fb3558dc.tar.gz
emacs-5491fd1098d27b3ba3db054076b9ab60fb3558dc.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/emacs-lisp/cl-generic.el27
-rw-r--r--lisp/emacs-lisp/cl-macs.el215
-rw-r--r--lisp/emacs-lisp/cl-preloaded.el48
-rw-r--r--lisp/emacs-lisp/eieio-core.el14
-rw-r--r--lisp/loadup.el3
-rw-r--r--lisp/net/shr.el37
-rw-r--r--src/ChangeLog4
-rw-r--r--src/lisp.mk1
9 files changed, 230 insertions, 139 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8eb189873d2..eb6ef6b19d2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -63,6 +63,24 @@
63 Fix dired quoting bug with "Hit`N`Hide". Fixes Bug#19498. 63 Fix dired quoting bug with "Hit`N`Hide". Fixes Bug#19498.
64 * files.el (shell-quote-wildcard-pattern): Also quote "`". 64 * files.el (shell-quote-wildcard-pattern): Also quote "`".
65 65
662015-01-28 Stefan Monnier <monnier@iro.umontreal.ca>
67
68 Tighten up the tagcode used for eieio and cl-struct objects.
69 * loadup.el: Load cl-preloaded.
70 * emacs-lisp/eieio-core.el (eieio-defclass-internal): Set the function
71 slot of the tag symbol to :quick-object-witness-check.
72 (eieio-object-p): Use :quick-object-witness-check.
73 (eieio--generic-tagcode): Use cl--generic-struct-tag.
74 * emacs-lisp/cl-preloaded.el: New file.
75 * emacs-lisp/cl-macs.el (cl--bind-inits): Remove, unused.
76 (cl--transform-lambda, cl-destructuring-bind): Remove cl--bind-inits.
77 (cl--make-usage-args): Strip away &aux args.
78 (cl-case, cl-typecase, cl--parse-loop-clause): Use macroexp-let2.
79 (cl-the, cl-check-type): Use macroexp-let2 and cl-typep.
80 (cl-defstruct): Use `declare' and cl-struct-define.
81 * emacs-lisp/cl-generic.el (cl--generic-struct-tag): New function.
82 (cl--generic-struct-tagcode): Use it to tighten the tagcode.
83
662015-01-27 Katsumi Yamaoka <yamaoka@jpl.org> 842015-01-27 Katsumi Yamaoka <yamaoka@jpl.org>
67 85
68 * emacs-lisp/cl.el (cl--function-convert): 86 * emacs-lisp/cl.el (cl--function-convert):
@@ -150,6 +168,8 @@
1502015-01-26 Lars Ingebrigtsen <larsi@gnus.org> 1682015-01-26 Lars Ingebrigtsen <larsi@gnus.org>
151 169
152 * net/shr.el (shr-make-table-1): Fix colspan typo. 170 * net/shr.el (shr-make-table-1): Fix colspan typo.
171 (shr-make-table-1): Add comments.
172 (shr-make-table-1): Make colspan display more sensibly.
153 173
154 * net/eww.el (eww-add-bookmark): Fix prompt and clean up the code 174 * net/eww.el (eww-add-bookmark): Fix prompt and clean up the code
155 slightly. 175 slightly.
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 1bb70963a57..3e34ab6e4d2 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -724,6 +724,14 @@ Can only be used from within the lexical body of a primary or around method."
724 724
725(add-function :before-until cl-generic-tagcode-function 725(add-function :before-until cl-generic-tagcode-function
726 #'cl--generic-struct-tagcode) 726 #'cl--generic-struct-tagcode)
727
728(defun cl--generic-struct-tag (name)
729 `(and (vectorp ,name)
730 (> (length ,name) 0)
731 (let ((tag (aref ,name 0)))
732 (if (eq (symbol-function tag) :quick-object-witness-check)
733 tag))))
734
727(defun cl--generic-struct-tagcode (type name) 735(defun cl--generic-struct-tagcode (type name)
728 (and (symbolp type) 736 (and (symbolp type)
729 (get type 'cl-struct-type) 737 (get type 'cl-struct-type)
@@ -733,12 +741,19 @@ Can only be used from within the lexical body of a primary or around method."
733 (or (equal '(cl-tag-slot) (car (get type 'cl-struct-slots))) 741 (or (equal '(cl-tag-slot) (car (get type 'cl-struct-slots)))
734 (error "Can't dispatch on cl-struct %S: no tag in slot 0" 742 (error "Can't dispatch on cl-struct %S: no tag in slot 0"
735 type)) 743 type))
736 ;; We could/should check the vector has length >0, 744 ;; It's tempting to use (and (vectorp ,name) (aref ,name 0))
737 ;; but really, mixing vectors and structs is a bad idea, 745 ;; but that would suffer from some problems:
738 ;; so let's not waste time trying to handle the case 746 ;; - the vector may have size 0.
739 ;; of an empty vector. 747 ;; - when called on an actual vector (rather than an object), we'd
740 ;; BEWARE: this returns a bogus tag for non-struct vectors. 748 ;; end up returning an arbitrary value, possibly colliding with
741 `(50 . (and (vectorp ,name) (aref ,name 0))))) 749 ;; other tagcode's values.
750 ;; - it can also result in returning all kinds of irrelevant
751 ;; values which would end up filling up the method-cache with
752 ;; lots of irrelevant/redundant entries.
753 ;; FIXME: We could speed this up by introducing a dedicated
754 ;; vector type at the C level, so we could do something like
755 ;; (and (vector-objectp ,name) (aref ,name 0))
756 `(50 . ,(cl--generic-struct-tag name))))
742 757
743(add-function :before-until cl-generic-tag-types-function 758(add-function :before-until cl-generic-tag-types-function
744 #'cl--generic-struct-tag-types) 759 #'cl--generic-struct-tag-types)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 38f15b89b0e..eaec2c5263c 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -221,7 +221,7 @@ The name is made by appending a number to PREFIX, default \"G\"."
221 '(&optional &rest &key &allow-other-keys &aux &whole &body &environment)) 221 '(&optional &rest &key &allow-other-keys &aux &whole &body &environment))
222 222
223(defvar cl--bind-block) (defvar cl--bind-defs) (defvar cl--bind-enquote) 223(defvar cl--bind-block) (defvar cl--bind-defs) (defvar cl--bind-enquote)
224(defvar cl--bind-inits) (defvar cl--bind-lets) (defvar cl--bind-forms) 224(defvar cl--bind-lets) (defvar cl--bind-forms)
225 225
226(defun cl--transform-lambda (form bind-block) 226(defun cl--transform-lambda (form bind-block)
227 "Transform a function form FORM of name BIND-BLOCK. 227 "Transform a function form FORM of name BIND-BLOCK.
@@ -229,9 +229,11 @@ BIND-BLOCK is the name of the symbol to which the function will be bound,
229and which will be used for the name of the `cl-block' surrounding the 229and which will be used for the name of the `cl-block' surrounding the
230function's body. 230function's body.
231FORM is of the form (ARGS . BODY)." 231FORM is of the form (ARGS . BODY)."
232 ;; FIXME: (lambda (a &aux b) 1) expands to (lambda (a &rest --cl-rest--) ...)
233 ;; where the --cl-rest-- is clearly undesired.
232 (let* ((args (car form)) (body (cdr form)) (orig-args args) 234 (let* ((args (car form)) (body (cdr form)) (orig-args args)
233 (cl--bind-block bind-block) (cl--bind-defs nil) (cl--bind-enquote nil) 235 (cl--bind-block bind-block) (cl--bind-defs nil) (cl--bind-enquote nil)
234 (cl--bind-inits nil) (cl--bind-lets nil) (cl--bind-forms nil) 236 (cl--bind-lets nil) (cl--bind-forms nil)
235 (header nil) (simple-args nil)) 237 (header nil) (simple-args nil))
236 (while (or (stringp (car body)) 238 (while (or (stringp (car body))
237 (memq (car-safe (car body)) '(interactive declare cl-declare))) 239 (memq (car-safe (car body)) '(interactive declare cl-declare)))
@@ -244,10 +246,10 @@ FORM is of the form (ARGS . BODY)."
244 (if (setq cl--bind-enquote (memq '&cl-quote args)) 246 (if (setq cl--bind-enquote (memq '&cl-quote args))
245 (setq args (delq '&cl-quote args))) 247 (setq args (delq '&cl-quote args)))
246 (if (memq '&whole args) (error "&whole not currently implemented")) 248 (if (memq '&whole args) (error "&whole not currently implemented"))
247 (let* ((p (memq '&environment args)) (v (cadr p)) 249 (let* ((p (memq '&environment args))
248 (env-exp 'macroexpand-all-environment)) 250 (v (cadr p)))
249 (if p (setq args (nconc (delq (car p) (delq v args)) 251 (if p (setq args (nconc (delq (car p) (delq v args))
250 (list '&aux (list v env-exp)))))) 252 `(&aux (,v macroexpand-all-environment))))))
251 (while (and args (symbolp (car args)) 253 (while (and args (symbolp (car args))
252 (not (memq (car args) '(nil &rest &body &key &aux))) 254 (not (memq (car args) '(nil &rest &body &key &aux)))
253 (not (and (eq (car args) '&optional) 255 (not (and (eq (car args) '&optional)
@@ -261,8 +263,7 @@ FORM is of the form (ARGS . BODY)."
261 (cl--do-arglist args nil (- (length simple-args) 263 (cl--do-arglist args nil (- (length simple-args)
262 (if (memq '&optional simple-args) 1 0))) 264 (if (memq '&optional simple-args) 1 0)))
263 (setq cl--bind-lets (nreverse cl--bind-lets)) 265 (setq cl--bind-lets (nreverse cl--bind-lets))
264 (cl-list* (and cl--bind-inits `(cl-eval-when (compile load eval) 266 (cl-list* nil
265 ,@(nreverse cl--bind-inits)))
266 (nconc (nreverse simple-args) 267 (nconc (nreverse simple-args)
267 (list '&rest (car (pop cl--bind-lets)))) 268 (list '&rest (car (pop cl--bind-lets))))
268 (nconc (let ((hdr (nreverse header))) 269 (nconc (let ((hdr (nreverse header)))
@@ -390,6 +391,11 @@ its argument list allows full Common Lisp conventions."
390 (t x))) 391 (t x)))
391 392
392(defun cl--make-usage-args (arglist) 393(defun cl--make-usage-args (arglist)
394 (let ((aux (ignore-errors (cl-position '&aux arglist))))
395 (when aux
396 ;; `&aux' args aren't arguments, so let's just drop them from the
397 ;; usage info.
398 (setq arglist (cl-subseq arglist 0 aux))))
393 (if (cdr-safe (last arglist)) ;Not a proper list. 399 (if (cdr-safe (last arglist)) ;Not a proper list.
394 (let* ((last (last arglist)) 400 (let* ((last (last arglist))
395 (tail (cdr last))) 401 (tail (cdr last)))
@@ -426,7 +432,7 @@ its argument list allows full Common Lisp conventions."
426 )))) 432 ))))
427 arglist)))) 433 arglist))))
428 434
429(defun cl--do-arglist (args expr &optional num) ; uses bind-* 435(defun cl--do-arglist (args expr &optional num) ; uses cl--bind-*
430 (if (nlistp args) 436 (if (nlistp args)
431 (if (or (memq args cl--lambda-list-keywords) (not (symbolp args))) 437 (if (or (memq args cl--lambda-list-keywords) (not (symbolp args)))
432 (error "Invalid argument name: %s" args) 438 (error "Invalid argument name: %s" args)
@@ -441,9 +447,9 @@ its argument list allows full Common Lisp conventions."
441 (keys nil) 447 (keys nil)
442 (laterarg nil) (exactarg nil) minarg) 448 (laterarg nil) (exactarg nil) minarg)
443 (or num (setq num 0)) 449 (or num (setq num 0))
444 (if (listp (cadr restarg)) 450 (setq restarg (if (listp (cadr restarg))
445 (setq restarg (make-symbol "--cl-rest--")) 451 (make-symbol "--cl-rest--")
446 (setq restarg (cadr restarg))) 452 (cadr restarg)))
447 (push (list restarg expr) cl--bind-lets) 453 (push (list restarg expr) cl--bind-lets)
448 (if (eq (car args) '&whole) 454 (if (eq (car args) '&whole)
449 (push (list (cl--pop2 args) restarg) cl--bind-lets)) 455 (push (list (cl--pop2 args) restarg) cl--bind-lets))
@@ -570,12 +576,11 @@ its argument list allows full Common Lisp conventions."
570 "Bind the variables in ARGS to the result of EXPR and execute BODY." 576 "Bind the variables in ARGS to the result of EXPR and execute BODY."
571 (declare (indent 2) 577 (declare (indent 2)
572 (debug (&define cl-macro-list def-form cl-declarations def-body))) 578 (debug (&define cl-macro-list def-form cl-declarations def-body)))
573 (let* ((cl--bind-lets nil) (cl--bind-forms nil) (cl--bind-inits nil) 579 (let* ((cl--bind-lets nil) (cl--bind-forms nil)
574 (cl--bind-defs nil) (cl--bind-block 'cl-none) (cl--bind-enquote nil)) 580 (cl--bind-defs nil) (cl--bind-block 'cl-none) (cl--bind-enquote nil))
575 (cl--do-arglist (or args '(&aux)) expr) 581 (cl--do-arglist (or args '(&aux)) expr)
576 (append '(progn) cl--bind-inits 582 (macroexp-let* (nreverse cl--bind-lets)
577 (list `(let* ,(nreverse cl--bind-lets) 583 (macroexp-progn (append (nreverse cl--bind-forms) body)))))
578 ,@(nreverse cl--bind-forms) ,@body)))))
579 584
580 585
581;;; The `cl-eval-when' form. 586;;; The `cl-eval-when' form.
@@ -655,30 +660,26 @@ allowed only in the final clause, and matches if no other keys match.
655Key values are compared by `eql'. 660Key values are compared by `eql'.
656\n(fn EXPR (KEYLIST BODY...)...)" 661\n(fn EXPR (KEYLIST BODY...)...)"
657 (declare (indent 1) (debug (form &rest (sexp body)))) 662 (declare (indent 1) (debug (form &rest (sexp body))))
658 (let* ((temp (if (cl--simple-expr-p expr 3) expr (make-symbol "--cl-var--"))) 663 (macroexp-let2 macroexp-copyable-p temp expr
659 (head-list nil) 664 (let* ((head-list nil))
660 (body (cons 665 `(cond
661 'cond 666 ,@(mapcar
662 (mapcar 667 (lambda (c)
663 (function 668 (cons (cond ((memq (car c) '(t otherwise)) t)
664 (lambda (c) 669 ((eq (car c) 'cl--ecase-error-flag)
665 (cons (cond ((memq (car c) '(t otherwise)) t) 670 `(error "cl-ecase failed: %s, %s"
666 ((eq (car c) 'cl--ecase-error-flag) 671 ,temp ',(reverse head-list)))
667 `(error "cl-ecase failed: %s, %s" 672 ((listp (car c))
668 ,temp ',(reverse head-list))) 673 (setq head-list (append (car c) head-list))
669 ((listp (car c)) 674 `(cl-member ,temp ',(car c)))
670 (setq head-list (append (car c) head-list)) 675 (t
671 `(cl-member ,temp ',(car c))) 676 (if (memq (car c) head-list)
672 (t 677 (error "Duplicate key in case: %s"
673 (if (memq (car c) head-list) 678 (car c)))
674 (error "Duplicate key in case: %s" 679 (push (car c) head-list)
675 (car c))) 680 `(eql ,temp ',(car c))))
676 (push (car c) head-list) 681 (or (cdr c) '(nil))))
677 `(eql ,temp ',(car c)))) 682 clauses)))))
678 (or (cdr c) '(nil)))))
679 clauses))))
680 (if (eq temp expr) body
681 `(let ((,temp ,expr)) ,body))))
682 683
683;;;###autoload 684;;;###autoload
684(defmacro cl-ecase (expr &rest clauses) 685(defmacro cl-ecase (expr &rest clauses)
@@ -698,24 +699,22 @@ final clause, and matches if no other keys match.
698\n(fn EXPR (TYPE BODY...)...)" 699\n(fn EXPR (TYPE BODY...)...)"
699 (declare (indent 1) 700 (declare (indent 1)
700 (debug (form &rest ([&or cl-type-spec "otherwise"] body)))) 701 (debug (form &rest ([&or cl-type-spec "otherwise"] body))))
701 (let* ((temp (if (cl--simple-expr-p expr 3) expr (make-symbol "--cl-var--"))) 702 (macroexp-let2 macroexp-copyable-p temp expr
702 (type-list nil) 703 (let* ((type-list nil))
703 (body (cons 704 (cons
704 'cond 705 'cond
705 (mapcar 706 (mapcar
706 (function 707 (function
707 (lambda (c) 708 (lambda (c)
708 (cons (cond ((eq (car c) 'otherwise) t) 709 (cons (cond ((eq (car c) 'otherwise) t)
709 ((eq (car c) 'cl--ecase-error-flag) 710 ((eq (car c) 'cl--ecase-error-flag)
710 `(error "cl-etypecase failed: %s, %s" 711 `(error "cl-etypecase failed: %s, %s"
711 ,temp ',(reverse type-list))) 712 ,temp ',(reverse type-list)))
712 (t 713 (t
713 (push (car c) type-list) 714 (push (car c) type-list)
714 (cl--make-type-test temp (car c)))) 715 `(cl-typep ,temp ',(car c))))
715 (or (cdr c) '(nil))))) 716 (or (cdr c) '(nil)))))
716 clauses)))) 717 clauses)))))
717 (if (eq temp expr) body
718 `(let ((,temp ,expr)) ,body))))
719 718
720;;;###autoload 719;;;###autoload
721(defmacro cl-etypecase (expr &rest clauses) 720(defmacro cl-etypecase (expr &rest clauses)
@@ -1439,16 +1438,14 @@ For more details, see Info node `(cl)Loop Facility'.
1439 (push `(progn (if ,what (cl-incf ,var)) t) cl--loop-body))) 1438 (push `(progn (if ,what (cl-incf ,var)) t) cl--loop-body)))
1440 1439
1441 ((memq word '(minimize minimizing maximize maximizing)) 1440 ((memq word '(minimize minimizing maximize maximizing))
1442 (let* ((what (pop cl--loop-args)) 1441 (push `(progn ,(macroexp-let2 macroexp-copyable-p temp
1443 (temp (if (cl--simple-expr-p what) what 1442 (pop cl--loop-args)
1444 (make-symbol "--cl-var--"))) 1443 (let* ((var (cl--loop-handle-accum nil))
1445 (var (cl--loop-handle-accum nil)) 1444 (func (intern (substring (symbol-name word)
1446 (func (intern (substring (symbol-name word) 0 3))) 1445 0 3))))
1447 (set `(setq ,var (if ,var (,func ,var ,temp) ,temp)))) 1446 `(setq ,var (if ,var (,func ,var ,temp) ,temp))))
1448 (push `(progn ,(if (eq temp what) set 1447 t)
1449 `(let ((,temp ,what)) ,set)) 1448 cl--loop-body))
1450 t)
1451 cl--loop-body)))
1452 1449
1453 ((eq word 'with) 1450 ((eq word 'with)
1454 (let ((bindings nil)) 1451 (let ((bindings nil))
@@ -2104,14 +2101,11 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
2104 (< cl--optimize-speed 3) 2101 (< cl--optimize-speed 3)
2105 (= cl--optimize-safety 3))) 2102 (= cl--optimize-safety 3)))
2106 form 2103 form
2107 (let* ((temp (if (cl--simple-expr-p form 3) 2104 (macroexp-let2 macroexp-copyable-p temp form
2108 form (make-symbol "--cl-var--"))) 2105 `(progn (unless (cl-typep ,temp ',type)
2109 (body `(progn (unless ,(cl--make-type-test temp type) 2106 (signal 'wrong-type-argument
2110 (signal 'wrong-type-argument 2107 (list ',type ,temp ',form)))
2111 (list ',type ,temp ',form))) 2108 ,temp))))
2112 ,temp)))
2113 (if (eq temp form) body
2114 `(let ((,temp ,form)) ,body)))))
2115 2109
2116(defvar cl--proclaim-history t) ; for future compilers 2110(defvar cl--proclaim-history t) ; for future compilers
2117(defvar cl--declare-stack t) ; for future compilers 2111(defvar cl--declare-stack t) ; for future compilers
@@ -2425,15 +2419,11 @@ non-nil value, that slot cannot be set via `setf'.
2425 (tag (intern (format "cl-struct-%s" name))) 2419 (tag (intern (format "cl-struct-%s" name)))
2426 (tag-symbol (intern (format "cl-struct-%s-tags" name))) 2420 (tag-symbol (intern (format "cl-struct-%s-tags" name)))
2427 (include-descs nil) 2421 (include-descs nil)
2428 (side-eff nil)
2429 (type nil) 2422 (type nil)
2430 (named nil) 2423 (named nil)
2431 (forms nil) 2424 (forms nil)
2425 (docstring (if (stringp (car descs)) (pop descs)))
2432 pred-form pred-check) 2426 pred-form pred-check)
2433 (if (stringp (car descs))
2434 (push `(put ',name 'structure-documentation
2435 ,(pop descs))
2436 forms))
2437 (setq descs (cons '(cl-tag-slot) 2427 (setq descs (cons '(cl-tag-slot)
2438 (mapcar (function (lambda (x) (if (consp x) x (list x)))) 2428 (mapcar (function (lambda (x) (if (consp x) x (list x))))
2439 descs))) 2429 descs)))
@@ -2458,6 +2448,7 @@ non-nil value, that slot cannot be set via `setf'.
2458 ((eq opt :predicate) 2448 ((eq opt :predicate)
2459 (if args (setq predicate (car args)))) 2449 (if args (setq predicate (car args))))
2460 ((eq opt :include) 2450 ((eq opt :include)
2451 (when include (error "Can't :include more than once"))
2461 (setq include (car args) 2452 (setq include (car args)
2462 include-descs (mapcar (function 2453 include-descs (mapcar (function
2463 (lambda (x) 2454 (lambda (x)
@@ -2511,20 +2502,19 @@ non-nil value, that slot cannot be set via `setf'.
2511 (if named (setq tag name))) 2502 (if named (setq tag name)))
2512 (setq type 'vector named 'true))) 2503 (setq type 'vector named 'true)))
2513 (or named (setq descs (delq (assq 'cl-tag-slot descs) descs))) 2504 (or named (setq descs (delq (assq 'cl-tag-slot descs) descs)))
2514 (push `(defvar ,tag-symbol) forms)
2515 (when (and (null predicate) named) 2505 (when (and (null predicate) named)
2516 (setq predicate (intern (format "cl--struct-%s-p" name)))) 2506 (setq predicate (intern (format "cl--struct-%s-p" name))))
2517 (setq pred-form (and named 2507 (setq pred-form (and named
2518 (let ((pos (- (length descs) 2508 (let ((pos (- (length descs)
2519 (length (memq (assq 'cl-tag-slot descs) 2509 (length (memq (assq 'cl-tag-slot descs)
2520 descs))))) 2510 descs)))))
2521 (if (eq type 'vector) 2511 (cond
2522 `(and (vectorp cl-x) 2512 ((eq type 'vector)
2523 (>= (length cl-x) ,(length descs)) 2513 `(and (vectorp cl-x)
2524 (memq (aref cl-x ,pos) ,tag-symbol)) 2514 (>= (length cl-x) ,(length descs))
2525 (if (= pos 0) 2515 (memq (aref cl-x ,pos) ,tag-symbol)))
2526 `(memq (car-safe cl-x) ,tag-symbol) 2516 ((= pos 0) `(memq (car-safe cl-x) ,tag-symbol))
2527 `(and (consp cl-x) 2517 (t `(and (consp cl-x)
2528 (memq (nth ,pos cl-x) ,tag-symbol)))))) 2518 (memq (nth ,pos cl-x) ,tag-symbol))))))
2529 pred-check (and pred-form (> safety 0) 2519 pred-check (and pred-form (> safety 0)
2530 (if (and (eq (cl-caadr pred-form) 'vectorp) 2520 (if (and (eq (cl-caadr pred-form) 'vectorp)
@@ -2546,6 +2536,7 @@ non-nil value, that slot cannot be set via `setf'.
2546 (push slot slots) 2536 (push slot slots)
2547 (push (nth 1 desc) defaults) 2537 (push (nth 1 desc) defaults)
2548 (push `(cl-defsubst ,accessor (cl-x) 2538 (push `(cl-defsubst ,accessor (cl-x)
2539 (declare (side-effect-free t))
2549 ,@(and pred-check 2540 ,@(and pred-check
2550 (list `(or ,pred-check 2541 (list `(or ,pred-check
2551 (error "%s accessing a non-%s" 2542 (error "%s accessing a non-%s"
@@ -2554,7 +2545,6 @@ non-nil value, that slot cannot be set via `setf'.
2554 (if (= pos 0) '(car cl-x) 2545 (if (= pos 0) '(car cl-x)
2555 `(nth ,pos cl-x)))) 2546 `(nth ,pos cl-x))))
2556 forms) 2547 forms)
2557 (push (cons accessor t) side-eff)
2558 (if (cadr (memq :read-only (cddr desc))) 2548 (if (cadr (memq :read-only (cddr desc)))
2559 (push `(gv-define-expander ,accessor 2549 (push `(gv-define-expander ,accessor
2560 (lambda (_cl-do _cl-x) 2550 (lambda (_cl-do _cl-x)
@@ -2587,15 +2577,14 @@ non-nil value, that slot cannot be set via `setf'.
2587 defaults (nreverse defaults)) 2577 defaults (nreverse defaults))
2588 (when pred-form 2578 (when pred-form
2589 (push `(cl-defsubst ,predicate (cl-x) 2579 (push `(cl-defsubst ,predicate (cl-x)
2580 (declare (side-effect-free error-free))
2590 ,(if (eq (car pred-form) 'and) 2581 ,(if (eq (car pred-form) 'and)
2591 (append pred-form '(t)) 2582 (append pred-form '(t))
2592 `(and ,pred-form t))) 2583 `(and ,pred-form t)))
2593 forms) 2584 forms)
2594 (push `(put ',name 'cl-deftype-satisfies ',predicate) forms) 2585 (push `(put ',name 'cl-deftype-satisfies ',predicate) forms))
2595 (push (cons predicate 'error-free) side-eff))
2596 (and copier 2586 (and copier
2597 (progn (push `(defun ,copier (x) (copy-sequence x)) forms) 2587 (push `(defalias ',copier #'copy-sequence) forms))
2598 (push (cons copier t) side-eff)))
2599 (if constructor 2588 (if constructor
2600 (push (list constructor 2589 (push (list constructor
2601 (cons '&key (delq nil (copy-sequence slots)))) 2590 (cons '&key (delq nil (copy-sequence slots))))
@@ -2607,11 +2596,11 @@ non-nil value, that slot cannot be set via `setf'.
2607 (make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d))) 2596 (make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d)))
2608 slots defaults))) 2597 slots defaults)))
2609 (push `(cl-defsubst ,name 2598 (push `(cl-defsubst ,name
2610 (&cl-defs '(nil ,@descs) ,@args) 2599 (&cl-defs '(nil ,@descs) ,@args)
2600 ,@(if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs)))
2601 '((declare (side-effect-free t))))
2611 (,type ,@make)) 2602 (,type ,@make))
2612 forms) 2603 forms)))
2613 (if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs)))
2614 (push (cons name t) side-eff))))
2615 (if print-auto (nconc print-func (list '(princ ")" cl-s) t))) 2604 (if print-auto (nconc print-func (list '(princ ")" cl-s) t)))
2616 ;; Don't bother adding to cl-custom-print-functions since it's not used 2605 ;; Don't bother adding to cl-custom-print-functions since it's not used
2617 ;; by anything anyway! 2606 ;; by anything anyway!
@@ -2624,17 +2613,14 @@ non-nil value, that slot cannot be set via `setf'.
2624 ;; (and ,pred-form ,print-func)) 2613 ;; (and ,pred-form ,print-func))
2625 ;; cl-custom-print-functions)) 2614 ;; cl-custom-print-functions))
2626 ;; forms)) 2615 ;; forms))
2627 (push `(setq ,tag-symbol (list ',tag)) forms) 2616 `(progn
2628 (push `(cl-eval-when (compile load eval) 2617 (defvar ,tag-symbol)
2629 (put ',name 'cl-struct-slots ',descs) 2618 ,@(nreverse forms)
2630 (put ',name 'cl-struct-type ',(list type (eq named t))) 2619 (eval-and-compile
2631 (put ',name 'cl-struct-include ',include) 2620 (cl-struct-define ',name ,docstring ',include
2632 (put ',name 'cl-struct-print ,print-auto) 2621 ',type ,(eq named t) ',descs ',tag-symbol ',tag
2633 ,@(mapcar (lambda (x) 2622 ',print-auto))
2634 `(function-put ',(car x) 'side-effect-free ',(cdr x))) 2623 ',name)))
2635 side-eff))
2636 forms)
2637 `(progn ,@(nreverse (cons `',name forms)))))
2638 2624
2639(defun cl-struct-sequence-type (struct-type) 2625(defun cl-struct-sequence-type (struct-type)
2640 "Return the sequence used to build STRUCT-TYPE. 2626 "Return the sequence used to build STRUCT-TYPE.
@@ -2741,14 +2727,11 @@ STRING is an optional description of the desired type."
2741 (declare (debug (place cl-type-spec &optional stringp))) 2727 (declare (debug (place cl-type-spec &optional stringp)))
2742 (and (or (not (cl--compiling-file)) 2728 (and (or (not (cl--compiling-file))
2743 (< cl--optimize-speed 3) (= cl--optimize-safety 3)) 2729 (< cl--optimize-speed 3) (= cl--optimize-safety 3))
2744 (let* ((temp (if (cl--simple-expr-p form 3) 2730 (macroexp-let2 macroexp-copyable-p temp form
2745 form (make-symbol "--cl-var--"))) 2731 `(progn (or (cl-typep ,temp ',type)
2746 (body `(or ,(cl--make-type-test temp type) 2732 (signal 'wrong-type-argument
2747 (signal 'wrong-type-argument 2733 (list ,(or string `',type) ,temp ',form)))
2748 (list ,(or string `',type) 2734 nil))))
2749 ,temp ',form)))))
2750 (if (eq temp form) `(progn ,body nil)
2751 `(let ((,temp ,form)) ,body nil)))))
2752 2735
2753;;;###autoload 2736;;;###autoload
2754(defmacro cl-assert (form &optional show-args string &rest args) 2737(defmacro cl-assert (form &optional show-args string &rest args)
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
new file mode 100644
index 00000000000..c9867b412a1
--- /dev/null
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -0,0 +1,48 @@
1;;; cl-preloaded.el --- Preloaded part of the CL library -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2015 Free Software Foundation, Inc
4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;; The expectation is that structs defined with cl-defstruct do not
25;; need cl-lib at run-time, but we'd like to hide the details of the
26;; cl-struct metadata behind the cl-struct-define function, so we put
27;; it in this pre-loaded file.
28
29;;; Code:
30
31(defun cl-struct-define (name docstring parent type named slots children-sym
32 tag print-auto)
33 (if (boundp children-sym)
34 (add-to-list children-sym tag)
35 (set children-sym (list tag)))
36 ;; If the cl-generic support, we need to be able to check
37 ;; if a vector is a cl-struct object, without knowing its particular type.
38 ;; So we use the (otherwise) unused function slots of the tag symbol
39 ;; to put a special witness value, to make the check easy and reliable.
40 (unless named (fset tag :quick-object-witness-check))
41 (put name 'cl-struct-slots slots)
42 (put name 'cl-struct-type (list type named))
43 (if parent (put name 'cl-struct-include parent))
44 (if print-auto (put name 'cl-struct-print print-auto))
45 (if docstring (put name 'structure-documentation docstring)))
46
47(provide 'cl-preloaded)
48;;; cl-preloaded.el ends here
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 7492f0522ab..d8d39020d0f 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -224,9 +224,9 @@ Return nil if that option doesn't exist."
224(defsubst eieio-object-p (obj) 224(defsubst eieio-object-p (obj)
225 "Return non-nil if OBJ is an EIEIO object." 225 "Return non-nil if OBJ is an EIEIO object."
226 (and (vectorp obj) 226 (and (vectorp obj)
227 (condition-case nil 227 (> (length obj) 0)
228 (eq (aref (eieio--object-class-object obj) 0) 'defclass) 228 (eq (symbol-function (eieio--class-tag obj))
229 (error nil)))) 229 :quick-object-witness-check)))
230 230
231(defalias 'object-p 'eieio-object-p) 231(defalias 'object-p 'eieio-object-p)
232 232
@@ -539,6 +539,7 @@ See `defclass' for more information."
539 ;; objects readable. 539 ;; objects readable.
540 (tag (intern (format "eieio-class-tag--%s" cname)))) 540 (tag (intern (format "eieio-class-tag--%s" cname))))
541 (set tag newc) 541 (set tag newc)
542 (fset tag :quick-object-witness-check)
542 (setf (eieio--object-class-tag cache) tag) 543 (setf (eieio--object-class-tag cache) tag)
543 (let ((eieio-skip-typecheck t)) 544 (let ((eieio-skip-typecheck t))
544 ;; All type-checking has been done to our satisfaction 545 ;; All type-checking has been done to our satisfaction
@@ -1223,9 +1224,10 @@ method invocation orders of the involved classes."
1223 ;; specializer in a defmethod form. 1224 ;; specializer in a defmethod form.
1224 ;; So we can ignore types that are not known to denote classes. 1225 ;; So we can ignore types that are not known to denote classes.
1225 (and (class-p type) 1226 (and (class-p type)
1226 ;; Prefer (aref ,name 0) over (eieio--class-tag ,name) so that 1227 ;; Use the exact same code as for cl-struct, so that methods
1227 ;; the tagcode is identical to the tagcode used for cl-struct. 1228 ;; that dispatch on both kinds of objects get to share this
1228 `(50 . (and (vectorp ,name) (aref ,name 0))))) 1229 ;; part of the dispatch code.
1230 `(50 . ,(cl--generic-struct-tag name))))
1229 1231
1230(add-function :before-until cl-generic-tag-types-function 1232(add-function :before-until cl-generic-tag-types-function
1231 #'eieio--generic-tag-types) 1233 #'eieio--generic-tag-types)
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 96641c8a268..003b0db4abd 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -145,7 +145,8 @@
145 (file-error (load "ldefs-boot.el"))) 145 (file-error (load "ldefs-boot.el")))
146 146
147(load "emacs-lisp/nadvice") 147(load "emacs-lisp/nadvice")
148(load "minibuffer") 148(load "emacs-lisp/cl-preloaded")
149(load "minibuffer") ;After loaddefs, for define-minor-mode.
149(load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table. 150(load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
150(load "simple") 151(load "simple")
151 152
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a0c9eba4144..59c277b01c2 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1628,6 +1628,8 @@ The preference is a float determined from `shr-prefer-media-type'."
1628 (let ((trs nil) 1628 (let ((trs nil)
1629 (shr-inhibit-decoration (not fill)) 1629 (shr-inhibit-decoration (not fill))
1630 (rowspans (make-vector (length widths) 0)) 1630 (rowspans (make-vector (length widths) 0))
1631 (colspan-remaining 0)
1632 colspan-width colspan-count
1631 width colspan) 1633 width colspan)
1632 (dolist (row (dom-non-text-children dom)) 1634 (dolist (row (dom-non-text-children dom))
1633 (when (eq (dom-tag row) 'tr) 1635 (when (eq (dom-tag row) 'tr)
@@ -1659,24 +1661,39 @@ The preference is a float determined from `shr-prefer-media-type'."
1659 (if column 1661 (if column
1660 (aref widths width-column) 1662 (aref widths width-column)
1661 10)) 1663 10))
1662 (when (and fill 1664 (when (setq colspan (dom-attr column 'colspan))
1663 (setq colspan (dom-attr column 'colspan)))
1664 (setq colspan (min (string-to-number colspan) 1665 (setq colspan (min (string-to-number colspan)
1665 ;; The colspan may be wrong, so 1666 ;; The colspan may be wrong, so
1666 ;; truncate it to the length of the 1667 ;; truncate it to the length of the
1667 ;; remaining columns. 1668 ;; remaining columns.
1668 (- (length widths) i))) 1669 (- (length widths) i)))
1669 (dotimes (j (1- colspan)) 1670 (dotimes (j (1- colspan))
1670 (if (> (+ i 1 j) (1- (length widths))) 1671 (setq width
1671 (setq width (aref widths (1- (length widths)))) 1672 (if (> (+ i 1 j) (1- (length widths)))
1672 (setq width (+ width 1673 ;; If we have a colspan spec that's longer
1673 shr-table-separator-length 1674 ;; than the table is wide, just use the last
1674 (aref widths (+ i 1 j)))))) 1675 ;; width as the width.
1675 (setq width-column (+ width-column (1- colspan)))) 1676 (aref widths (1- (length widths)))
1677 ;; Sum up the widths of the columns we're
1678 ;; spanning.
1679 (+ width
1680 shr-table-separator-length
1681 (aref widths (+ i 1 j))))))
1682 (setq width-column (+ width-column (1- colspan))
1683 colspan-count colspan
1684 colspan-remaining colspan))
1676 (when (or column 1685 (when (or column
1677 (not fill)) 1686 (not fill))
1678 (push (shr-render-td column width fill) 1687 (let ((data (shr-render-td column width fill)))
1679 tds)) 1688 (if (and (not fill)
1689 (> colspan-remaining 0))
1690 (progn
1691 (when (= colspan-count colspan-remaining)
1692 (setq colspan-width data))
1693 (let ((this-width (/ colspan-width colspan-count)))
1694 (push this-width tds)
1695 (setq colspan-remaining (1- colspan-remaining))))
1696 (push data tds))))
1680 (setq i (1+ i) 1697 (setq i (1+ i)
1681 width-column (1+ width-column)))) 1698 width-column (1+ width-column))))
1682 (push (nreverse tds) trs)))) 1699 (push (nreverse tds) trs))))
diff --git a/src/ChangeLog b/src/ChangeLog
index 8efc90727e1..1df4f6ae0ba 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -57,6 +57,10 @@
57 * emacs.c (syms_of_emacs) <system-configuration>: Doc fix. 57 * emacs.c (syms_of_emacs) <system-configuration>: Doc fix.
58 (Bug#19502) 58 (Bug#19502)
59 59
602015-01-28 Stefan Monnier <monnier@iro.umontreal.ca>
61
62 * lisp.mk (lisp): Add cl-preloaded.
63
602015-01-27 Paul Eggert <eggert@cs.ucla.edu> 642015-01-27 Paul Eggert <eggert@cs.ucla.edu>
61 65
62 Use bool for boolean in xfaces.c 66 Use bool for boolean in xfaces.c
diff --git a/src/lisp.mk b/src/lisp.mk
index a9deb2b53d9..ee2a07c0fd7 100644
--- a/src/lisp.mk
+++ b/src/lisp.mk
@@ -71,6 +71,7 @@ lisp = \
71 $(lispsource)/faces.elc \ 71 $(lispsource)/faces.elc \
72 $(lispsource)/button.elc \ 72 $(lispsource)/button.elc \
73 $(lispsource)/startup.elc \ 73 $(lispsource)/startup.elc \
74 $(lispsource)/emacs-lisp/cl-preloaded.elc \
74 $(lispsource)/emacs-lisp/nadvice.elc \ 75 $(lispsource)/emacs-lisp/nadvice.elc \
75 $(lispsource)/minibuffer.elc \ 76 $(lispsource)/minibuffer.elc \
76 $(lispsource)/abbrev.elc \ 77 $(lispsource)/abbrev.elc \