forked from mirrors/org-mode
now better at inserting wrapping comments, and using org-src-lang-modes
This commit is contained in:
parent
8e09dacdbc
commit
937e1aa981
|
@ -78,7 +78,11 @@ exported source code blocks by language."
|
||||||
(lambda (by-lang)
|
(lambda (by-lang)
|
||||||
(let* ((lang (car by-lang))
|
(let* ((lang (car by-lang))
|
||||||
(specs (cdr 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)))
|
(lang-specs (cdr (assoc lang org-babel-tangle-langs)))
|
||||||
(ext (first lang-specs))
|
(ext (first lang-specs))
|
||||||
(she-bang (second 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 she-bang (insert (concat she-bang "\n")))
|
||||||
(when commentable
|
(when commentable
|
||||||
(comment-region
|
(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)
|
(org-babel-spec-to-string spec)
|
||||||
(append-to-file nil nil file-name))
|
(append-to-file nil nil file-name))
|
||||||
;; update counter
|
;; update counter
|
||||||
|
@ -161,7 +166,8 @@ form
|
||||||
(link source-name params body)"
|
(link source-name params body)"
|
||||||
(flet ((insert-comment (text)
|
(flet ((insert-comment (text)
|
||||||
(when commentable
|
(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))
|
(let ((link (first spec))
|
||||||
(source-name (second spec))
|
(source-name (second spec))
|
||||||
(body (fourth spec))
|
(body (fourth spec))
|
||||||
|
@ -193,12 +199,14 @@ the source-code block which holds BODY."
|
||||||
(setq new-body (concat new-body text))))
|
(setq new-body (concat new-body text))))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert body) (goto-char (point-min))
|
(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))
|
(setq index (point))
|
||||||
(while (and (re-search-forward "<<\\(.+\\)>>" nil t))
|
(while (and (re-search-forward "<<\\(.+\\)>>" nil t))
|
||||||
(save-match-data (setf source-name (match-string 1)))
|
(save-match-data (setf source-name (match-string 1)))
|
||||||
;; add interval to new-body
|
;; 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)))
|
(nb-add (buffer-substring index (point)))
|
||||||
(setq index (point))
|
(setq index (point))
|
||||||
;; if found, add body of referenced source-block
|
;; if found, add body of referenced source-block
|
||||||
|
|
Loading…
Reference in a new issue