diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-12 16:48:05 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-12 17:07:23 -0700 |
commit | e3aaaec91c2797e81eb09a31f4e60e59c46671a4 (patch) | |
tree | b1e95fb050d4020ba92096166669c6e18b810c3d | |
parent | 5570bef3684c219fcaefdae06b4ca471c49acf4c (diff) | |
download | org-mode-e3aaaec91c2797e81eb09a31f4e60e59c46671a4.tar.gz |
babel: more informative automatically generated block names in tangled comments
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): more
informative automatically generated block names in comments
-rw-r--r-- | lisp/ob-tangle.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 36cb349..60fe114 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -33,6 +33,7 @@ (require 'cl)) (declare-function org-link-escape "org" (text &optional table)) +(declare-function org-heading-components "org" ()) (declare-function with-temp-filebuffer "org-interaction" (file &rest body)) (defcustom org-babel-tangle-lang-exts @@ -199,15 +200,23 @@ Return an association list of source-code block specifications of the form used by `org-babel-spec-to-string' grouped by language. Optional argument LANG can be used to limit the collected source code blocks by language." - (let ((block-counter 0) blocks) + (let ((block-counter 1) (current-heading "") blocks) (org-babel-map-src-blocks (buffer-file-name) - (setq block-counter (+ 1 block-counter)) + ((lambda (new-heading) + (if (not (string= new-heading current-heading)) + (progn + (setq block-counter 1) + (setq current-heading new-heading)) + (setq block-counter (+ 1 block-counter)))) + (replace-regexp-in-string "[ \t]" "-" + (nth 4 (org-heading-components)))) (let* ((link (progn (call-interactively 'org-store-link) (org-babel-clean-text-properties (car (pop org-stored-links))))) (info (org-babel-get-src-block-info)) (source-name (intern (or (nth 4 info) - (format "block-%d" block-counter)))) + (format "%s:%d" + current-heading block-counter)))) (src-lang (nth 0 info)) (expand-cmd (intern (concat "org-babel-expand-body:" src-lang))) (params (nth 2 info)) |