Serialize check-syntax
- Wait for ghc-mod to be ready before trying to check a buffer - Times out after 10s with an error - Only check-syntax visible buffers - check-syntax when switching to a buffer
This commit is contained in:
		
							parent
							
								
									509f43999f
								
							
						
					
					
						commit
						3bf4243baf
					
				| @ -64,9 +64,14 @@ nil            does not display errors/warnings. | |||||||
| 
 | 
 | ||||||
| (defun ghc-check-syntax () | (defun ghc-check-syntax () | ||||||
|   (interactive) |   (interactive) | ||||||
|  |   ;; Only check syntax of visible buffers | ||||||
|  |   (when (get-buffer-window (current-buffer) t) | ||||||
|  |     (with-timeout | ||||||
|  |         (10 (error "ghc process may have hung or exited with an error")) | ||||||
|  |       (while ghc-process-running (sleep-for 0.1))) | ||||||
|     (ghc-with-process (ghc-check-send) |     (ghc-with-process (ghc-check-send) | ||||||
|                       'ghc-check-callback |                       'ghc-check-callback | ||||||
| 		    (lambda () (setq mode-line-process " -:-")))) |                       (lambda () (setq mode-line-process " -:-"))))) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -117,6 +117,9 @@ | |||||||
|     (setq ghc-initialized t) |     (setq ghc-initialized t) | ||||||
|     (defadvice save-buffer (after ghc-check-syntax-on-save activate) |     (defadvice save-buffer (after ghc-check-syntax-on-save activate) | ||||||
|       "Check syntax with GHC when a haskell-mode buffer is saved." |       "Check syntax with GHC when a haskell-mode buffer is saved." | ||||||
|  |       (when (eq 'haskell-mode major-mode) (ghc-check-syntax))) | ||||||
|  |     (defadvice switch-to-buffer (after ghc-check-syntax-on-switch-to-buffer activate) | ||||||
|  |       "Check syntax with GHC when switching to a haskell-mode buffer." | ||||||
|       (when (eq 'haskell-mode major-mode) (ghc-check-syntax)))) |       (when (eq 'haskell-mode major-mode) (ghc-check-syntax)))) | ||||||
|   (ghc-import-module) |   (ghc-import-module) | ||||||
|   (ghc-check-syntax)) |   (ghc-check-syntax)) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Anthony Cowley
						Anthony Cowley