diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-05 11:55:55 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-05 11:55:55 +0200 |
commit | 8b9c1e15dfa24b19823d308cbd1ca6f629c048a9 (patch) | |
tree | 7165ae48e57dc85fed5e2a3dc7a9572718f3f4ed | |
parent | ed7d1dc6d7fea0cb849e5c6ebb76197023d4bb16 (diff) | |
download | org-mode-8b9c1e15dfa24b19823d308cbd1ca6f629c048a9.tar.gz |
ob-tangle: Fix `org-babel-detangle'
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Preserve position
in source block only if it doesn't put point outside of the block.
Reported-by: Frederick Giasson <fred@curbside.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-06/msg00008.html>
-rw-r--r-- | lisp/ob-tangle.el | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 105f7bf..d78c90b 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -581,10 +581,12 @@ which enable the original code blocks to be found." (t (org-babel-next-src-block (1- n))))) (org-babel-goto-named-src-block block-name)) (goto-char (org-babel-where-is-src-block-head)) - ;; Preserve location of point within the source code in tangled - ;; code file. (forward-line 1) - (forward-char (- mid body-start)) + ;; Try to preserve location of point within the source code in + ;; tangled code file. + (let ((offset (- mid body-start))) + (when (> end (+ offset (point))) + (forward-char offset))) (setq target-char (point))) (org-src-switch-to-buffer target-buffer t) (goto-char target-char) |