aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2005-05-22 17:46:50 +0000
committerJuanma Barranquero2005-05-22 17:46:50 +0000
commit708c63a68973a4f06aeee900116b86fed2dcaa85 (patch)
treeb56369049ae978842f3e33396980d35bc7725b50
parent1b12fa9dc4be9a4fec1e6cdfdd12b146ce1f3ae9 (diff)
downloademacs-708c63a68973a4f06aeee900116b86fed2dcaa85.tar.gz
emacs-708c63a68973a4f06aeee900116b86fed2dcaa85.zip
(pushnew, cl-macroexpand, floatp-safe, plusp, minusp, oddp, evenp, mapcar*,
list*, copy-list, adjoin, subst): Improve argument/docstring consistency.
-rw-r--r--lisp/emacs-lisp/cl.el44
1 files changed, 25 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index 11835629bd7..8385af601af 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -162,7 +162,8 @@ be a symbol, or any generalized variable allowed by `setf'."
162 "(pushnew X PLACE): insert X at the head of the list if not already there. 162 "(pushnew X PLACE): insert X at the head of the list if not already there.
163Like (push X PLACE), except that the list is unmodified if X is `eql' to 163Like (push X PLACE), except that the list is unmodified if X is `eql' to
164an element already on the list. 164an element already on the list.
165Keywords supported: :test :test-not :key" 165\nKeywords supported: :test :test-not :key
166\n(fn X PLACE [KEYWORD VALUE]...)"
166 (if (symbolp place) (list 'setq place (list* 'adjoin x place keys)) 167 (if (symbolp place) (list 'setq place (list* 'adjoin x place keys))
167 (list* 'callf2 'adjoin x place keys))) 168 (list* 'callf2 'adjoin x place keys)))
168 169
@@ -256,7 +257,8 @@ Otherwise, the macro is expanded and the expansion is considered
256in place of FORM. When a non-macro-call results, it is returned. 257in place of FORM. When a non-macro-call results, it is returned.
257 258
258The second optional arg ENVIRONMENT specifies an environment of macro 259The second optional arg ENVIRONMENT specifies an environment of macro
259definitions to shadow the loaded ones for use in file byte-compilation." 260definitions to shadow the loaded ones for use in file byte-compilation.
261\n(fn FORM &optional ENVIRONMENT)"
260 (let ((cl-macro-environment cl-env)) 262 (let ((cl-macro-environment cl-env))
261 (while (progn (setq cl-macro (funcall cl-old-macroexpand cl-macro cl-env)) 263 (while (progn (setq cl-macro (funcall cl-old-macroexpand cl-macro cl-env))
262 (and (symbolp cl-macro) 264 (and (symbolp cl-macro)
@@ -300,27 +302,27 @@ definitions to shadow the loaded ones for use in file byte-compilation."
300 302
301;;; Numbers. 303;;; Numbers.
302 304
303(defun floatp-safe (x) 305(defun floatp-safe (object)
304 "Return t if OBJECT is a floating point number. 306 "Return t if OBJECT is a floating point number.
305On Emacs versions that lack floating-point support, this function 307On Emacs versions that lack floating-point support, this function
306always returns nil." 308always returns nil."
307 (and (numberp x) (not (integerp x)))) 309 (and (numberp object) (not (integerp object))))
308 310
309(defun plusp (x) 311(defun plusp (number)
310 "Return t if NUMBER is positive." 312 "Return t if NUMBER is positive."
311 (> x 0)) 313 (> number 0))
312 314
313(defun minusp (x) 315(defun minusp (number)
314 "Return t if NUMBER is negative." 316 "Return t if NUMBER is negative."
315 (< x 0)) 317 (< number 0))
316 318
317(defun oddp (x) 319(defun oddp (integer)
318 "Return t if INTEGER is odd." 320 "Return t if INTEGER is odd."
319 (eq (logand x 1) 1)) 321 (eq (logand integer 1) 1))
320 322
321(defun evenp (x) 323(defun evenp (integer)
322 "Return t if INTEGER is even." 324 "Return t if INTEGER is even."
323 (eq (logand x 1) 0)) 325 (eq (logand integer 1) 0))
324 326
325(defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time))) 327(defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time)))
326 328
@@ -344,7 +346,8 @@ always returns nil."
344If there are several SEQs, FUNCTION is called with that many arguments, 346If there are several SEQs, FUNCTION is called with that many arguments,
345and mapping stops as soon as the shortest list runs out. With just one 347and mapping stops as soon as the shortest list runs out. With just one
346SEQ, this is like `mapcar'. With several, it is like the Common Lisp 348SEQ, this is like `mapcar'. With several, it is like the Common Lisp
347`mapcar' function extended to arbitrary sequence types." 349`mapcar' function extended to arbitrary sequence types.
350\n(fn FUNCTION SEQ...)"
348 (if cl-rest 351 (if cl-rest
349 (if (or (cdr cl-rest) (nlistp cl-x) (nlistp (car cl-rest))) 352 (if (or (cdr cl-rest) (nlistp cl-x) (nlistp (car cl-rest)))
350 (cl-mapcar-many cl-func (cons cl-x cl-rest)) 353 (cl-mapcar-many cl-func (cons cl-x cl-rest))
@@ -503,9 +506,10 @@ SEQ, this is like `mapcar'. With several, it is like the Common Lisp
503;; x)) 506;; x))
504 507
505(defun list* (arg &rest rest) ; See compiler macro in cl-macs.el 508(defun list* (arg &rest rest) ; See compiler macro in cl-macs.el
506 "Return a new list with specified args as elements, consed to last arg. 509 "Return a new list with specified ARGs as elements, consed to last ARG.
507Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to 510Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
508`(cons A (cons B (cons C D)))'." 511`(cons A (cons B (cons C D)))'.
512\n(fn ARG...)"
509 (cond ((not rest) arg) 513 (cond ((not rest) arg)
510 ((not (cdr rest)) (cons arg (car rest))) 514 ((not (cdr rest)) (cons arg (car rest)))
511 (t (let* ((n (length rest)) 515 (t (let* ((n (length rest))
@@ -522,8 +526,8 @@ Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
522 (nreverse res))) 526 (nreverse res)))
523 527
524(defun copy-list (list) 528(defun copy-list (list)
525 "Return a copy of a list, which may be a dotted list. 529 "Return a copy of LIST, which may be a dotted list.
526The elements of the list are not copied, just the list structure itself." 530The elements of LIST are not copied, just the list structure itself."
527 (if (consp list) 531 (if (consp list)
528 (let ((res nil)) 532 (let ((res nil))
529 (while (consp list) (push (pop list) res)) 533 (while (consp list) (push (pop list) res))
@@ -544,7 +548,8 @@ The elements of the list are not copied, just the list structure itself."
544(defun adjoin (cl-item cl-list &rest cl-keys) ; See compiler macro in cl-macs 548(defun adjoin (cl-item cl-list &rest cl-keys) ; See compiler macro in cl-macs
545 "Return ITEM consed onto the front of LIST only if it's not already there. 549 "Return ITEM consed onto the front of LIST only if it's not already there.
546Otherwise, return LIST unmodified. 550Otherwise, return LIST unmodified.
547Keywords supported: :test :test-not :key" 551\nKeywords supported: :test :test-not :key
552\n(fn ITEM LIST [KEYWORD VALUE]...)"
548 (cond ((or (equal cl-keys '(:test eq)) 553 (cond ((or (equal cl-keys '(:test eq))
549 (and (null cl-keys) (not (numberp cl-item)))) 554 (and (null cl-keys) (not (numberp cl-item))))
550 (if (memq cl-item cl-list) cl-list (cons cl-item cl-list))) 555 (if (memq cl-item cl-list) cl-list (cons cl-item cl-list)))
@@ -555,7 +560,8 @@ Keywords supported: :test :test-not :key"
555(defun subst (cl-new cl-old cl-tree &rest cl-keys) 560(defun subst (cl-new cl-old cl-tree &rest cl-keys)
556 "Substitute NEW for OLD everywhere in TREE (non-destructively). 561 "Substitute NEW for OLD everywhere in TREE (non-destructively).
557Return a copy of TREE with all elements `eql' to OLD replaced by NEW. 562Return a copy of TREE with all elements `eql' to OLD replaced by NEW.
558Keywords supported: :test :test-not :key" 563\nKeywords supported: :test :test-not :key
564\n(fn NEW OLD TREE [KEYWORD VALUE]...)"
559 (if (or cl-keys (and (numberp cl-old) (not (integerp cl-old)))) 565 (if (or cl-keys (and (numberp cl-old) (not (integerp cl-old))))
560 (apply 'sublis (list (cons cl-old cl-new)) cl-tree cl-keys) 566 (apply 'sublis (list (cons cl-old cl-new)) cl-tree cl-keys)
561 (cl-do-subst cl-new cl-old cl-tree))) 567 (cl-do-subst cl-new cl-old cl-tree)))