diff options
| author | Richard M. Stallman | 1999-08-29 20:23:54 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-08-29 20:23:54 +0000 |
| commit | d270117a18a28a1bebdb687fd794b5cc89f1559d (patch) | |
| tree | 3ce9f2dfa1196dd03b3f5d7c5c78ff4cdc0ae8eb | |
| parent | e3c0f9ded6f68f9fded9904afaca2e7d6e5bc75a (diff) | |
| download | emacs-d270117a18a28a1bebdb687fd794b5cc89f1559d.tar.gz emacs-d270117a18a28a1bebdb687fd794b5cc89f1559d.zip | |
(push, pop): New macros.
| -rw-r--r-- | lisp/subr.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index f4f695e8108..a80383467d3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -51,6 +51,21 @@ BODY should be a list of lisp expressions." | |||
| 51 | ;; depend on backquote.el. | 51 | ;; depend on backquote.el. |
| 52 | (list 'function (cons 'lambda cdr))) | 52 | (list 'function (cons 'lambda cdr))) |
| 53 | 53 | ||
| 54 | (defmacro push (value listname) | ||
| 55 | "Add VALUE to the list which is the value of LISTNAME. | ||
| 56 | This is equivalent to (setq LISTNAME (cons VALUE LISTNAME)). | ||
| 57 | LISTNAME must be a symbol." | ||
| 58 | (list 'setq list | ||
| 59 | (list 'cons value list))) | ||
| 60 | |||
| 61 | (defmacro pop (listname) | ||
| 62 | "Return the first element of LISTNAME's value, and remove it from the list. | ||
| 63 | LISTNAME must be a symbol whose value is a list. | ||
| 64 | If the value is nil, `pop' returns nil but does not actually | ||
| 65 | change the list." | ||
| 66 | (list 'prog1 (list 'car listname) | ||
| 67 | (list 'setq listname (list 'cdr listname)))) | ||
| 68 | |||
| 54 | (defmacro when (cond &rest body) | 69 | (defmacro when (cond &rest body) |
| 55 | "(when COND BODY...): if COND yields non-nil, do BODY, else return nil." | 70 | "(when COND BODY...): if COND yields non-nil, do BODY, else return nil." |
| 56 | (list 'if cond (cons 'progn body))) | 71 | (list 'if cond (cons 'progn body))) |