diff --git a/lisp/langs/org-babel-css.el b/lisp/langs/org-babel-css.el index 836870f36..93a369dc8 100644 --- a/lisp/langs/org-babel-css.el +++ b/lisp/langs/org-babel-css.el @@ -34,7 +34,7 @@ (org-babel-add-interpreter "css") -(add-to-list 'org-babel-tangle-langs '("css" "css")) +(add-to-list 'org-babel-tangle-langs '("css" "css" nil t)) (defun org-babel-execute:css (body params) "Execute a block of CSS code with org-babel. This function is diff --git a/lisp/org-babel-tangle.el b/lisp/org-babel-tangle.el index 2767caaa0..3cf34e4f7 100644 --- a/lisp/org-babel-tangle.el +++ b/lisp/org-babel-tangle.el @@ -35,8 +35,9 @@ "Association list matching source-block languages. The car of each element should be a string indicating the source block language, and the cdr should be a list containing the extension -and shebang(#!) line to use when writing out the language to -file.") +shebang(#!) line to use when writing out the language to file, +and an optional flag indicating that the language is not +commentable.") (defun org-babel-load-file (file) "Load the contents of the Emacs Lisp source code blocks in the @@ -80,7 +81,8 @@ exported source code blocks by language." (lang-f (intern (concat lang "-mode"))) (lang-specs (cdr (assoc lang org-babel-tangle-langs))) (ext (first lang-specs)) - (she-bang (second lang-specs))) + (she-bang (second lang-specs)) + (commentable (not (third lang-specs)))) (mapc (lambda (spec) (let* ((tangle (cdr (assoc :tangle (third spec)))) @@ -104,8 +106,9 @@ exported source code blocks by language." (with-temp-buffer (funcall lang-f) (when she-bang (insert (concat she-bang "\n"))) - (comment-region - (point) (progn (insert "generated by org-babel-tangle") (point))) + (when commentable + (comment-region + (point) (progn (insert "generated by org-babel-tangle") (point)))) (org-babel-spec-to-string spec) (append-to-file nil nil file-name)) ;; update counter @@ -134,7 +137,7 @@ code blocks by language." (src-lang (first info)) (body (org-babel-expand-noweb-references info)) (params (third info)) - (spec (list link source-name params body)) + (spec (list link source-name params body (third (cdr (assoc src-lang org-babel-tangle-langs))))) by-lang) (unless (string= (cdr (assoc :tangle params)) "no") ;; maybe skip (unless (and lang (not (string= lang src-lang))) ;; maybe limit by language @@ -146,7 +149,7 @@ code blocks by language." (setq blocks (mapcar (lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang)))) blocks)) ;; blocks should contain all source-blocks organized by language - (message "blocks=%S" blocks) ;; debugging + ;; (message "blocks=%S" blocks) ;; debugging blocks)) (defun org-babel-spec-to-string (spec) @@ -157,10 +160,12 @@ form (link source-name params body)" (flet ((insert-comment (text) - (comment-region (point) (progn (insert text) (point))))) + (when commentable + (comment-region (point) (progn (insert text) (point)))))) (let ((link (first spec)) (source-name (second spec)) - (body (fourth spec))) + (body (fourth spec)) + (commentable (not (fifth spec)))) (insert "\n\n") (insert-comment (format "[[%s][%s]]" (org-link-escape link) source-name)) (insert (format "\n%s\n" (org-babel-chomp body)))