I don't have an automated way yet, but here's a function one can use:
(defun check-parens-in-tangled-file () "Tangle the current buffer, then run `check-parens' in the output tangled buffer." (interactive) (let ((tangled-file (car (org-babel-tangle)))) (with-current-buffer (find-file-noselect tangled-file) (check-parens)))
One could also do further checks by also calling, say, eval-buffer.
For an automated version, one tricky thing is that check-parens doesn't have a useful return value; if the check passes, it returns nil, and otherwise throws an error. You can wrap that, though, and do various things based on the return value:
(defun bad-parens-p () "Return `t' if `check-parens' indicates unbalanced parens or quotes; otherwise `nil'" (interactive) (condition-case err (check-parens) (error (message "%s" (error-message-string err)) t))) (defun check-parens-in-tangled-file () "Tangle the current buffer, then run `check-parens' in the output tangled buffer." (interactive) (let ((tangled-file (car (org-babel-tangle)))) (with-current-buffer (find-file-noselect tangled-file) (if (bad-parens-p) (message "Tangled file has unbalanced parentheses or quotes") (message "`check-parens' is satisfied with the tangled file.")))))
One approach could be to use write-contents-functions -- inspired by this emacs.sx answer, and looking at the documentation:
This works just like ‘write-file-functions’, but it is intended for hooks that pertain to the buffer’s contents, not to the particular visited file or its location, and can be used to create arbitrary save processes for buffers that aren’t visiting files at all. Such hooks are usually set up by major modes, as buffer-local bindings for this variable. This variable automatically becomes buffer-local whenever it is set; switching to a new major mode always resets this variable, but calling ‘set-visited-file-name’ does not. If any of the functions in this hook returns non-‘nil’, the file is considered already written and the rest are not called and neither are the functions in ‘write-file-functions’.
So in your literate config, you could run a function that returns non-nil when something is wrong with the output .el file.
For the moment, though, just having a function I can run that does some kind of check is a good start.