From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: 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 Message-ID: References: <87egsmnvf7.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuopK-000373-HZ for emacs-orgmode@gnu.org; Sat, 29 Nov 2014 15:41:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuopF-0002Jv-He for emacs-orgmode@gnu.org; Sat, 29 Nov 2014 15:41:10 -0500 Received: from plane.gmane.org ([80.91.229.3]:54716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuopF-0002Jo-Au for emacs-orgmode@gnu.org; Sat, 29 Nov 2014 15:41:05 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XuopB-0004Ma-2b for emacs-orgmode@gnu.org; Sat, 29 Nov 2014 21:41:01 +0100 Received: from cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net ([81.102.136.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 29 Nov 2014 21:41:01 +0100 Received: from andreas.leha by cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 29 Nov 2014 21:41:01 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Grant Rettke 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 wrote: >> Hello, >> >> Andreas Leha writes: >> >>> Grant Rettke 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 >>