emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Ihor Radchenko <yantar92@gmail.com>
Subject: [RFC PATCH 1/2] org-babel-tangle-single-block: Do not create comment link when not requested
Date: Mon,  7 Feb 2022 20:31:14 +0800	[thread overview]
Message-ID: <0f17f3041df08edd9508fdf8e5519f6aa1ecca43.1644236545.git.yantar92@gmail.com> (raw)
In-Reply-To: <cover.1644236545.git.yantar92@gmail.com>

* lisp/ob-tangle.el (org-babel-tangle-single-block): Do not spend
extra time creating link to source block when :comments is set to
"no".
---
 lisp/ob-tangle.el | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 7ae319d4f..85356d537 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -472,16 +472,20 @@ (defun org-babel-tangle-single-block (block-counter &optional only-this-block)
 	 (extra (nth 3 info))
          (coderef (nth 6 info))
 	 (cref-regexp (org-src-coderef-regexp coderef))
-	 (link (let* (
-                      ;; The created link is transient.  Using ID is
-                      ;; not necessary, but could have side-effects if
-                      ;; used.  An ID property may be added to
-                      ;; existing entries thus creatin unexpected file
-                      ;; modifications.
-                      (org-id-link-to-org-use-id nil)
-                      (l (org-no-properties (org-store-link nil))))
-                 (and (string-match org-link-bracket-re l)
-                      (match-string 1 l))))
+	 (link (if (string= "no" (cdr (assq :comments params))) ""
+                 (let* (
+                        ;; The created link is transient.  Using ID is
+                        ;; not necessary, but could have side-effects if
+                        ;; used.  An ID property may be added to
+                        ;; existing entries thus creating unexpected
+                        ;; file modifications.
+                        (org-id-link-to-org-use-id nil)
+                        (l (org-no-properties
+                            (cl-letf (((symbol-function 'org-store-link-functions)
+                                       (lambda () nil)))
+                              (org-store-link nil)))))
+                   (and (string-match org-link-bracket-re l)
+                        (match-string 1 l)))))
 	 (source-name
 	  (or (nth 4 info)
 	      (format "%s:%d"
-- 
2.34.1



  reply	other threads:[~2022-02-07 12:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 12:31 [RFC PATCH 0/2] Make org-babel-tangle usable in after-save-hook on large org buffers Ihor Radchenko
2022-02-07 12:31 ` Ihor Radchenko [this message]
2022-02-07 12:31 ` [RFC PATCH 2/2] org-babel-expand-noweb-references: Cache block info Ihor Radchenko
2022-07-31  6:43 ` [RFC PATCH 0/2] Make org-babel-tangle usable in after-save-hook on large org buffers Ihor Radchenko

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=0f17f3041df08edd9508fdf8e5519f6aa1ecca43.1644236545.git.yantar92@gmail.com \
    --to=yantar92@gmail.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).