Matt Lundin <m...@imapmail.org> writes:

> Gerald Wildgruber <gerald.wildgru...@unibas.ch> writes:
>
>> Matt, thanks! looking forward to any elucidation you can give on the
>> problem at hand!
>
> Could you tell me what the value of org-footnote-auto-adjust is on your
> machine?
>
> It seems on my end that the problem only occurs when
> org-footnote-auto-adjust is set to t. The problem seems to be line 556
> of org-footnote.el, which reorders the footnotes *after* the position of
> the footnote definition has been saved. When I remove that line or set
> org-footnote-auto-adjust to nil, the cursor is positioned correctly.

This patch should fix the issue. Testing is welcome.

Matt

>From d52d6b331e92dddce5477c131858ded7e091599e Mon Sep 17 00:00:00 2001
From: Matt Lundin <m...@imapmail.org>
Date: Thu, 13 Aug 2015 13:14:34 -0500
Subject: [PATCH] Fix position of cursor when creating footnotes

* lisp/org-footnote.el (org-footnote-auto-label): Call
  org-footnote-auto-adjust-maybe after going to the footnote definition.
  Otherwise the correct position is lost.
---
 lisp/org-footnote.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 7396609..1048219 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -553,12 +553,12 @@ or new, let the user edit the definition of the footnote."
 	  (t
 	   (insert "[" label "]")
 	   (let ((l (copy-marker (org-footnote-create-definition label))))
-	     (org-footnote-auto-adjust-maybe)
 	     (or (ignore-errors (org-footnote-goto-definition label l))
 		 ;; Since definition was created outside current
 		 ;; scope, edit it remotely.
 		 (progn (set-marker l nil)
-			(org-edit-footnote-reference))))))))
+			(org-edit-footnote-reference))))
+	   (org-footnote-auto-adjust-maybe)))))
 
 (defvar org-blank-before-new-entry) ; Silence byte-compiler.
 (defun org-footnote-create-definition (label)
-- 
2.5.0

Reply via email to