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: Andreas Leha
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 20:40:49 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin)

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