diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl.el | 52 |
2 files changed, 36 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cfd79fc57ef..ff9684ad175 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2012-11-07 Glenn Morris <rgm@gnu.org> | 1 | 2012-11-07 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * emacs-lisp/cl.el (define-setf-expander, defsetf) | ||
| 4 | (define-modify-macro): Doc fixes. | ||
| 5 | |||
| 3 | * emacs-lisp/gv.el (gv-letplace): Fix doc typo. | 6 | * emacs-lisp/gv.el (gv-letplace): Fix doc typo. |
| 4 | (gv-define-simple-setter): Update doc of `fix-return'. | 7 | (gv-define-simple-setter): Update doc of `fix-return'. |
| 5 | 8 | ||
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 | |||
| 547 | 547 | ||
| 548 | (defmacro define-setf-expander (name arglist &rest body) | 548 | (defmacro define-setf-expander (name arglist &rest body) |
| 549 | "Define a `setf' method. | 549 | "Define a `setf' method. |
| 550 | This method shows how to handle `setf's to places of the form (NAME ARGS...). | 550 | This method shows how to handle `setf's to places of the form |
| 551 | The argument forms ARGS are bound according to ARGLIST, as if NAME were | 551 | \(NAME ARGS...). The argument forms ARGS are bound according to |
| 552 | going to be expanded as a macro, then the BODY forms are executed and must | 552 | ARGLIST, as if NAME were going to be expanded as a macro, then |
| 553 | return a list of five elements: a temporary-variables list, a value-forms | 553 | the BODY forms are executed and must return a list of five elements: |
| 554 | list, a store-variables list (of length one), a store-form, and an access- | 554 | a temporary-variables list, a value-forms list, a store-variables list |
| 555 | form. See `gv-define-expander', `gv-define-setter', and `gv-define-expander' | 555 | \(of length one), a store-form, and an access- form. |
| 556 | for a better and simpler ways to define setf-methods." | 556 | |
| 557 | See `gv-define-expander', and `gv-define-setter' for better and | ||
| 558 | simpler ways to define setf-methods." | ||
| 557 | (declare (debug | 559 | (declare (debug |
| 558 | (&define name cl-lambda-list cl-declarations-or-string def-body))) | 560 | (&define name cl-lambda-list cl-declarations-or-string def-body))) |
| 559 | `(progn | 561 | `(progn |
| @@ -566,23 +568,31 @@ for a better and simpler ways to define setf-methods." | |||
| 566 | 568 | ||
| 567 | (defmacro defsetf (name arg1 &rest args) | 569 | (defmacro defsetf (name arg1 &rest args) |
| 568 | "Define a `setf' method. | 570 | "Define a `setf' method. |
| 569 | This macro is an easy-to-use substitute for `define-setf-expander' that works | 571 | This macro is an easy-to-use substitute for `define-setf-expander' |
| 570 | well for simple place forms. In the simple `defsetf' form, `setf's of | 572 | that works well for simple place forms. |
| 571 | the form (setf (NAME ARGS...) VAL) are transformed to function or macro | 573 | |
| 572 | calls of the form (FUNC ARGS... VAL). Example: | 574 | In the simple `defsetf' form, `setf's of the form (setf (NAME |
| 575 | ARGS...) VAL) are transformed to function or macro calls of the | ||
| 576 | form (FUNC ARGS... VAL). For example: | ||
| 573 | 577 | ||
| 574 | (defsetf aref aset) | 578 | (defsetf aref aset) |
| 575 | 579 | ||
| 580 | You can replace this form with `gv-define-simple-setter'. | ||
| 581 | |||
| 576 | Alternate form: (defsetf NAME ARGLIST (STORE) BODY...). | 582 | Alternate form: (defsetf NAME ARGLIST (STORE) BODY...). |
| 577 | Here, the above `setf' call is expanded by binding the argument forms ARGS | 583 | |
| 578 | according to ARGLIST, binding the value form VAL to STORE, then executing | 584 | Here, the above `setf' call is expanded by binding the argument |
| 579 | BODY, which must return a Lisp form that does the necessary `setf' operation. | 585 | forms ARGS according to ARGLIST, binding the value form VAL to |
| 580 | Actually, ARGLIST and STORE may be bound to temporary variables which are | 586 | STORE, then executing BODY, which must return a Lisp form that |
| 581 | introduced automatically to preserve proper execution order of the arguments. | 587 | does the necessary `setf' operation. Actually, ARGLIST and STORE |
| 582 | Example: | 588 | may be bound to temporary variables which are introduced |
| 589 | automatically to preserve proper execution order of the arguments. | ||
| 590 | For example: | ||
| 583 | 591 | ||
| 584 | (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v)) | 592 | (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v)) |
| 585 | 593 | ||
| 594 | You can replace this form with `gv-define-setter'. | ||
| 595 | |||
| 586 | \(fn NAME [FUNC | ARGLIST (STORE) BODY...])" | 596 | \(fn NAME [FUNC | ARGLIST (STORE) BODY...])" |
| 587 | (declare (debug | 597 | (declare (debug |
| 588 | (&define name | 598 | (&define name |
| @@ -639,8 +649,12 @@ Example: | |||
| 639 | 649 | ||
| 640 | (defmacro define-modify-macro (name arglist func &optional doc) | 650 | (defmacro define-modify-macro (name arglist func &optional doc) |
| 641 | "Define a `setf'-like modify macro. | 651 | "Define a `setf'-like modify macro. |
| 642 | If NAME is called, it combines its PLACE argument with the other arguments | 652 | If NAME is called, it combines its PLACE argument with the other |
| 643 | from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" | 653 | arguments from ARGLIST using FUNC. For example: |
| 654 | |||
| 655 | (define-modify-macro incf (&optional (n 1)) +) | ||
| 656 | |||
| 657 | You can replace this macro with `gv-letplace'." | ||
| 644 | (declare (debug | 658 | (declare (debug |
| 645 | (&define name cl-lambda-list ;; should exclude &key | 659 | (&define name cl-lambda-list ;; should exclude &key |
| 646 | symbolp &optional stringp))) | 660 | symbolp &optional stringp))) |