Grant Rettke <g...@wisdomandwonder.com> writes: > What a treat, sir, thank you for sharing that as if by some delightful > magic, which surely it indeed is.
Many thanks also from my side! > > On Sat, Nov 29, 2014 at 4:38 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> > wrote: >> Hello, >> >> Andreas Leha <andreas.l...@med.uni-goettingen.de> writes: >> >>> Grant Rettke <g...@wisdomandwonder.com> writes: >>>> Good evening, >>>> >>>> My goal is to obtain the following behavior in org mode for a document: >>>> 1) Report an error if there is a source block without a language >>>> specified >>>> 2) Report an error if there is a source block with a language specified >>>> that is *not* present in `org-babel-load-languages' >>>> >>>> I've thought about ways to do this and come up with: >>>> 1) Visually inspect the document >>>> 2) Use `org-element' to parse and process the document >>> >>> I'd be interested in 2) if you come up with something here :-) >> >> (defun my-src-block-check () >> (interactive) >> (org-element-map (org-element-parse-buffer 'element) 'src-block >> (lambda (src-block) >> (let ((language (org-element-property :language src-block))) >> (cond ((null language) >> (error "Missing language at position %d" >> (org-element-property :post-affiliated src-block))) >> ((not (assoc-string language org-babel-load-languages)) >> (error "Unknown language at position %d" >> (org-element-property :post-affiliated >> src-block))))))) >> (message "Source blocks checked in %s." (buffer-name >> (buffer-base-buffer)))) >> >> >> Regards, >> >> -- >> Nicolas Goaziou >>