0

When I do

C-u C-c C-v t

to tangle the code block at point, my point moves to the head of the code block. How can I prevent that point movement.

0
1

One solution is to update to org 9.1.6. There they have moved the save-excursion to the beginning of org-babel-tangle.

By the way they use the wrong sequence (save-restriction (save-excursion ...)). Looks like that has historical reasons. Don't know what funny consequences that may have with org-babel-tangle. I think it would be worth a bug report.

If you want to keep an older version of org-mode you could put a save-excursion around org-babel-tangle via :around advice. That looks like:

(defun my-org-wrap-org-babel-tangle-in-save-excursion (oldfun &rest args)
"Put `save-excursion` around (org-babel-tangle (ARGS))."
  (save-excursion (apply oldfun args)))

(advice-add 'org-babel-tangle :around #'my-org-wrap-org-babel-tangle-in-save-excursion)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.