changeset 76960:85841d693997

(with-case-table): Use `make-symbol' to avoid variable capture. Restore the table in the same buffer.
author John Paul Wallington <jpw@pobox.com>
date Fri, 06 Apr 2007 12:15:04 +0000
parents 9863cec1b6ca
children 43ce98afcc71
files lisp/subr.el
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Fri Apr 06 00:07:14 2007 +0000
+++ b/lisp/subr.el	Fri Apr 06 12:15:04 2007 +0000
@@ -2485,11 +2485,15 @@
   "Execute the forms in BODY with TABLE as the current case table.
 The value returned is the value of the last form in BODY."
   (declare (indent 1) (debug t))
-  `(let ((old-case-table (current-case-table)))
-     (unwind-protect
-	 (progn (set-case-table ,table)
-		,@body)
-       (set-case-table old-case-table))))
+  (let ((old-case-table (make-symbol "table"))
+	(old-buffer (make-symbol "buffer")))
+    `(let ((,old-case-table (current-case-table))
+	   (,old-buffer (current-buffer)))
+       (unwind-protect
+	   (progn (set-case-table ,table)
+		  ,@body)
+	 (with-current-buffer ,old-buffer
+	   (set-case-table ,old-case-table))))))
 
 ;;;; Constructing completion tables.