From f6c6e09c7f16b7adbe2e5d1214a27902937f419e Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 4 Nov 2012 07:22:06 -0500 Subject: Auto-commit of loaddefs files. --- lisp/emacs-lisp/cl-loaddefs.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el index 5ad6e37a5a1..a2e394e3f4e 100644 --- a/lisp/emacs-lisp/cl-loaddefs.el +++ b/lisp/emacs-lisp/cl-loaddefs.el @@ -265,7 +265,7 @@ Remove from SYMBOL's plist the property PROPNAME and its value. ;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when ;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp ;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) -;;;;;; "cl-macs" "cl-macs.el" "366e9efa4e3e7a81b2253e503611b23a") +;;;;;; "cl-macs" "cl-macs.el" "57cf89149db1e8ea6bc1582713980cf8") ;;; Generated autoloads from cl-macs.el (autoload 'cl--compiler-macro-list* "cl-macs" "\ @@ -473,9 +473,9 @@ from OBARRAY. (put 'cl-do-symbols 'lisp-indent-function '1) (autoload 'cl-do-all-symbols "cl-macs" "\ +Like `cl-do-symbols', but use the default obarray. - -\(fn SPEC &rest BODY)" nil t) +\(fn (VAR [RESULT]) BODY...)" nil t) (put 'cl-do-all-symbols 'lisp-indent-function '1) -- cgit v1.2.3 From 5593ed900d0d420f4ee3dd7af3f56b118308a3c0 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 5 Nov 2012 00:29:12 -0800 Subject: Misc small cl doc fixes * emacs-lisp/cl-extra.el (cl-maplist, cl-mapcan): Doc fix. * emacs-lisp/cl-extra.el (cl-prettyexpand): * emacs-lisp/cl-lib.el (cl-proclaim, cl-declaim): * emacs-lisp/cl-macs.el (cl-destructuring-bind, cl-locally) (cl-the, cl-compiler-macroexpand): Add basic doc strings. --- lisp/ChangeLog | 9 +++++++++ lisp/emacs-lisp/cl-extra.el | 7 +++++-- lisp/emacs-lisp/cl-lib.el | 7 ++++++- lisp/emacs-lisp/cl-macs.el | 7 +++++++ 4 files changed, 27 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5be111818dd..95c407fcdb7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2012-11-05 Glenn Morris + + * emacs-lisp/cl-extra.el (cl-prettyexpand): + * emacs-lisp/cl-lib.el (cl-proclaim, cl-declaim): + * emacs-lisp/cl-macs.el (cl-destructuring-bind, cl-locally) + (cl-the, cl-compiler-macroexpand): Add basic doc strings. + + * emacs-lisp/cl-extra.el (cl-maplist, cl-mapcan): Doc fix. + 2012-11-03 Glenn Morris * emacs-lisp/cl-macs.el (cl-parse-loop-clause): diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index c72e3342648..8f801b39d3d 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -131,7 +131,7 @@ TYPE is the sequence type to return. ;;;###autoload (defun cl-maplist (cl-func cl-list &rest cl-rest) "Map FUNCTION to each sublist of LIST or LISTs. -Like `mapcar', except applies to lists and their cdr's rather than to +Like `cl-mapcar', except applies to lists and their cdr's rather than to the elements themselves. \n(fn FUNCTION LIST...)" (if cl-rest @@ -170,7 +170,7 @@ the elements themselves. ;;;###autoload (defun cl-mapcan (cl-func cl-seq &rest cl-rest) - "Like `mapcar', but nconc's together the values returned by the function. + "Like `cl-mapcar', but nconc's together the values returned by the function. \n(fn FUNCTION SEQUENCE...)" (apply 'nconc (apply 'cl-mapcar cl-func cl-seq cl-rest))) @@ -675,6 +675,9 @@ PROPLIST is a list of the sort returned by `symbol-plist'. ;;;###autoload (defun cl-prettyexpand (form &optional full) + "Expand macros in FORM and insert the pretty-printed result. +Optional argument FULL non-nil means to expand all macros, +including `cl-block' and `cl-eval-when'." (message "Expanding...") (let ((cl--compiling-file full) (byte-compile-macro-environment nil)) diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index 122402797e1..e9b30a8f62d 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -251,12 +251,17 @@ one value. (defvar cl-proclaims-deferred nil) (defun cl-proclaim (spec) + "Record a global declaration specified by SPEC." (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t) (push spec cl-proclaims-deferred)) nil) (defmacro cl-declaim (&rest specs) - (let ((body (mapcar (function (lambda (x) (list 'cl-proclaim (list 'quote x)))) + "Like `cl-proclaim', but takes any number of unevaluated, unquoted arguments. +Puts `(cl-eval-when (compile load eval) ...)' around the declarations +so that they are registered at compile-time as well as run-time." + (let ((body (mapcar (function (lambda (x) + (list 'cl-proclaim (list 'quote x)))) specs))) (if (cl--compiling-file) (cl-list* 'cl-eval-when '(compile load eval) body) (cons 'progn body)))) ; avoid loading cl-macs.el for cl-eval-when diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 8d240774edb..b28f8f7f9e9 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -554,6 +554,7 @@ its argument list allows full Common Lisp conventions." ;;;###autoload (defmacro cl-destructuring-bind (args expr &rest body) + "Bind the variables in ARGS to the result of EXPR and execute BODY." (declare (indent 2) (debug (&define cl-macro-list def-form cl-declarations def-body))) (let* ((cl--bind-lets nil) (cl--bind-forms nil) (cl--bind-inits nil) @@ -1886,10 +1887,12 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C). ;;;###autoload (defmacro cl-locally (&rest body) + "Equivalent to `progn'." (declare (debug t)) (cons 'progn body)) ;;;###autoload (defmacro cl-the (_type form) + "At present this ignores _TYPE and is simply equivalent to FORM." (declare (indent 1) (debug (cl-type-spec form))) form) @@ -2537,6 +2540,10 @@ and then returning foo." ;;;###autoload (defun cl-compiler-macroexpand (form) + "Like `macroexpand', but for compiler macros. +Expands FORM repeatedly until no further expansion is possible. +Returns FORM unchanged if it has no compiler macro, or if it has a +macro that returns its `&whole' argument." (while (let ((func (car-safe form)) (handler nil)) (while (and (symbolp func) -- cgit v1.2.3 From 7e92a493969e1cb5887f87508d7c020bb11693b6 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 5 Nov 2012 07:20:41 -0500 Subject: Auto-commit of loaddefs files. --- lisp/emacs-lisp/cl-loaddefs.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el index a2e394e3f4e..e18c32da996 100644 --- a/lisp/emacs-lisp/cl-loaddefs.el +++ b/lisp/emacs-lisp/cl-loaddefs.el @@ -11,7 +11,7 @@ ;;;;;; cl--map-overlays cl--map-intervals cl--map-keymap-recursively ;;;;;; cl-notevery cl-notany cl-every cl-some cl-mapcon cl-mapcan ;;;;;; cl-mapl cl-mapc cl-maplist cl-map cl--mapcar-many cl-equalp -;;;;;; cl-coerce) "cl-extra" "cl-extra.el" "7d7f65d8a05e954a919fe2555b68fb05") +;;;;;; cl-coerce) "cl-extra" "cl-extra.el" "b7d4e24fe58609eaf4fb319c81eb829e") ;;; Generated autoloads from cl-extra.el (autoload 'cl-coerce "cl-extra" "\ @@ -41,7 +41,7 @@ TYPE is the sequence type to return. (autoload 'cl-maplist "cl-extra" "\ Map FUNCTION to each sublist of LIST or LISTs. -Like `mapcar', except applies to lists and their cdr's rather than to +Like `cl-mapcar', except applies to lists and their cdr's rather than to the elements themselves. \(fn FUNCTION LIST...)" nil nil) @@ -57,7 +57,7 @@ Like `cl-maplist', but does not accumulate values returned by the function. \(fn FUNCTION LIST...)" nil nil) (autoload 'cl-mapcan "cl-extra" "\ -Like `mapcar', but nconc's together the values returned by the function. +Like `cl-mapcar', but nconc's together the values returned by the function. \(fn FUNCTION SEQUENCE...)" nil nil) @@ -248,7 +248,9 @@ Remove from SYMBOL's plist the property PROPNAME and its value. \(fn SYMBOL PROPNAME)" nil nil) (autoload 'cl-prettyexpand "cl-extra" "\ - +Expand macros in FORM and insert the pretty-printed result. +Optional argument FULL non-nil means to expand all macros, +including `cl-block' and `cl-eval-when'. \(fn FORM &optional FULL)" nil nil) @@ -265,7 +267,7 @@ Remove from SYMBOL's plist the property PROPNAME and its value. ;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when ;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp ;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) -;;;;;; "cl-macs" "cl-macs.el" "57cf89149db1e8ea6bc1582713980cf8") +;;;;;; "cl-macs" "cl-macs.el" "a7228877484d2b39e1c2bee40b011734") ;;; Generated autoloads from cl-macs.el (autoload 'cl--compiler-macro-list* "cl-macs" "\ @@ -320,7 +322,7 @@ its argument list allows full Common Lisp conventions. \(fn FUNC)" nil t) (autoload 'cl-destructuring-bind "cl-macs" "\ - +Bind the variables in ARGS to the result of EXPR and execute BODY. \(fn ARGS EXPR &rest BODY)" nil t) @@ -564,12 +566,12 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C). (put 'cl-multiple-value-setq 'lisp-indent-function '1) (autoload 'cl-locally "cl-macs" "\ - +Equivalent to `progn'. \(fn &rest BODY)" nil t) (autoload 'cl-the "cl-macs" "\ - +At present this ignores _TYPE and is simply equivalent to FORM. \(fn TYPE FORM)" nil t) @@ -721,7 +723,10 @@ and then returning foo. \(fn FUNC ARGS &rest BODY)" nil t) (autoload 'cl-compiler-macroexpand "cl-macs" "\ - +Like `macroexpand', but for compiler macros. +Expands FORM repeatedly until no further expansion is possible. +Returns FORM unchanged if it has no compiler macro, or if it has a +macro that returns its `&whole' argument. \(fn FORM)" nil nil) -- cgit v1.2.3 From 6b3770fb9dd180abbda32383eba5e961e76d7504 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 5 Nov 2012 20:36:44 -0500 Subject: * lisp/emacs-lisp/gv.el (gv-define-setter): Fix doc typo. --- lisp/ChangeLog | 4 ++++ lisp/emacs-lisp/gv.el | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 95c407fcdb7..9295f72a336 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2012-11-06 Glenn Morris + + * emacs-lisp/gv.el (gv-define-setter): Fix doc typo. + 2012-11-05 Glenn Morris * emacs-lisp/cl-extra.el (cl-prettyexpand): diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index d6c91539a90..3dd021f9e74 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -194,7 +194,7 @@ well for simple place forms. Assignments of VAL to (NAME ARGS...) are expanded by binding the argument forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must return a Lisp form that does the assignment. -The first arg in ARLIST (the one that receives VAL) receives an expression +The first arg in ARGLIST (the one that receives VAL) receives an expression which can do arbitrary things, whereas the other arguments are all guaranteed to be pure and copyable. Example use: (gv-define-setter aref (v a i) `(aset ,a ,i ,v))" -- cgit v1.2.3 From d57c286eea2c3bc69e8aeac6c4a1458625032a73 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 6 Nov 2012 22:14:27 -0500 Subject: * lisp/emacs-lisp/cl.el (defsetf): Pass the third arg to gv-define-simple-setter. Fixes: debbugs:12812 --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/cl.el | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e89af026c66..b88baaa2f0a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-07 Stefan Monnier + + * emacs-lisp/cl.el (defsetf): Pass the third arg to + gv-define-simple-setter (bug#12812). + 2012-11-06 Stefan Monnier * woman.el (woman-decode-region): Disable adaptive-fill when rendering diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index d3ef83961e2..52567f34278 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -597,7 +597,7 @@ Example: (cl-function (lambda (,@(car args) ,@arg1) ,@(cdr args))) do args))) - `(gv-define-simple-setter ,name ,arg1))) + `(gv-define-simple-setter ,name ,arg1 ,(car args)))) ;; FIXME: CL used to provide a setf method for `apply', but I haven't been able ;; to find a case where it worked. The code below tries to handle it as well. -- cgit v1.2.3 From b715ed4447b025d713fc68a7af3728c2d463974b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 6 Nov 2012 22:39:33 -0500 Subject: * lisp/emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val' twice when `fix-return' is set. Fixes: debbugs:12813 --- lisp/ChangeLog | 3 +++ lisp/emacs-lisp/gv.el | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b88baaa2f0a..187ff2d7e1d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-11-07 Stefan Monnier + * emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val' + twice when `fix-return' is set (bug#12813). + * emacs-lisp/cl.el (defsetf): Pass the third arg to gv-define-simple-setter (bug#12812). diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 3dd021f9e74..a0c412a9504 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -213,9 +213,11 @@ If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and instead the assignment is turned into (prog1 VAL (SETTER ARGS... VAL)) so as to preserve the semantics of `setf'." (declare (debug (sexp (&or symbolp lambda-expr) &optional sexp))) - (let ((set-call `(cons ',setter (append args (list val))))) `(gv-define-setter ,name (val &rest args) - ,(if fix-return `(list 'prog1 val ,set-call) set-call)))) + ,(if fix-return + `(macroexp-let2 nil v val + (cons ',setter (append args (list v)))) + `(cons ',setter (append args (list val)))))) ;;; Typical operations on generalized variables. -- cgit v1.2.3 From 2ee1d59f5bea4a206595d621dcb63477461b7155 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 6 Nov 2012 20:37:07 -0800 Subject: Small doc updates for generalized variables * lisp/emacs-lisp/gv.el (gv-letplace): Fix doc typo. (gv-define-simple-setter): Update doc of `fix-return'. * doc/lispref/variables.texi (Adding Generalized Variables): Update description of FIX-RETURN expansion. * doc/misc/cl.texi (Obsolete Setf Customization): Revert defsetf example to the more correct let rather than prog1. --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/variables.texi | 9 +++++++-- doc/misc/ChangeLog | 5 +++++ doc/misc/cl.texi | 10 +++++----- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/gv.el | 8 ++++++-- 6 files changed, 33 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index c588e81dd1f..6e7a0b7a648 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2012-11-07 Glenn Morris + + * variables.texi (Adding Generalized Variables): + Update description of FIX-RETURN expansion. + 2012-11-06 Glenn Morris * variables.texi (Setting Generalized Variables): diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index a7134af20bd..fb98b3cd035 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2089,8 +2089,13 @@ no problem with, e.g., @code{car} and @code{setcar}, because @code{setcar} returns the value that it set. If your @var{setter} function does not return @var{value}, use a non-@code{nil} value for the @var{fix-return} argument of @code{gv-define-simple-setter}. This -wraps the @code{setf} expansion in @code{(prog1 @var{value} @dots{})} -so that it returns the correct result. +expands into something equivalent to +@example +(let ((temp @var{value})) + (@var{setter} @var{args}@dots{} temp) + temp) +@end example +so ensuring that it returns the correct result. @end defmac diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index bd815e3df9f..49f86ef093b 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,8 @@ +2012-11-07 Glenn Morris + + * cl.texi (Obsolete Setf Customization): + Revert defsetf example to the more correct let rather than prog1. + 2012-11-06 Glenn Morris * cl.texi (Overview): Mention EIEIO here, as well as the appendix. diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index a5a696b6b16..e39186c1222 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -4950,9 +4950,8 @@ is completely irregular. @end defmac @defmac defsetf access-fn update-fn -This is the simpler of two @code{defsetf} forms, and is entirely -obsolete, being replaced by @code{gv-define-simple-setter} in Emacs -24.3. +This is the simpler of two @code{defsetf} forms, and is +replaced by @code{gv-define-simple-setter} in Emacs 24.3. @xref{Adding Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}. Where @var{access-fn} is the name of a function that accesses a place, @@ -4983,8 +4982,9 @@ not suitable, so that the above @code{setf} should be expanded to something more like @example -(prog1 @var{value} - (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} @var{value})) +(let ((temp @var{value})) + (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} temp) + temp) @end example Some examples are: diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 187ff2d7e1d..cfd79fc57ef 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-07 Glenn Morris + + * emacs-lisp/gv.el (gv-letplace): Fix doc typo. + (gv-define-simple-setter): Update doc of `fix-return'. + 2012-11-07 Stefan Monnier * emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val' diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index a0c412a9504..145c48c670e 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -111,7 +111,7 @@ DO must return an Elisp expression." GETTER will be bound to a copyable expression that returns the value of PLACE. SETTER will be bound to a function that takes an expression V and returns -and new expression that sets PLACE to V. +a new expression that sets PLACE to V. BODY should return some Elisp expression E manipulating PLACE via GETTER and SETTER. The returned value will then be an Elisp expression that first evaluates @@ -209,8 +209,12 @@ to be pure and copyable. Example use: This macro is an easy-to-use substitute for `gv-define-expander' that works well for simple place forms. Assignments of VAL to (NAME ARGS...) are turned into calls of the form (SETTER ARGS... VAL). + If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and -instead the assignment is turned into (prog1 VAL (SETTER ARGS... VAL)) +instead the assignment is turned into something equivalent to + \(let ((temp VAL)) + (SETTER ARGS... temp) + temp) so as to preserve the semantics of `setf'." (declare (debug (sexp (&or symbolp lambda-expr) &optional sexp))) `(gv-define-setter ,name (val &rest args) -- cgit v1.2.3 From 031b2ea7f5cefc53885d469c3c37ef68103d49aa Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 7 Nov 2012 00:56:16 -0800 Subject: More cl-lib and gv doc updates * lisp/emacs-lisp/cl.el (define-setf-expander, defsetf) (define-modify-macro): Doc fixes. * doc/misc/cl.texi (Obsolete Setf Customization): Give defsetf gv.el replacements. * etc/NEWS: Related edit. --- doc/misc/ChangeLog | 2 +- doc/misc/cl.texi | 29 ++++++++++++++++++---------- etc/NEWS | 4 ++-- lisp/ChangeLog | 3 +++ lisp/emacs-lisp/cl.el | 52 ++++++++++++++++++++++++++++++++------------------- 5 files changed, 58 insertions(+), 32 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 93a2971f8c6..6951f2df79d 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -2,7 +2,7 @@ * cl.texi (Obsolete Setf Customization): Revert defsetf example to the more correct let rather than prog1. - Give define-modify-macro gv.el replacement. + Give define-modify-macro and defsetf gv.el replacements. 2012-11-06 Glenn Morris diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 21750b79c93..d3c9ad6aedf 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -5019,14 +5019,16 @@ These translate directly to @code{gv-define-simple-setter}: @end defmac @defmac defsetf access-fn arglist (store-var) forms@dots{} -This is the second, more complex, form of @code{defsetf}. It is -rather like @code{defmacro} except for the additional @var{store-var} -argument. The @var{forms} should return a Lisp form that stores -the value of @var{store-var} into the generalized variable formed -by a call to @var{access-fn} with arguments described by @var{arglist}. -The @var{forms} may begin with a string which documents the @code{setf} -method (analogous to the doc string that appears at the front of a -function). +This is the second, more complex, form of @code{defsetf}. +It can be replaced by @code{gv-define-setter}. + +This form of @code{defsetf} is rather like @code{defmacro} except for +the additional @var{store-var} argument. The @var{forms} should +return a Lisp form that stores the value of @var{store-var} into the +generalized variable formed by a call to @var{access-fn} with +arguments described by @var{arglist}. The @var{forms} may begin with +a string which documents the @code{setf} method (analogous to the doc +string that appears at the front of a function). For example, the simple form of @code{defsetf} is shorthand for @@ -5041,11 +5043,18 @@ macros like @code{cl-incf} that invoke this setf-method will insert temporary variables as needed to make sure the apparent order of evaluation is preserved. -Another example drawn from the standard package: +Another standard example: @example (defsetf nth (n x) (store) - (list 'setcar (list 'nthcdr n x) store)) + `(setcar (nthcdr ,n ,x) ,store)) +@end example + +You could write this using @code{gv-define-setter} as: + +@example +(gv-define-setter nth (store n x) + `(setcar (nthcdr ,n ,x) ,store)) @end example @end defmac diff --git a/etc/NEWS b/etc/NEWS index 33ec17c1960..76126cf6dda 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -339,8 +339,8 @@ rather than making them unbound. *** The following methods of extending `setf' are obsolete (use features from gv.el instead): `define-modify-macro' (use `gv-letplace') -`defsetf' (use `gv-define-simple-setter', or FIXME) -`define-setf-expander' (use FIXME) +`defsetf' (use `gv-define-simple-setter' or `gv-define-setter') +`define-setf-expander' (use `gv-define-setter' or `gv-define-expander') ** Compilation mode +++ diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cfd79fc57ef..ff9684ad175 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-11-07 Glenn Morris + * emacs-lisp/cl.el (define-setf-expander, defsetf) + (define-modify-macro): Doc fixes. + * emacs-lisp/gv.el (gv-letplace): Fix doc typo. (gv-define-simple-setter): Update doc of `fix-return'. diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index 52567f34278..016967bc713 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -547,13 +547,15 @@ deprecated usage of `symbol-function' in place forms)." ; bug#12760 (defmacro define-setf-expander (name arglist &rest body) "Define a `setf' method. -This method shows how to handle `setf's to places of the form (NAME ARGS...). -The argument forms ARGS are bound according to ARGLIST, as if NAME were -going to be expanded as a macro, then the BODY forms are executed and must -return a list of five elements: a temporary-variables list, a value-forms -list, a store-variables list (of length one), a store-form, and an access- -form. See `gv-define-expander', `gv-define-setter', and `gv-define-expander' -for a better and simpler ways to define setf-methods." +This method shows how to handle `setf's to places of the form +\(NAME ARGS...). The argument forms ARGS are bound according to +ARGLIST, as if NAME were going to be expanded as a macro, then +the BODY forms are executed and must return a list of five elements: +a temporary-variables list, a value-forms list, a store-variables list +\(of length one), a store-form, and an access- form. + +See `gv-define-expander', and `gv-define-setter' for better and +simpler ways to define setf-methods." (declare (debug (&define name cl-lambda-list cl-declarations-or-string def-body))) `(progn @@ -566,23 +568,31 @@ for a better and simpler ways to define setf-methods." (defmacro defsetf (name arg1 &rest args) "Define a `setf' method. -This macro is an easy-to-use substitute for `define-setf-expander' that works -well for simple place forms. In the simple `defsetf' form, `setf's of -the form (setf (NAME ARGS...) VAL) are transformed to function or macro -calls of the form (FUNC ARGS... VAL). Example: +This macro is an easy-to-use substitute for `define-setf-expander' +that works well for simple place forms. + +In the simple `defsetf' form, `setf's of the form (setf (NAME +ARGS...) VAL) are transformed to function or macro calls of the +form (FUNC ARGS... VAL). For example: (defsetf aref aset) +You can replace this form with `gv-define-simple-setter'. + Alternate form: (defsetf NAME ARGLIST (STORE) BODY...). -Here, the above `setf' call is expanded by binding the argument forms ARGS -according to ARGLIST, binding the value form VAL to STORE, then executing -BODY, which must return a Lisp form that does the necessary `setf' operation. -Actually, ARGLIST and STORE may be bound to temporary variables which are -introduced automatically to preserve proper execution order of the arguments. -Example: + +Here, the above `setf' call is expanded by binding the argument +forms ARGS according to ARGLIST, binding the value form VAL to +STORE, then executing BODY, which must return a Lisp form that +does the necessary `setf' operation. Actually, ARGLIST and STORE +may be bound to temporary variables which are introduced +automatically to preserve proper execution order of the arguments. +For example: (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v)) +You can replace this form with `gv-define-setter'. + \(fn NAME [FUNC | ARGLIST (STORE) BODY...])" (declare (debug (&define name @@ -639,8 +649,12 @@ Example: (defmacro define-modify-macro (name arglist func &optional doc) "Define a `setf'-like modify macro. -If NAME is called, it combines its PLACE argument with the other arguments -from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" +If NAME is called, it combines its PLACE argument with the other +arguments from ARGLIST using FUNC. For example: + + (define-modify-macro incf (&optional (n 1)) +) + +You can replace this macro with `gv-letplace'." (declare (debug (&define name cl-lambda-list ;; should exclude &key symbolp &optional stringp))) -- cgit v1.2.3 From 41626722272734aa3a7e4fdfafd3b085133db665 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 7 Nov 2012 20:24:14 -0500 Subject: * lisp/emacs-lisp/gv.el (gv-define-simple-setter): Fix last change. Fixes: debbugs:12812 --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/gv.el | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 98e47dd83d9..6a574f4b26d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-08 Stefan Monnier + + * emacs-lisp/gv.el (gv-define-simple-setter): Fix last change + (bug#12812). + 2012-11-07 Chong Yidong * minibuf-eldef.el (minibuffer-eldef-shorten-default): Convert to diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 145c48c670e..38bb6319a03 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -220,7 +220,8 @@ so as to preserve the semantics of `setf'." `(gv-define-setter ,name (val &rest args) ,(if fix-return `(macroexp-let2 nil v val - (cons ',setter (append args (list v)))) + (cons ',setter (append args (list v))) + v) `(cons ',setter (append args (list val)))))) ;;; Typical operations on generalized variables. -- cgit v1.2.3 From 32170f7ff2f85378cbafd68ea562fc0da7909941 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 8 Nov 2012 09:36:47 -0500 Subject: * lisp/emacs-lisp/advice.el: Require `cl-lib' at run-time to fix miscompilation of trace.el. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/advice.el | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b141afe67e6..b17f3d9a59e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-08 Stefan Monnier + + * emacs-lisp/advice.el: Require `cl-lib' at run-time to fix + miscompilation of trace.el. + 2012-11-08 Glenn Morris * vc/diff-mode.el (diff-remove-trailing-whitespace): Doc fix. diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index bd85238e23e..e358c756712 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el @@ -1709,7 +1709,8 @@ ;; During a normal load this is a noop: (require 'advice-preload "advice.el") (require 'macroexp) -(eval-when-compile (require 'cl-lib)) +;; At run-time also, since ad-do-advised-functions returns code that uses it. +(require 'cl-lib) ;; @@ Variable definitions: ;; ======================== -- cgit v1.2.3