X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/16ddec7e9e6adcf615db097d9627d490ca29208c..70c8ae6ebdad9265f793b91bc056204e0833682b:/lisp/org/ob-tangle.el?ds=sidebyside diff --git a/lisp/org/ob-tangle.el b/lisp/org/ob-tangle.el index 7077a1571e..c3b6a483ee 100644 --- a/lisp/org/ob-tangle.el +++ b/lisp/org/ob-tangle.el @@ -1,6 +1,6 @@ ;;; ob-tangle.el --- extract source code from org-mode files -;; Copyright (C) 2009-2012 Free Software Foundation, Inc. +;; Copyright (C) 2009-2013 Free Software Foundation, Inc. ;; Author: Eric Schulte ;; Keywords: literate programming, reproducible research @@ -38,7 +38,6 @@ (declare-function org-babel-update-block-body "org" (new-body)) (declare-function make-directory "files" (dir &optional parents)) -;;;###autoload (defcustom org-babel-tangle-lang-exts '(("emacs-lisp" . "el")) "Alist mapping languages to their file extensions. @@ -372,6 +371,10 @@ code blocks by language." (unless (and language (not (string= language src-lang))) (let* ((info (org-babel-get-src-block-info)) (params (nth 2 info)) + (extra (nth 3 info)) + (cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra) + (match-string 1 extra)) + org-coderef-label-format)) (link ((lambda (link) (and (string-match org-bracket-link-regexp link) (match-string 1 link))) @@ -389,6 +392,11 @@ code blocks by language." ((lambda (body) ;; run the tangle-body-hook (with-temp-buffer (insert body) + (when (string-match "-r" extra) + (goto-char (point-min)) + (while (re-search-forward + (replace-regexp-in-string "%s" ".+" cref-fmt) nil t) + (replace-match ""))) (run-hooks 'org-babel-tangle-body-hook) (buffer-string))) ((lambda (body) ;; expand the body in language specific manner @@ -514,6 +522,8 @@ which enable the original code blocks to be found." (provide 'ob-tangle) - +;; Local variables: +;; generated-autoload-file: "org-loaddefs.el" +;; End: ;;; ob-tangle.el ends here