emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to inspect a document and check for the presence of source b


From: Nicolas Goaziou
Subject: Re: [O] How to inspect a document and check for the presence of source block language names and support
Date: Sat, 29 Nov 2014 11:38:36 +0100

Hello,

Andreas Leha <address@hidden> writes:

> Grant Rettke <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]