[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r110801: * cl.texi (Obsolete Setf
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r110801: * cl.texi (Obsolete Setf Customization): Give define-modify-macro replacement. |
Date: |
Wed, 07 Nov 2012 00:28:34 -0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 110801
committer: Glenn Morris <address@hidden>
branch nick: emacs-24
timestamp: Wed 2012-11-07 00:28:34 -0800
message:
* cl.texi (Obsolete Setf Customization): Give define-modify-macro replacement.
modified:
doc/misc/ChangeLog
doc/misc/cl.texi
=== modified file 'doc/misc/ChangeLog'
--- a/doc/misc/ChangeLog 2012-11-07 04:37:07 +0000
+++ b/doc/misc/ChangeLog 2012-11-07 08:28:34 +0000
@@ -2,6 +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.
2012-11-06 Glenn Morris <address@hidden>
=== modified file 'doc/misc/cl.texi'
--- a/doc/misc/cl.texi 2012-11-07 04:37:07 +0000
+++ b/doc/misc/cl.texi 2012-11-07 08:28:34 +0000
@@ -4905,15 +4905,17 @@
@code{defsetf}, and @code{define-setf-method}, that allow the
user to extend generalized variables in various ways.
In Emacs, these are obsolete, replaced by various features of
address@hidden in Emacs 24.3. Many of the implementation
-details in the following are out-of-date.
address@hidden FIXME this whole section needs updating.
address@hidden in Emacs 24.3.
address@hidden Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+
@defmac define-modify-macro name arglist function [doc-string]
This macro defines a ``read-modify-write'' macro similar to
address@hidden and @code{cl-decf}. The macro @var{name} is defined
-to take a @var{place} argument followed by additional arguments
-described by @var{arglist}. The call
address@hidden and @code{cl-decf}. You can replace this macro
+with @code{gv-letplace}.
+
+The macro @var{name} is defined to take a @var{place} argument
+followed by additional arguments described by @var{arglist}. The call
@example
(@var{name} @var{place} @address@hidden)
@@ -4936,8 +4938,8 @@
For example:
@example
-(define-modify-macro cl-incf (&optional (n 1)) +)
-(define-modify-macro cl-concatf (&rest args) concat)
+(define-modify-macro incf (&optional (n 1)) +)
+(define-modify-macro concatf (&rest args) concat)
@end example
Note that @code{&key} is not allowed in @var{arglist}, but
@@ -4947,14 +4949,28 @@
follow the pattern of @code{define-modify-macro}. For example,
@code{push} takes its arguments in the wrong order, and @code{pop}
is completely irregular.
+
+The above @code{incf} example could be written using
address@hidden as:
address@hidden
+(defmacro incf (place &optional n)
+ (gv-letplace (getter setter) place
+ (macroexp-let2 nil v (or n 1)
+ (funcall setter `(+ ,v ,getter)))))
address@hidden example
address@hidden
+(defmacro concatf (place &rest args)
+ (gv-letplace (getter setter) place
+ (macroexp-let2 nil v (mapconcat 'identity args "")
+ (funcall setter `(concat ,getter ,v)))))
address@hidden ignore
@end defmac
@defmac defsetf access-fn update-fn
This is the simpler of two @code{defsetf} forms, and is
-replaced by @code{gv-define-simple-setter} in Emacs 24.3.
address@hidden Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+replaced by @code{gv-define-simple-setter}.
-Where @var{access-fn} is the name of a function that accesses a place,
+With @var{access-fn} the name of a function that accesses a place,
this declares @var{update-fn} to be the corresponding store function.
From now on,
@@ -4993,6 +5009,13 @@
(defsetf car setcar)
(defsetf buffer-name rename-buffer t)
@end example
+
+These translate directly to @code{gv-define-simple-setter}:
+
address@hidden
+(gv-define-simple-setter car setcar)
+(gv-define-simple-setter buffer-name rename-buffer t)
address@hidden example
@end defmac
@defmac defsetf access-fn arglist (store-var) address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-24 r110801: * cl.texi (Obsolete Setf Customization): Give define-modify-macro replacement.,
Glenn Morris <=