From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WHKtAEuTo2LrVQAAbAwnHQ (envelope-from ) for ; Fri, 10 Jun 2022 20:54:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8KlvAEuTo2KZdAEAauVa8A (envelope-from ) for ; Fri, 10 Jun 2022 20:54:03 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2D11C8EB6 for ; Fri, 10 Jun 2022 20:54:02 +0200 (CEST) Received: from localhost ([::1]:38740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzjlh-0002WX-04 for larch@yhetil.org; Fri, 10 Jun 2022 14:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzjN3-0004le-OC for emacs-orgmode@gnu.org; Fri, 10 Jun 2022 14:28:34 -0400 Received: from mout01.posteo.de ([185.67.36.65]:47407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzjN1-0004GF-F1 for emacs-orgmode@gnu.org; Fri, 10 Jun 2022 14:28:33 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id E7605240026 for ; Fri, 10 Jun 2022 20:28:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1654885706; bh=XL2QH3zu96hFQaH5r3Ywmrre/nzxYIfaEkRHRKkR5u4=; h=From:To:Subject:Date:From; b=WCTKBnZ+s/0HjgDMCv134AAN91wMnJ8nfHd/G4vFtRw9+mGWlSKvjwHnAtBZkX/FT Dz9VSrHPdoaSZQJpmSaVkDdpYzH2j/NNTAo7v/gyEa80u84My62NN3OvHSfRmPjPDL xzPDAl1dLNYOaUpBeoTtjiQXStlMBO/svL0RyyWjYrk/BvT5tQqhw9Xu7Lh2heeykt GzxOwFXLJIDoDmh3LJbYHZ62d1SbTRGHWkzwblXvWdb1+GxbukFiwWGqo0m3KFGenQ MNqv+I7wJuLJdrG9ipAJZgllSkRZTD7N+kt8Os1PjG1ll09ILozJP0ayBtDK3yBkLM bCIH0GtRHQVug== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LKTx600S0z6tqx for ; Fri, 10 Jun 2022 20:28:25 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [Patch] ob-tangle.el: New value 'ascii' for the header argument ':comments' Date: Fri, 10 Jun 2022 18:28:24 +0000 Message-ID: <87o7z0tltj.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654887242; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=HjiPLJXO62hYCwa1cu7m07UBYTQbyMIsbM597PGwS6I=; b=iUmCp3PQESCpa6xG9NDo9xjve5iSRgDMJfszAnT7xdI3kxIZeiJUhMiZa9t+1nzxDkzTxH Tc9sfzwo2Yc274PlaEFLIw9MHrtmBrhuicq35fOYnoDvETd+D/iuO1iU2SSY3PO1evdMVH oZoADy1OQayCHSBx5afm5KPRefyQzdNIOv7ueB3ODUd3j7jxBlxnhVPDJB7MUZvN+LPn9i 7gZ/9tGME4TCw5QoqJ+N9Xb8oWMuNl4/jQEDA1sOC+nAeuymbCiGpnVWpBOZWCZm9Yl8PS gbFw6r2YlZQtqseyRJnYnDPPu6C7vW611fkInSOwSaYKM5Qf5VpFq9Qgg/5tIA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654887242; a=rsa-sha256; cv=none; b=qb3nGaWbWrl5zwX6zF01lJmJFvP5F8VlcVJOntt8BCfs37snSBsDdVWZ3ok+nQAPGwO4Ps +pPEm4ee4EDditMgs3E4IA9jqh675CHriKHAraG5J4b9ALfuSXumzzzTAKxUfgEko1pFpN ECeQbZ0UNaTNFsx3QBhymsSBotxgMAX/9iiwjDeqDLaXtcXGZVkDkRA+RYRWKrD0uivnfR 0wAOY6QJFl2iQbEIDT5AyZa++UjYqK7Xx1wdb17MEAarQTDdJwsBAaM8N2lYYV9V0PG0qM Abcyepl0w3WIABhXBlTiSQVfyi6AekD3KmHKjBYcqlE+7QGOnD9enH6qTYIzpQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WCTKBnZ+; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.18 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WCTKBnZ+; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2D11C8EB6 X-Spam-Score: -4.18 X-Migadu-Scanner: scn1.migadu.com X-TUID: 0QaNb9gF+49q --=-=-= Content-Type: text/plain Hi, With this new value, comments are passed to the source file as plain text, without the org metadata (keywords, property drawers, etc.). As usual, feedback and suggestions for this patch are greatly appreciated. Best regards and happy weekend, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ob-tangle.el-add-the-ascii-value-to-the-comment.patch >From 414e0b3a18abca34bc47f07e55debec0910d4728 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Fri, 10 Jun 2022 20:12:37 +0200 Subject: [PATCH] lisp/ob-tangle.el: add the `ascii' value to the `comments' head. arg. * (org-babel-tangle-single-block): With the value ascii the comments are passed as plain text. This is useful for removing all org metadata from the source file's comments. --- lisp/ob-tangle.el | 53 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 6685a1599..aed241416 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -525,23 +525,42 @@ non-nil, return the full association list to be used by (run-hooks 'org-babel-tangle-body-hook) (buffer-string)))) (comment - (when (or (string= "both" (cdr (assq :comments params))) - (string= "org" (cdr (assq :comments params)))) - ;; From the previous heading or code-block end - (funcall - org-babel-process-comment-text - (buffer-substring - (max (condition-case nil - (save-excursion - (org-back-to-heading t) ; Sets match data - (match-end 0)) - (error (point-min))) - (save-excursion - (if (re-search-backward - org-babel-src-block-regexp nil t) - (match-end 0) - (point-min)))) - (point))))) + (cond ((or (string= "both" (cdr (assq :comments params))) + (string= "org" (cdr (assq :comments params)))) + ;; From the previous heading or code-block end + (funcall + org-babel-process-comment-text + (buffer-substring + (max (condition-case nil + (save-excursion + (org-back-to-heading t) ; Sets match data + (match-end 0)) + (error (point-min))) + (save-excursion + (if (re-search-backward + org-babel-src-block-regexp nil t) + (match-end 0) + (point-min)))) + (point)))) + ((string= "ascii" (cdr (assq :comments params))) + ;; From the previous heading or code-block end + (let ((org-babel-process-comment-text + (lambda (str) + (org-export-string-as str 'ascii t)))) + (funcall + org-babel-process-comment-text + (buffer-substring + (max (condition-case nil + (save-excursion + (org-back-to-heading t) ; Sets match data + (match-beginning 0)) + (error (point-min))) + (save-excursion + (if (re-search-backward + org-babel-src-block-regexp nil t) + (match-beginning 0) + (point-min)))) + (point))))))) (src-tfile (cdr (assq :tangle params))) (result (list start-line -- 2.36.1 --=-=-=--