From 7095cb5d547bfe9f0576418e71317ad3ebeade77 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Thu, 21 Jul 2022 13:47:23 +0200 Subject: [PATCH] lisp/ob-tangle.el: The `org' value for `:comments' is now plain text * org-babel-process-comment-text: `org-babel-export-comment-text-as-plain-text' function is added as a new default value, which exports the raw Org text as plain text. This is useful for removing all org metadata from the source file's comments. --- lisp/ob-tangle.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index f4fb2af71..aba87ef13 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -134,11 +134,12 @@ of tangled comments." :group 'org-babel :type 'boolean) -(defcustom org-babel-process-comment-text 'org-remove-indentation - "Function called to process raw Org text collected to be -inserted as comments in tangled source-code files. The function -should take a single string argument and return a string -result. The default value is `org-remove-indentation'." +(defcustom org-babel-process-comment-text 'org-babel-export-comment-text-as-plain-text + "Function called to process raw Org text collected to be inserted +as comments in tangled source-code files. The function should +take a single string argument and return a string result. The +default value is `org-babel-export-comment-text-as-plain-text'. +Legacy value is `org-remove-indentation'." :group 'org-babel :version "24.1" :type 'function) @@ -158,6 +159,11 @@ represented in the file." (with-current-buffer (get-file-buffer file) (revert-buffer t t t))) +(defun org-babel-export-comment-text-as-plain-text (comment) + "Default function to process raw Org text collected to be +inserted as comments in tangled source-code files." + (org-export-string-as comment 'ascii t)) + (defmacro org-babel-with-temp-filebuffer (file &rest body) "Open FILE into a temporary buffer execute BODY there like `progn', then kill the FILE buffer returning the result of @@ -533,8 +539,8 @@ non-nil, return the full association list to be used by (buffer-substring (max (condition-case nil (save-excursion - (org-back-to-heading t) ; Sets match data - (match-end 0)) + (re-search-backward org-heading-regexp) ; Sets match data + (match-beginning 0)) (error (point-min))) (save-excursion (if (re-search-backward -- 2.37.1