From mboxrd@z Thu Jan 1 00:00:00 1970 From: Immanuel Litzroth Subject: Re: Bug: tangling with elisp as lang in a noweb reference doesn't work [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)] Date: Sat, 31 Aug 2019 10:34:20 +0200 Message-ID: References: <87blwdlaka.fsf@gmail.com> <87sgpitjv6.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:45000) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3yqA-0000Et-Td for emacs-orgmode@gnu.org; Sat, 31 Aug 2019 04:34:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3yq9-0006zS-JT for emacs-orgmode@gnu.org; Sat, 31 Aug 2019 04:34:34 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]:33829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i3yq9-0006yo-BI for emacs-orgmode@gnu.org; Sat, 31 Aug 2019 04:34:33 -0400 Received: by mail-io1-xd2f.google.com with SMTP id s21so19003510ioa.1 for ; Sat, 31 Aug 2019 01:34:33 -0700 (PDT) In-Reply-To: <87sgpitjv6.fsf@nicolasgoaziou.fr> 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" To: immanuel , emacs-orgmode@gnu.org No problem! I have some more coming up :-) I've been looking at getting org-babel to add line directives for languages that support it. (c, c++, haskell...). It would make literate programming for these kinds of languages much better, and other people have been complaining e.g. https://paulbatchelor.github.io/blog/posts/2018-09-21-org-babel-impressions.html Unfortunately there is no easy way to hook this into org-babel now without doing some rather intrusive work. 1) The language specific expansions don't know the file or the line a block comes from, and noweb references have already been expanded. 2) The tangle-body-hook is useless since it runs in a temp buffer that doesn't even have the major mode set for the language you're tangling to. 3) The :comments mechanism is not strong enough to allow language specific comments and it 's different for noweb vs. normal block expansion. Would there be interest in such a feature, if it doesn't change current behaviour? Immanuel On Fri, Aug 30, 2019 at 11:37 PM Nicolas Goaziou wrote: > > Hello, > > immanuel writes: > > > #+NAME: this is a test > > #+BEGIN_SRC elisp :tangle no > > > > (message \"aha\") #+END_SRC > > > > #+BEGIN_SRC elisp :noweb yes :comments noweb :tangle out.el > > first > > <> > > second > > #+END_SRC > > > > #+BEGIN_SRC elisp :tangle no > > (progn > > (org-babel-tangle) > > (with-temp-buffer > > (insert-file-contents "out.el") > > (buffer-string))))) > > #+END_SRC > > > > > > Doesn't work. The reason is that the function > > org-babel-expand-noweb-references uses > > > > #+BEGIN_SRC emacs-lisp > > (c-wrap (lambda (text) > > (with-temp-buffer > > (funcall (intern (concat lang "-mode"))) > > ... > > #+END_SRC > > Fixed! Thank you for the report and the analysis. > > Regards, > > -- > Nicolas Goaziou