aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2001-11-30 00:56:45 +0000
committerStefan Monnier2001-11-30 00:56:45 +0000
commite0b163225fcba986a267c9e68f8792cccadc5656 (patch)
tree2ff6a80b79ab88217796ea00549ce8fd34a69a72 /lisp
parente700ec12bdeae48e917af0c3b94dd4dc3be2c8fc (diff)
downloademacs-e0b163225fcba986a267c9e68f8792cccadc5656.tar.gz
emacs-e0b163225fcba986a267c9e68f8792cccadc5656.zip
(shiftf): Fix the fast case so
(let ((a 1) (b 2)) (shiftf a b (cons a b)) b) returns (1 . 2). (cl-make-type-test): Use char-valid-p for `character'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/cl-macs.el35
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 2d51ac23adb..feb1a2f956b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1845,12 +1845,14 @@ The form returns true if TAG was found and removed, nil otherwise."
1845Example: (shiftf A B C) sets A to B, B to C, and returns the old A. 1845Example: (shiftf A B C) sets A to B, B to C, and returns the old A.
1846Each PLACE may be a symbol, or any generalized variable allowed by `setf'." 1846Each PLACE may be a symbol, or any generalized variable allowed by `setf'."
1847 (if (not (memq nil (mapcar 'symbolp (butlast (cons place args))))) 1847 (if (not (memq nil (mapcar 'symbolp (butlast (cons place args)))))
1848 (list* 'prog1 place 1848 (list 'prog1 place
1849 (let ((sets nil)) 1849 (let ((sets nil))
1850 (while args 1850 (while args
1851 (cl-push (list 'setq place (car args)) sets) 1851 (cl-push (list 'setq place (car args)) sets)
1852 (setq place (cl-pop args))) 1852 (setq place (cl-pop args)))
1853 (nreverse sets))) 1853 `(setq ,(cadar sets)
1854 (prog1 ,(caddar sets)
1855 ,@(nreverse (cdr sets))))))
1854 (let* ((places (reverse (cons place args))) 1856 (let* ((places (reverse (cons place args)))
1855 (form (cl-pop places))) 1857 (form (cl-pop places)))
1856 (while places 1858 (while places
@@ -2239,15 +2241,16 @@ The type name can then be used in `typecase', `check-type', etc."
2239 name 'cl-deftype-handler (cons (list* '&cl-defs ''('*) arglist) body)))) 2241 name 'cl-deftype-handler (cons (list* '&cl-defs ''('*) arglist) body))))
2240 2242
2241(defun cl-make-type-test (val type) 2243(defun cl-make-type-test (val type)
2242 (if (memq type '(character string-char)) (setq type '(integer 0 255)))
2243 (if (symbolp type) 2244 (if (symbolp type)
2244 (cond ((get type 'cl-deftype-handler) 2245 (cond ((get type 'cl-deftype-handler)
2245 (cl-make-type-test val (funcall (get type 'cl-deftype-handler)))) 2246 (cl-make-type-test val (funcall (get type 'cl-deftype-handler))))
2246 ((memq type '(nil t)) type) 2247 ((memq type '(nil t)) type)
2247 ((eq type 'null) (list 'null val)) 2248 ((eq type 'null) `(null ,val))
2248 ((eq type 'float) (list 'floatp-safe val)) 2249 ((eq type 'float) `(floatp-safe ,val))
2249 ((eq type 'real) (list 'numberp val)) 2250 ((eq type 'real) `(numberp ,val))
2250 ((eq type 'fixnum) (list 'integerp val)) 2251 ((eq type 'fixnum) `(integerp ,val))
2252 ;; FIXME: Should `character' accept things like ?\C-\M-a ? -stef
2253 ((memq type '(character string-char))) `(char-valid-p ,val)
2251 (t 2254 (t
2252 (let* ((name (symbol-name type)) 2255 (let* ((name (symbol-name type))
2253 (namep (intern (concat name "p")))) 2256 (namep (intern (concat name "p"))))
@@ -2256,21 +2259,21 @@ The type name can then be used in `typecase', `check-type', etc."
2256 (cond ((get (car type) 'cl-deftype-handler) 2259 (cond ((get (car type) 'cl-deftype-handler)
2257 (cl-make-type-test val (apply (get (car type) 'cl-deftype-handler) 2260 (cl-make-type-test val (apply (get (car type) 'cl-deftype-handler)
2258 (cdr type)))) 2261 (cdr type))))
2259 ((memq (car-safe type) '(integer float real number)) 2262 ((memq (car type) '(integer float real number))
2260 (delq t (list 'and (cl-make-type-test val (car type)) 2263 (delq t (and (cl-make-type-test val (car type))
2261 (if (memq (cadr type) '(* nil)) t 2264 (if (memq (cadr type) '(* nil)) t
2262 (if (consp (cadr type)) (list '> val (caadr type)) 2265 (if (consp (cadr type)) (list '> val (caadr type))
2263 (list '>= val (cadr type)))) 2266 (list '>= val (cadr type))))
2264 (if (memq (caddr type) '(* nil)) t 2267 (if (memq (caddr type) '(* nil)) t
2265 (if (consp (caddr type)) (list '< val (caaddr type)) 2268 (if (consp (caddr type)) (list '< val (caaddr type))
2266 (list '<= val (caddr type))))))) 2269 (list '<= val (caddr type)))))))
2267 ((memq (car-safe type) '(and or not)) 2270 ((memq (car type) '(and or not))
2268 (cons (car type) 2271 (cons (car type)
2269 (mapcar (function (lambda (x) (cl-make-type-test val x))) 2272 (mapcar (function (lambda (x) (cl-make-type-test val x)))
2270 (cdr type)))) 2273 (cdr type))))
2271 ((memq (car-safe type) '(member member*)) 2274 ((memq (car type) '(member member*))
2272 (list 'and (list 'member* val (list 'quote (cdr type))) t)) 2275 (list 'and (list 'member* val (list 'quote (cdr type))) t))
2273 ((eq (car-safe type) 'satisfies) (list (cadr type) val)) 2276 ((eq (car type) 'satisfies) (list (cadr type) val))
2274 (t (error "Bad type spec: %s" type))))) 2277 (t (error "Bad type spec: %s" type)))))
2275 2278
2276(defun typep (val type) ; See compiler macro below. 2279(defun typep (val type) ; See compiler macro below.