From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Syntax error warnings? (Especially important with :noweb-ref's) Date: Sat, 14 Jan 2012 10:49:57 -0700 Message-ID: <87sjji5g3e.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:45015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm7jz-0001De-H0 for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:50:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm7jx-0005Uy-P1 for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:50:07 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:51275) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rm7jx-0005TT-Jh for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:50:05 -0500 In-Reply-To: (Yu's message of "Thu, 12 Jan 2012 22:38:16 +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: Yu Cc: org-mode mailing list Yu writes: > Hello! > > I was wondering, if there is a way to get warnings for typos (e.g. > when specifying invalid properties or header arguments). It can just > easily happen that I mix up e.g. ":exports" and ":export" (though > that's probably a very harmless example). > While there is currently no way to do this there are two related functions which should help. ,----[org-babel-view-src-block-info] bound to C-c C-v I | org-babel-view-src-block-info is an interactive Lisp function in | `ob.el'. | | (org-babel-view-src-block-info) | | Display information on the current source block. | This includes header arguments, language and name, and is largely | a window into the `org-babel-get-src-block-info' function. `---- and ,----[org-babel-check-src-block] bound to C-c C-v c | org-babel-check-src-block is an interactive Lisp function in `ob.el'. | | (org-babel-check-src-block) | | Check for misspelled header arguments in the current code block. `---- This problem is not trivial because new language are permitted to create and use *any* header arguments they like, so there are no /wrong/ header arguments, there are only /suspicious/ header arguments (like the :exports option you suggest). The above function reports any suspicious header arguments. Perhaps there would be a way to integrate the above function with flyspell for automatic highlighting of suspicious header arguments. I'll put looking into such integration on my long-term Org task queue. > > More important it gets though, when trying to use the literate > programming facilities. > > Say I have a source code > > #+begin_src sh :noweb tangle :tangle foo.sh > <> > #+end_src > #+begin_src sh :noweb-ref fo > echo '... how are you?'; > #+end_src > > then tangling would run through without any indication of the typo in > the name of the "foo" block. Such errors might be hard to debug, > because there is no indication of the error, maybe nothing other than > runtime errors. > > An error message for the /use/ of undefined references only wouldn't > avoid such problems either, e.g. consider > > #+begin_src sh :noweb tangle :tangle foo.sh > <> > #+end_src > #+begin_src sh :noweb-ref foo > echo 'Hello World...'; > #+end_src > #+begin_src sh :noweb-ref fo > echo 'Hello World...'; > #+end_src > > where the only detectable error is, that "fo" was never used anywhere. > > A similiar question (though without the second part) was asked here: > http://lists.gnu.org/archive/html/emacs-orgmode/2009-11/msg00273.html > As far as I can tell, it stands unanswered. > Yes, although in many languages constructs like <> are valid code, so it would be inappropriate for tangling to raise errors by default. It is possible to turn on such errors on a language-by-language basis, by customizing the following variable. ,----[org-babel-noweb-error-langs] | org-babel-noweb-error-langs is a variable defined in `ob.el'. | Its value is nil | | Documentation: | Languages for which Babel will raise literate programming errors. | List of languages for which errors should be raised when the | source code block satisfying a noweb reference in this language | can not be resolved. `---- > > On a side note: What is the customary way to mention the > noweb-relevant name of a source block in the html/pdf export? After > all, if a code-block states > : <> > : <> > the reader needs to know, which code blocks define these. > Currently there is no automated support for this, so you should simply name code blocks manually, however this topic has been raised recently in another thread and there does seem to be interest for automated support. Best, > > > kind regards, Yu > -- Eric Schulte http://cs.unm.edu/~eschulte/