diff options
| author | Richard M. Stallman | 1994-04-12 17:45:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-12 17:45:53 +0000 |
| commit | cd320f323ec8c2b7a32476ed44a95ef4053a02b6 (patch) | |
| tree | 924d7a3f607574d1862b1949cc3285cb40ec609e /lisp | |
| parent | c2a2858aecca5b9586876b6276516cc5523eaad5 (diff) | |
| download | emacs-cd320f323ec8c2b7a32476ed44a95ef4053a02b6.tar.gz emacs-cd320f323ec8c2b7a32476ed44a95ef4053a02b6.zip | |
(backquote-process): Don't crash if ultimate
expression is just a variable.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/backquote.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/backquote.el b/lisp/emacs-lisp/backquote.el index 777cbbf8f9a..d67e2bef6f4 100644 --- a/lisp/emacs-lisp/backquote.el +++ b/lisp/emacs-lisp/backquote.el | |||
| @@ -141,8 +141,18 @@ Vectors work just like lists. Nested backquotes are permitted." | |||
| 141 | ((eq (car s) backquote-backquote-symbol) | 141 | ((eq (car s) backquote-backquote-symbol) |
| 142 | (backquote-process (cdr (backquote-process (nth 1 s))))) | 142 | (backquote-process (cdr (backquote-process (nth 1 s))))) |
| 143 | (t | 143 | (t |
| 144 | (let ((rest s) (item nil) (firstlist nil) (list nil) (lists nil)) | 144 | (let ((rest s) |
| 145 | item firstlist list lists expression) | ||
| 146 | ;; Scan this list-level, setting LISTS to a list of forms, | ||
| 147 | ;; each of which produces a list of elements | ||
| 148 | ;; that should go in this level. | ||
| 149 | ;; The order of LISTS is backwards. | ||
| 150 | ;; If there are non-splicing elements (constant or variable) | ||
| 151 | ;; at the beginning, put them in FIRSTLIST, | ||
| 152 | ;; as a list of tagged values (TAG . FORM). | ||
| 153 | ;; If there are any at the end, they go in LIST, likewise. | ||
| 145 | (while (consp rest) | 154 | (while (consp rest) |
| 155 | ;; Turn . (, foo) into (,@ foo). | ||
| 146 | (if (eq (car rest) backquote-unquote-symbol) | 156 | (if (eq (car rest) backquote-unquote-symbol) |
| 147 | (setq rest (list (list backquote-splice-symbol (nth 1 rest))))) | 157 | (setq rest (list (list backquote-splice-symbol (nth 1 rest))))) |
| 148 | (setq item (backquote-process (car rest))) | 158 | (setq item (backquote-process (car rest))) |
| @@ -158,20 +168,23 @@ Vectors work just like lists. Nested backquotes are permitted." | |||
| 158 | (t | 168 | (t |
| 159 | (setq list (cons item list)))) | 169 | (setq list (cons item list)))) |
| 160 | (setq rest (cdr rest))) | 170 | (setq rest (cdr rest))) |
| 171 | ;; Handle nonsplicing final elements, and the tail of the list | ||
| 172 | ;; (which remains in REST). | ||
| 161 | (if (or rest list) | 173 | (if (or rest list) |
| 162 | (setq lists (cons (backquote-listify list (backquote-process rest)) | 174 | (setq lists (cons (backquote-listify list (backquote-process rest)) |
| 163 | lists))) | 175 | lists))) |
| 164 | (setq lists | 176 | ;; Turn LISTS into a form that produces the combined list. |
| 177 | (setq expression | ||
| 165 | (if (or (cdr lists) | 178 | (if (or (cdr lists) |
| 166 | (and (consp (car lists)) | 179 | (eq (car-safe (car lists)) backquote-splice-symbol)) |
| 167 | (eq (car (car lists)) backquote-splice-symbol))) | ||
| 168 | (cons 'append (nreverse lists)) | 180 | (cons 'append (nreverse lists)) |
| 169 | (car lists))) | 181 | (car lists))) |
| 182 | ;; Tack on any initial elements. | ||
| 170 | (if firstlist | 183 | (if firstlist |
| 171 | (setq lists (backquote-listify firstlist (cons 1 lists)))) | 184 | (setq expression (backquote-listify firstlist (cons 1 expression)))) |
| 172 | (if (eq (car lists) 'quote) | 185 | (if (eq (car-safe expression) 'quote) |
| 173 | (cons 0 (list 'quote s)) | 186 | (cons 0 (list 'quote s)) |
| 174 | (cons 1 lists)))))) | 187 | (cons 1 expression)))))) |
| 175 | 188 | ||
| 176 | ;; backquote-listify takes (tag . structure) pairs from backquote-process | 189 | ;; backquote-listify takes (tag . structure) pairs from backquote-process |
| 177 | ;; and decides between append, list, backquote-list*, and cons depending | 190 | ;; and decides between append, list, backquote-list*, and cons depending |