bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19790: [PATCH] destructive splicing in backquote


From: Robin Templeton
Subject: bug#19790: [PATCH] destructive splicing in backquote
Date: Fri, 06 Feb 2015 01:39:02 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Common Lisp and MACLISP define comma-dot syntax for destructive splicing
in backquote expressions. The Elisp reader reads ",.x" as "(\,\. x)"
(like ",@"), but the resulting forms are not processed by the backquote
library. A patch follows that adds CL-compatible comma-dot support.

Originally reported by at Artur Malabarba in
<http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00624.html>.

-- >8 --
Subject: [PATCH] destructive splicing in backquote

Allow Common Lisp-compatible destructive splicing in backquote
expressions using ",." syntax.

* lisp/emacs-lisp/backquote.el (backquote-destructive-splice-symbol):
  New variable.
  (backquote-process): Allow backquote-destructive-splice-symbol as a
  synonym for backquote-splice-symbol.
---
 lisp/ChangeLog               | 7 +++++++
 lisp/emacs-lisp/backquote.el | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c18a8ff..fd643ed 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-06  Robin Templeton  <robin@terpri.org>
+
+       * emacs-lisp/backquote.el (backquote-destructive-splice-symbol):
+       New variable.
+       (backquote-process): Allow backquote-destructive-splice-symbol as
+       a synonym for backquote-splice-symbol.
+
 2015-02-03  Artur Malabarba  <bruce.connor.am@gmail.com>
 
        * emacs-lisp/package.el (package-delete): Document NOSAVE.
diff --git a/lisp/emacs-lisp/backquote.el b/lisp/emacs-lisp/backquote.el
index d5cdca2..b6e1792 100644
--- a/lisp/emacs-lisp/backquote.el
+++ b/lisp/emacs-lisp/backquote.el
@@ -90,6 +90,9 @@ For example (backquote-list* 'a 'b 'c) => (a b . c)"
 (defconst backquote-splice-symbol '\,@
   "Symbol used to represent a splice inside a backquote.")
 
+(defconst backquote-destructive-splice-symbol '\,.
+  "Symbol used to represent a destructive splice inside a backquote.")
+
 (defmacro backquote (structure)
   "Argument STRUCTURE describes a template to build.
 
@@ -160,7 +163,8 @@ LEVEL is only used internally and indicates the nesting 
level:
          (t (cons (if (eq (car-safe (nth 1 s)) 'quote) 0 1)
                   (nth 1 s))))
       (backquote-delay-process s (1- level))))
-   ((eq (car s) backquote-splice-symbol)
+   ((or (eq (car s) backquote-splice-symbol)
+        (eq (car s) backquote-destructive-splice-symbol))
     (if (<= level 0)
         (if (> (length s) 2)
             ;; (cons 2 `(append . ,(cdr s)))
-- 
2.1.4







reply via email to

[Prev in Thread] Current Thread [Next in Thread]