From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tassilo Horn Subject: [PATCH] Fix renumbering for footnotes at BOL. Date: Thu, 29 Sep 2011 11:19:58 +0200 Message-ID: <87ehyzk8n5.fsf@thinkpad.tsdh.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9Cn0-0006LZ-EO for emacs-orgmode@gnu.org; Thu, 29 Sep 2011 05:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9Cmv-000380-FD for emacs-orgmode@gnu.org; Thu, 29 Sep 2011 05:20:22 -0400 Received: from lo.gmane.org ([80.91.229.12]:47914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9Cmv-000379-6A for emacs-orgmode@gnu.org; Thu, 29 Sep 2011 05:20:17 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R9Cmt-0002PV-It for emacs-orgmode@gnu.org; Thu, 29 Sep 2011 11:20:15 +0200 Received: from tsdh.uni-koblenz.de ([141.26.67.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 11:20:15 +0200 Received: from tassilo by tsdh.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 11:20:15 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi all, org-footnote-renumber-fn:N invalidates footnotes that appear as the first thing on a line. Here's a test file including the recipe. --8<---------------cut here---------------start------------->8--- * Bla This is a line in which the following footnote that is inserted exactly [fn:1] is the first thing in that line. And now invoke org-footnote-renumber-fn:N and see it breaking. * Footnotes [fn:1] Test --8<---------------cut here---------------end--------------->8--- Note, that in larger org files, it's likely that you don't even notice that the footnotes break. Once I added a patch on patchwork that fixed this issue, and that's shown as "accepted". http://patchwork.newartisans.com/patch/705/ I think, I've marked it as deferred or so myself because I've thought the issue was fixed in the meantime, but that doesn't seem to be true. Here's an updated patch. --- lisp/org-footnote.el | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index cce0921..931f7dd 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -893,16 +893,13 @@ If LABEL is non-nil, delete that footnote instead." (goto-char (point-min)) (while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t) (setq i (string-to-number (match-string 1))) - (when (and (string-match "\\S-" (buffer-substring - (point-at-bol) (match-beginning 0))) - (not (assq i map))) + (when (not (assq i map)) (push (cons i (number-to-string (incf n))) map))) (goto-char (point-min)) (while (re-search-forward "\\(\\[fn:\\)\\([0-9]+\\)\\([]:]\\)" nil t) - (replace-match (concat "\\1" - (cdr (assq (string-to-number (match-string 2)) - map)) - "\\3"))))))) + (setq i (cdr (assq (string-to-number (match-string 2)) map))) + (assert (progn i) t "Footnote has no number. Better undo renumbering!") + (replace-match (concat "\\1" i "\\3"))))))) (defun org-footnote-auto-adjust-maybe () "Renumber and/or sort footnotes according to user settings." -- 1.7.6.1