# HG changeset patch # User Richard M. Stallman # Date 766172753 0 # Node ID 922626d0570d5702d5583061d41c8a1651ba19d7 # Parent 6a77fcbb5d44228fe2f6609967323295a547b9a3 (backquote-process): Don't crash if ultimate expression is just a variable. diff -r 6a77fcbb5d44 -r 922626d0570d lisp/emacs-lisp/backquote.el --- a/lisp/emacs-lisp/backquote.el Tue Apr 12 16:37:03 1994 +0000 +++ b/lisp/emacs-lisp/backquote.el Tue Apr 12 17:45:53 1994 +0000 @@ -141,8 +141,18 @@ ((eq (car s) backquote-backquote-symbol) (backquote-process (cdr (backquote-process (nth 1 s))))) (t - (let ((rest s) (item nil) (firstlist nil) (list nil) (lists nil)) + (let ((rest s) + item firstlist list lists expression) + ;; Scan this list-level, setting LISTS to a list of forms, + ;; each of which produces a list of elements + ;; that should go in this level. + ;; The order of LISTS is backwards. + ;; If there are non-splicing elements (constant or variable) + ;; at the beginning, put them in FIRSTLIST, + ;; as a list of tagged values (TAG . FORM). + ;; If there are any at the end, they go in LIST, likewise. (while (consp rest) + ;; Turn . (, foo) into (,@ foo). (if (eq (car rest) backquote-unquote-symbol) (setq rest (list (list backquote-splice-symbol (nth 1 rest))))) (setq item (backquote-process (car rest))) @@ -158,20 +168,23 @@ (t (setq list (cons item list)))) (setq rest (cdr rest))) + ;; Handle nonsplicing final elements, and the tail of the list + ;; (which remains in REST). (if (or rest list) (setq lists (cons (backquote-listify list (backquote-process rest)) lists))) - (setq lists + ;; Turn LISTS into a form that produces the combined list. + (setq expression (if (or (cdr lists) - (and (consp (car lists)) - (eq (car (car lists)) backquote-splice-symbol))) + (eq (car-safe (car lists)) backquote-splice-symbol)) (cons 'append (nreverse lists)) (car lists))) + ;; Tack on any initial elements. (if firstlist - (setq lists (backquote-listify firstlist (cons 1 lists)))) - (if (eq (car lists) 'quote) + (setq expression (backquote-listify firstlist (cons 1 expression)))) + (if (eq (car-safe expression) 'quote) (cons 0 (list 'quote s)) - (cons 1 lists)))))) + (cons 1 expression)))))) ;; backquote-listify takes (tag . structure) pairs from backquote-process ;; and decides between append, list, backquote-list*, and cons depending