Browse Source

tangle option to not post-process tangle comments

* lisp/ob-tangle.el (org-babel-tangle-comment-format-beg): Mention the
  new `org-babel-tangle-uncomment-comments' variable in the
  documentation.
  (org-babel-tangle-comment-format-end): Mention the new
  `org-babel-tangle-uncomment-comments' variable in the documentation.
  (org-babel-tangle-uncomment-comments): New customization variable to
  inhibit the post-processing of tangle comments.
  (org-babel-spec-to-string): Post-processing of tangle comments is
  now dependent upon a customization variable.
Eric Schulte 6 years ago
parent
commit
a3745c375b
1 changed files with 27 additions and 2 deletions
  1. 27 2
      lisp/ob-tangle.el

+ 27 - 2
lisp/ob-tangle.el

@@ -88,6 +88,11 @@ information into the output using `org-fill-template'.
 %link --------- Org-mode style link to the code block
 %source-name -- name of the code block
 
+Upon insertion the formatted comment will be commented out, and
+followed by a newline.  To inhibit this post-insertion processing
+set the `org-babel-tangle-uncomment-comments' variable to a
+non-nil value.
+
 Whether or not comments are inserted during tangling is
 controlled by the :comments header argument."
   :group 'org-babel
@@ -103,12 +108,25 @@ information into the output using `org-fill-template'.
 %link --------- Org-mode style link to the code block
 %source-name -- name of the code block
 
+Upon insertion the formatted comment will be commented out, and
+followed by a newline.  To inhibit this post-insertion processing
+set the `org-babel-tangle-uncomment-comments' variable to a
+non-nil value.
+
 Whether or not comments are inserted during tangling is
 controlled by the :comments header argument."
   :group 'org-babel
   :version "24.1"
   :type 'string)
 
+(defcustom org-babel-tangle-uncomment-comments nil
+  "Inhibits automatic commenting and addition of trailing newline
+of tangle comments.  Use `org-babel-tangle-comment-format-beg'
+and `org-babel-tangle-comment-format-end' to customize the format
+of tangled comments."
+  :group 'org-babel
+  :type 'boolean)
+
 (defcustom org-babel-process-comment-text #'org-remove-indentation
   "Function called to process raw Org-mode text collected to be
 inserted as comments in tangled source-code files.  The function
@@ -342,8 +360,15 @@ that the appropriate major-mode is set.  SPEC has the form:
 	 (insert-comment (lambda (text)
 			   (when (and comments (not (string= comments "no"))
 				      (> (length text) 0))
-			     (comment-region (point) (progn (insert text) (point)))
-			     (end-of-line nil) (insert "\n")))))
+			     (if org-babel-tangle-uncomment-comments
+				 ;; just plain comments with no processing
+				 (insert text)
+			       ;; ensure comments are made to be
+			       ;; comments, and add a trailing newline
+			       (comment-region
+				(point) (progn (insert text) (point)))
+			       (end-of-line nil)
+			       (insert "\n"))))))
     (when comment (funcall insert-comment comment))
     (when link-p
       (funcall