changeset 101756:5f840f1a34d4

(vhdl-prepare-search-1, vhdl-prepare-search-2): Properly cleanup on `quit'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 02 Feb 2009 20:49:41 +0000
parents b6273f409a73
children 6d71fc980cde
files lisp/ChangeLog lisp/progmodes/vhdl-mode.el
diffstat 2 files changed, 18 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Feb 02 20:40:18 2009 +0000
+++ b/lisp/ChangeLog	Mon Feb 02 20:49:41 2009 +0000
@@ -1,5 +1,8 @@
 2009-02-02  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* progmodes/vhdl-mode.el (vhdl-prepare-search-1)
+	(vhdl-prepare-search-2): Properly cleanup on `quit'.
+
 	* progmodes/vhdl-mode.el (vhdl-mode-abbrev-table-init):
 	Mark the entries as being "system" entries rather than "user" entries.
 
--- a/lisp/progmodes/vhdl-mode.el	Mon Feb 02 20:40:18 2009 +0000
+++ b/lisp/progmodes/vhdl-mode.el	Mon Feb 02 20:49:41 2009 +0000
@@ -2328,42 +2328,19 @@
   "Enable case insensitive search and switch to syntax table that includes '_',
 then execute BODY, and finally restore the old environment.  Used for
 consistent searching."
-  `(let ((case-fold-search t)		; case insensitive search
-	 (current-syntax-table (syntax-table))
-	 result
-	 (restore-prog			; program to restore enviroment
-	  '(progn
-	     ;; restore syntax table
-	     (set-syntax-table current-syntax-table))))
+  `(let ((case-fold-search t))		; case insensitive search
      ;; use extended syntax table
-     (set-syntax-table vhdl-mode-ext-syntax-table)
-     ;; execute BODY safely
-     (setq result
-	   (condition-case info
-	       (progn ,@body)
-	     (error (eval restore-prog)	; restore environment on error
-		    (error (cadr info))))) ; pass error up
-     ;; restore environment
-     (eval restore-prog)
-     result))
+     (with-syntax-table vhdl-mode-ext-syntax-table
+       ,@body)))
 
 (defmacro vhdl-prepare-search-2 (&rest body)
   "Enable case insensitive search, switch to syntax table that includes '_',
 and remove `intangible' overlays, then execute BODY, and finally restore the
 old environment.  Used for consistent searching."
+  ;; FIXME: Why not just let-bind `inhibit-point-motion-hooks'?  --Stef
   `(let ((case-fold-search t)		; case insensitive search
 	 (current-syntax-table (syntax-table))
-	 result overlay-all-list overlay-intangible-list overlay
-	 (restore-prog			; program to restore enviroment
-	  '(progn
-	     ;; restore syntax table
-	     (set-syntax-table current-syntax-table)
-	     ;; restore `intangible' overlays
-	     (when (fboundp 'overlay-lists)
-	       (while overlay-intangible-list
-		 (overlay-put (car overlay-intangible-list) 'intangible t)
-		 (setq overlay-intangible-list
-		       (cdr overlay-intangible-list)))))))
+	 overlay-all-list overlay-intangible-list overlay)
      ;; use extended syntax table
      (set-syntax-table vhdl-mode-ext-syntax-table)
      ;; remove `intangible' overlays
@@ -2379,14 +2356,16 @@
 	   (overlay-put overlay 'intangible nil))
 	 (setq overlay-all-list (cdr overlay-all-list))))
      ;; execute BODY safely
-     (setq result
-	   (condition-case info
-	       (progn ,@body)
-	     (error (eval restore-prog)	; restore environment on error
-		    (error (cadr info))))) ; pass error up
-     ;; restore environment
-     (eval restore-prog)
-     result))
+     (unwind-protect
+         (progn ,@body)
+       ;; restore syntax table
+       (set-syntax-table current-syntax-table)
+       ;; restore `intangible' overlays
+       (when (fboundp 'overlay-lists)
+         (while overlay-intangible-list
+           (overlay-put (car overlay-intangible-list) 'intangible t)
+           (setq overlay-intangible-list
+                 (cdr overlay-intangible-list)))))))
 
 (defmacro vhdl-visit-file (file-name issue-error &rest body)
   "Visit file FILE-NAME and execute BODY."