GNU bug report logs - #50218
28.0.50; org-babel-tangle-file tangles code blocks starting with #+begin_src :tangle no

Previous Next

Package: org-mode;

Reported by: Tassilo Neubauer <tassilo.neubauer <at> gmail.com>

Date: Thu, 26 Aug 2021 23:06:01 UTC

Severity: normal

Found in version 28.0.50

Done: Ihor Radchenko <yantar92 <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Tassilo Neubauer <tassilo.neubauer <at> gmail.com>
Cc: 50218 <at> debbugs.gnu.org
Subject: bug#50218: 28.0.50; org-babel-tangle-file tangles code blocks starting with #+begin_src :tangle no
Date: Mon, 17 Oct 2022 12:24:15 +0000
Tassilo Neubauer <tassilo.neubauer <at> gmail.com> writes:

> Here are the steps that led to code blocks being tangled I did not 
> expect to:
>
> emacs -Q
> C-x C-h: ~/org-roam/example.org
> content of example.org (excluding "):
> "
> #+begin_src emacs-lisp
> (setq some-emacs-lisp-variable t)
> #+end_src
>
> #+begin_src :tangle no
> ;;This line should not be in the elisp code
> #+end_src
> "
>
> open scratch buffer through menu.
> type into scratch buffer:
> (org-bable-tangle-file "/home/tassilo/org-roam/example.org"
> "/home/tassilo/org-roam/example.el")
> M-x:emacs-lisp-mode
> Select (with mouse) the above line and evaluate region through menu.
> I see in the minibuffer: "Tangled 2 code blocks from example.org"
> After typing C-h C-f: ~/org-roam/example.el
> I see the file content of "example.el" (excluding "):
> "
> (setq some-emacs-lisp-variable t)
>
> ;;This line should not be in the elisp code
>
> "

Well. I can see why you did not expect this, but the real cause is a
typo in your code block.

#+begin_src :tangle no
;;This line should not be in the elisp code
#+end_src

is viewed by Org mode as src block written in ":tangle" programming
language :) That's because you forgot to put language in the block and
Org takes the first word after #+begin_src and the language name.

This block does not have :tangle attribute and thus "example.el"
supplied in your function call is being used :)

On Org side, we may catch such scenarios in org-lint.
M-x org-lint currently reports no problem with the above block.

Not urgent fix. Patches are welcome :)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




This bug report was last modified 1 year and 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.