Mercurial > emacs
comparison lisp/simple.el @ 26476:46323650988d
(with-syntax-table): Save buffer explicitly instead of
using save-excursion.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 17 Nov 1999 21:09:57 +0000 |
parents | b32572666174 |
children | 0044d20f41ae |
comparison
equal
deleted
inserted
replaced
26475:7bd41cca7ed8 | 26476:46323650988d |
---|---|
4137 new)) | 4137 new)) |
4138 | 4138 |
4139 | 4139 |
4140 (defmacro with-syntax-table (table &rest body) | 4140 (defmacro with-syntax-table (table &rest body) |
4141 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. | 4141 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. |
4142 Point, mark, current buffer, and syntax table are saved, BODY is | 4142 Current buffer and syntax table are saved, BODY is evaluated, and the |
4143 evaluated, and the saved values are restored, even in case of an | 4143 saved values are restored, even in case of an abnormal exit. |
4144 abnormal exit. Value is what BODY returns." | 4144 Value is what BODY returns." |
4145 (let ((old-table (gensym))) | 4145 (let ((old-table (gensym)) |
4146 '(let ((,old-table (syntax-table))) | 4146 (old-buffer (gensym))) |
4147 '(let ((,old-table (syntax-table)) | |
4148 (,old-buffer (current-buffer))) | |
4147 (unwind-protect | 4149 (unwind-protect |
4148 (save-excursion | 4150 (progn |
4149 (set-syntax-table (copy-syntax-table ,table)) | 4151 (set-syntax-table (copy-syntax-table ,table)) |
4150 ,@body) | 4152 ,@body) |
4151 (set-syntax-table ,old-table))))) | 4153 (set-buffer ,old-buffer) |
4154 (set-syntax-table ,old-table))))) | |
4152 | 4155 |
4153 (put 'with-syntax-table 'lisp-indent-function 1) | 4156 (put 'with-syntax-table 'lisp-indent-function 1) |
4154 (put 'with-syntax-table 'edebug-form-spec '(form body)) | 4157 (put 'with-syntax-table 'edebug-form-spec '(form body)) |
4155 | 4158 |
4156 ;;; simple.el ends here | 4159 ;;; simple.el ends here |