Mercurial > emacs
comparison lisp/progmodes/vhdl-mode.el @ 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 | 55ba5af4bf3a |
comparison
equal
deleted
inserted
replaced
101755:b6273f409a73 | 101756:5f840f1a34d4 |
---|---|
2326 | 2326 |
2327 (defmacro vhdl-prepare-search-1 (&rest body) | 2327 (defmacro vhdl-prepare-search-1 (&rest body) |
2328 "Enable case insensitive search and switch to syntax table that includes '_', | 2328 "Enable case insensitive search and switch to syntax table that includes '_', |
2329 then execute BODY, and finally restore the old environment. Used for | 2329 then execute BODY, and finally restore the old environment. Used for |
2330 consistent searching." | 2330 consistent searching." |
2331 `(let ((case-fold-search t) ; case insensitive search | 2331 `(let ((case-fold-search t)) ; case insensitive search |
2332 (current-syntax-table (syntax-table)) | |
2333 result | |
2334 (restore-prog ; program to restore enviroment | |
2335 '(progn | |
2336 ;; restore syntax table | |
2337 (set-syntax-table current-syntax-table)))) | |
2338 ;; use extended syntax table | 2332 ;; use extended syntax table |
2339 (set-syntax-table vhdl-mode-ext-syntax-table) | 2333 (with-syntax-table vhdl-mode-ext-syntax-table |
2340 ;; execute BODY safely | 2334 ,@body))) |
2341 (setq result | |
2342 (condition-case info | |
2343 (progn ,@body) | |
2344 (error (eval restore-prog) ; restore environment on error | |
2345 (error (cadr info))))) ; pass error up | |
2346 ;; restore environment | |
2347 (eval restore-prog) | |
2348 result)) | |
2349 | 2335 |
2350 (defmacro vhdl-prepare-search-2 (&rest body) | 2336 (defmacro vhdl-prepare-search-2 (&rest body) |
2351 "Enable case insensitive search, switch to syntax table that includes '_', | 2337 "Enable case insensitive search, switch to syntax table that includes '_', |
2352 and remove `intangible' overlays, then execute BODY, and finally restore the | 2338 and remove `intangible' overlays, then execute BODY, and finally restore the |
2353 old environment. Used for consistent searching." | 2339 old environment. Used for consistent searching." |
2340 ;; FIXME: Why not just let-bind `inhibit-point-motion-hooks'? --Stef | |
2354 `(let ((case-fold-search t) ; case insensitive search | 2341 `(let ((case-fold-search t) ; case insensitive search |
2355 (current-syntax-table (syntax-table)) | 2342 (current-syntax-table (syntax-table)) |
2356 result overlay-all-list overlay-intangible-list overlay | 2343 overlay-all-list overlay-intangible-list overlay) |
2357 (restore-prog ; program to restore enviroment | |
2358 '(progn | |
2359 ;; restore syntax table | |
2360 (set-syntax-table current-syntax-table) | |
2361 ;; restore `intangible' overlays | |
2362 (when (fboundp 'overlay-lists) | |
2363 (while overlay-intangible-list | |
2364 (overlay-put (car overlay-intangible-list) 'intangible t) | |
2365 (setq overlay-intangible-list | |
2366 (cdr overlay-intangible-list))))))) | |
2367 ;; use extended syntax table | 2344 ;; use extended syntax table |
2368 (set-syntax-table vhdl-mode-ext-syntax-table) | 2345 (set-syntax-table vhdl-mode-ext-syntax-table) |
2369 ;; remove `intangible' overlays | 2346 ;; remove `intangible' overlays |
2370 (when (fboundp 'overlay-lists) | 2347 (when (fboundp 'overlay-lists) |
2371 (setq overlay-all-list (overlay-lists)) | 2348 (setq overlay-all-list (overlay-lists)) |
2377 (setq overlay-intangible-list | 2354 (setq overlay-intangible-list |
2378 (cons overlay overlay-intangible-list)) | 2355 (cons overlay overlay-intangible-list)) |
2379 (overlay-put overlay 'intangible nil)) | 2356 (overlay-put overlay 'intangible nil)) |
2380 (setq overlay-all-list (cdr overlay-all-list)))) | 2357 (setq overlay-all-list (cdr overlay-all-list)))) |
2381 ;; execute BODY safely | 2358 ;; execute BODY safely |
2382 (setq result | 2359 (unwind-protect |
2383 (condition-case info | 2360 (progn ,@body) |
2384 (progn ,@body) | 2361 ;; restore syntax table |
2385 (error (eval restore-prog) ; restore environment on error | 2362 (set-syntax-table current-syntax-table) |
2386 (error (cadr info))))) ; pass error up | 2363 ;; restore `intangible' overlays |
2387 ;; restore environment | 2364 (when (fboundp 'overlay-lists) |
2388 (eval restore-prog) | 2365 (while overlay-intangible-list |
2389 result)) | 2366 (overlay-put (car overlay-intangible-list) 'intangible t) |
2367 (setq overlay-intangible-list | |
2368 (cdr overlay-intangible-list))))))) | |
2390 | 2369 |
2391 (defmacro vhdl-visit-file (file-name issue-error &rest body) | 2370 (defmacro vhdl-visit-file (file-name issue-error &rest body) |
2392 "Visit file FILE-NAME and execute BODY." | 2371 "Visit file FILE-NAME and execute BODY." |
2393 `(if (null ,file-name) | 2372 `(if (null ,file-name) |
2394 (progn ,@body) | 2373 (progn ,@body) |