aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann <[email protected]>1999-11-16 13:29:51 +0000
committerGerd Moellmann <[email protected]>1999-11-16 13:29:51 +0000
commitd01a33cf8d8855f935b5e93145ab8e5cfb99f598 (patch)
tree36eaf980db91ebfd0413baea93dad2e5696631cd
parent0a936fe0eea70582d4e48333ff684eaa2dda5601 (diff)
(with-syntax-table): New.
-rw-r--r--lisp/simple.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index b65e8b2ff9..279a76ad71 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -27,6 +27,10 @@
;;; Code:
+(eval-when-compile
+ (require 'cl))
+
+
(defgroup killing nil
"Killing and yanking commands"
:group 'editing)
@@ -4132,4 +4136,21 @@ after it has been set up properly in other respects."
(if display-flag (pop-to-buffer new))
new))
+
+(defmacro with-syntax-table (table &rest body)
+ "Evaluate BODY with syntax table of current buffer set to a copy of TABLE.
+Point, mark, current buffer, and syntax table are saved, BODY is
+evaluated, and the saved values are restored, even in case of an
+abnormal exit. Value is what BODY returns."
+ (let ((old-table (gensym)))
+ '(let ((,old-table (syntax-table)))
+ (unwind-protect
+ (save-excursion
+ (set-syntax-table (copy-syntax-table ,table))
+ ,@body)
+ (set-syntax-table ,old-table)))))
+
+(put 'with-syntax-table 'lisp-indent-function 1)
+(put 'with-syntax-table 'edebug-form-spec '(form body))
+
;;; simple.el ends here