emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jacopo De Simoi <jacopods@protonmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix erroneous tangling of blocks
Date: Thu, 01 Jul 2021 03:50:11 +0000	[thread overview]
Message-ID: <2077251.irdbgypaU6@bl4ckspoons> (raw)

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Dear All,

 Please find attached a patch (against master) which takes care of the
following issue. Assume I have a block like this

#+begin_src sh :tangle no
  This should not be tangled
#+end_src

Then the block is correctly ignored when tangling the whole file, but
erroneously tangled (to a file named "no") when tangling is run with the
universal argument (so that only the current block should be tangled)

This happens because the check for the "no" option is not performed when
tangling a single block.  In the proposed patch I address this issue by
checking for the "no" option in the function org-babel-effective-tangled-
filename

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-ob-tangle.el-Parse-correctly-tangle-options.patch --]
[-- Type: text/x-patch; name=0002-ob-tangle.el-Parse-correctly-tangle-options.patch, Size: 1127 bytes --]

From 4ae3b326750e094b359de5c920cc9695edbea16d Mon Sep 17 00:00:00 2001
From: Jacopo De Simoi <jacopods@protonmail.com>
Date: Wed, 30 Jun 2021 23:33:56 -0400
Subject: [PATCH 2/2] ob-tangle.el: Parse correctly tangle options

* lisp/ob-tangle.el (org-babel-effective-tangled-filename): Check for
  the "no" parameter in this function to avoid erroneous tangling of a
  single block (e.g. with C-u C-c C-v t) even with the parameter
  :tangle no

TINYCHANGE
---
 lisp/ob-tangle.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 02379d44e..585020364 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -359,6 +359,7 @@ as computed by `org-babel-tangle-single-block'."
                     ((string= "yes" src-tfile)
                      ;; Use the buffer name
                      (file-name-sans-extension buffer-fn))
+                    ((string= "no" src-tfile) nil)
                     ((> (length src-tfile) 0) src-tfile)))
         (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang)))
     (when base-name
-- 
2.31.1


[-- Attachment #3: attachment.asc --]
[-- Type: application/pgp-signature, Size: 499 bytes --]

             reply	other threads:[~2021-07-01 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01  3:50 Jacopo De Simoi [this message]
2021-07-01 13:38 ` [PATCH] Fix erroneous tangling of blocks Timothy
2021-07-01 13:43   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2077251.irdbgypaU6@bl4ckspoons \
    --to=jacopods@protonmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).