diff lisp/subr.el @ 4408:8bbabcab2c42

Merge.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 20 Jan 2008 13:09:58 +0100
parents ef9eb714f0e4
children 42fad34efb3f
line wrap: on
line diff
--- a/lisp/subr.el	Wed Dec 26 17:30:16 2007 +0100
+++ b/lisp/subr.el	Sun Jan 20 13:09:58 2008 +0100
@@ -579,6 +579,19 @@
 ; 	 . ,body)
 ;      (combine-after-change-execute)))
 
+(defmacro with-case-table (table &rest body)
+  "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 (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))))))
 
 (defvar delay-mode-hooks nil
   "If non-nil, `run-mode-hooks' should delay running the hooks.")