diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2013-05-30 18:03:21 -0400 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2013-05-30 18:03:33 -0400 |
commit | d9cfec3040e5d487d91336b9a643ad15d2fa5bec (patch) | |
tree | 425285d24005b742f97d5cefb7f48d0ec8740297 | |
parent | 94c48111c9e1543bafb012c2342847e343d82d4a (diff) | |
download | org-mode-d9cfec3040e5d487d91336b9a643ad15d2fa5bec.tar.gz |
jump back to the correct point in the code block
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Use the existing
org-edit-src functionality to jump back to the correct point in the
code block in the original Org-mode buffer.
-rw-r--r-- | lisp/ob-tangle.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 25dcb91..c5cde53 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -493,13 +493,15 @@ which enable the original code blocks to be found." "Jump from a tangled code file to the related Org-mode file." (interactive) (let ((mid (point)) - start end done + start body-start end done target-buffer target-char link path block-name body) (save-window-excursion (save-excursion (while (and (re-search-backward org-bracket-link-analytic-regexp nil t) (not ; ever wider searches until matching block comments (and (setq start (point-at-eol)) + (setq body-start (save-excursion + (forward-line 2) (point-at-bol))) (setq link (match-string 0)) (setq path (match-string 3)) (setq block-name (match-string 5)) @@ -520,6 +522,17 @@ which enable the original code blocks to be found." (org-babel-next-src-block (string-to-number (match-string 1 block-name))) (org-babel-goto-named-src-block block-name)) + ;; position at the beginning of the code block body + (goto-char (org-babel-where-is-src-block-head)) + (forward-line 1) + ;; Use org-edit-special to isolate the code. + (org-edit-special) + ;; Then move forward the correct number of characters in the + ;; code buffer. + (forward-char (- mid body-start)) + ;; And return to the Org-mode buffer with the point in the right + ;; place. + (org-edit-src-exit) (setq target-char (point))) (pop-to-buffer target-buffer) (prog1 body (goto-char target-char)))) |