emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 06cfa27e372 1/2: Merge remote-tracking branch 'origin/ma


From: Po Lu
Subject: feature/android 06cfa27e372 1/2: Merge remote-tracking branch 'origin/master' into feature/android
Date: Tue, 7 Mar 2023 21:35:07 -0500 (EST)

branch: feature/android
commit 06cfa27e372be135646ed736ff48d9ad199c955c
Merge: abe279cb173 4e8b50ec57b
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge remote-tracking branch 'origin/master' into feature/android
---
 doc/lispref/lists.texi      |  1 +
 lisp/emacs-lisp/bytecomp.el |  9 +--------
 lisp/subr.el                |  9 ++++++---
 test/lisp/subr-tests.el     | 26 ++++++++++++++++++++++++++
 4 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 911defbc211..3478049c84f 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -719,6 +719,7 @@ Normally, when @var{tree} is anything other than a cons 
cell,
 non-@code{nil}, it copies vectors and records too (and operates
 recursively on their elements).  This function handles circular lists
 and vectors, and is thus slower than @code{copy-tree} for typical cases.
+@end defun
 
 @defun flatten-tree tree
 This function returns a ``flattened'' copy of @var{tree}, that is,
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 243d4b11b5f..12850c27b88 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2294,19 +2294,12 @@ With argument ARG, insert value in current buffer after 
the form."
            (symbols-with-pos-enabled t)
           (value (eval
                   (displaying-byte-compile-warnings
-;;;; NEW STOUGH, 2023-03-05
-                    (byte-run-strip-symbol-positions
-;;;; END OF NEW STOUGH
                    (byte-compile-sexp
                      (let ((form (read-positioning-symbols (current-buffer))))
                        (push form byte-compile-form-stack)
                        (eval-sexp-add-defvars
                         form
-                        start-read-position)))
-;;;; NEW STOUGH, 2023-03-05
-                    )
-;;;; END OF NEW STOUGH
-                                              )
+                        start-read-position))))
                    lexical-binding)))
       (cond (arg
             (message "Compiling from buffer... done.")
diff --git a/lisp/subr.el b/lisp/subr.el
index c3d315843bd..cf6aa6452fe 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -848,8 +848,8 @@ argument VECP, this copies vectors as well as conses."
 
 (defvar safe-copy-tree--seen nil
   "A hash table for conses/vectors/records already seen by safe-copy-tree-1.
-It's key is a cons or vector/record seen by the algorithm, and its value is
-the corresponding cons/vector/record in the copy.")
+Its key is a cons or vector/record seen by the algorithm, and its
+value is the corresponding cons/vector/record in the copy.")
 
 (defun safe-copy-tree--1 (tree &optional vecp)
   "Make a copy of TREE, taking circular structure into account.
@@ -896,7 +896,10 @@ If TREE is a cons cell, this recursively copies both its 
car and its cdr.
 Contrast to `copy-sequence', which copies only along the cdrs.  With second
 argument VECP, this copies vectors and records as well as conses."
   (setq safe-copy-tree--seen (make-hash-table :test #'eq))
-  (safe-copy-tree--1 tree vecp))
+  (unwind-protect
+      (safe-copy-tree--1 tree vecp)
+    (clrhash safe-copy-tree--seen)
+    (setq safe-copy-tree--seen nil)))
 
 
 ;;;; Various list-search functions.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 050ee22ac18..37fe09c1716 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1205,5 +1205,31 @@ final or penultimate step during initialization."))
     (should (equal a-dedup '("a" "b" "a" "b" "c")))
     (should (eq a a-dedup))))
 
+(ert-deftest subr--safe-copy-tree ()
+  (should (null (safe-copy-tree nil)))
+  (let* ((foo '(1 2 (3 4))) (bar (safe-copy-tree foo)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should-not (eq (caddr bar) (caddr foo))))
+  (let* ((foo '#1=(a #1#)) (bar (safe-copy-tree foo)))
+    (should (eq (car bar) (car foo)))
+;    (should-not (proper-list-p bar))
+    (should (eq (caadr bar) (caadr foo)))
+    (should (eq (caadr bar) 'a)))
+  (let* ((foo [1 2 3 4]) (bar (safe-copy-tree foo)))
+    (should (eq bar foo)))
+  (let* ((foo [1 (2 3) 4]) (bar (safe-copy-tree foo t)))
+    (should-not (eq bar foo))
+    (should (equal bar foo))
+    (should-not (eq (aref bar 1) (aref foo 1))))
+  (let* ((foo [1 [2 3] 4]) (bar (safe-copy-tree foo t)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should-not (eq (aref bar 1) (aref foo 1))))
+  (let* ((foo (record 'foo 1 "two" 3)) (bar (safe-copy-tree foo t)))
+    (should (equal bar foo))
+    (should-not (eq bar foo))
+    (should (eq (aref bar 2) (aref foo 2)))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here



reply via email to

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