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: Grant Rettke
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 08:42:30 -0600

What a treat, sir, thank you for sharing that as if by some delightful
magic, which surely it indeed is.

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
>



-- 
Grant Rettke
address@hidden | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson



reply via email to

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