diff --git a/lisp/org-babel-tangle.el b/lisp/org-babel-tangle.el index 3cf34e4f7..02f77a9a6 100644 --- a/lisp/org-babel-tangle.el +++ b/lisp/org-babel-tangle.el @@ -78,7 +78,11 @@ exported source code blocks by language." (lambda (by-lang) (let* ((lang (car by-lang)) (specs (cdr by-lang)) - (lang-f (intern (concat lang "-mode"))) + (lang-f (intern (concat + (or (plist-get org-src-lang-modes + (intern (concat ":" lang))) + lang) + "-mode"))) (lang-specs (cdr (assoc lang org-babel-tangle-langs))) (ext (first lang-specs)) (she-bang (second lang-specs)) @@ -108,7 +112,8 @@ exported source code blocks by language." (when she-bang (insert (concat she-bang "\n"))) (when commentable (comment-region - (point) (progn (insert "generated by org-babel-tangle") (point)))) + (point) (progn (insert "generated by org-babel-tangle") (point))) + (move-end-of-line nil)) (org-babel-spec-to-string spec) (append-to-file nil nil file-name)) ;; update counter @@ -161,7 +166,8 @@ form (link source-name params body)" (flet ((insert-comment (text) (when commentable - (comment-region (point) (progn (insert text) (point)))))) + (comment-region (point) (progn (insert text) (point))) + (move-end-of-line nil)))) (let ((link (first spec)) (source-name (second spec)) (body (fourth spec)) @@ -193,12 +199,14 @@ the source-code block which holds BODY." (setq new-body (concat new-body text)))) (with-temp-buffer (insert body) (goto-char (point-min)) - (funcall (intern (concat lang "-mode"))) + (funcall (intern (concat (or (plist-get org-src-lang-modes + (intern (concat ":" lang))) + lang) "-mode"))) (setq index (point)) (while (and (re-search-forward "<<\\(.+\\)>>" nil t)) (save-match-data (setf source-name (match-string 1))) ;; add interval to new-body - (goto-char (match-end 0)) + (goto-char (match-end 0)) (move-end-of-line nil) (nb-add (buffer-substring index (point))) (setq index (point)) ;; if found, add body of referenced source-block