* [PATCH] Fix renumbering for footnotes at BOL.
@ 2011-09-29 9:19 Tassilo Horn
2011-09-29 11:41 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2011-09-29 9:19 UTC (permalink / raw)
To: emacs-orgmode
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.
---
| 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
--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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix renumbering for footnotes at BOL.
2011-09-29 9:19 [PATCH] Fix renumbering for footnotes at BOL Tassilo Horn
@ 2011-09-29 11:41 ` Nicolas Goaziou
2011-09-29 11:51 ` Tassilo Horn
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2011-09-29 11:41 UTC (permalink / raw)
To: Tassilo Horn; +Cc: emacs-orgmode
Hello,
Tassilo Horn <tassilo@member.fsf.org> writes:
> org-footnote-renumber-fn:N invalidates footnotes that appear as the
> first thing on a line. Here's a test file including the recipe.
>
> * 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
>
> Note, that in larger org files, it's likely that you don't even notice
> that the footnotes break.
It looks like the original function isn't right in more than one way (it
doesn't even make sure the matched string is really a footnote). But
that's another topic.
About your patch, I have but one question: I don't get a situation in
which the assert would be triggered, may you give me such an example?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix renumbering for footnotes at BOL.
2011-09-29 11:41 ` Nicolas Goaziou
@ 2011-09-29 11:51 ` Tassilo Horn
2011-09-29 13:03 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2011-09-29 11:51 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> It looks like the original function isn't right in more than one way
> (it doesn't even make sure the matched string is really a
> footnote). But that's another topic.
Yes, indeed.
> About your patch, I have but one question: I don't get a situation in
> which the assert would be triggered, may you give me such an example?
I don't either, and that's a good thing. I added that just as some
extra paranoia so that you get an error if a footnote gets broken.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix renumbering for footnotes at BOL.
2011-09-29 11:51 ` Tassilo Horn
@ 2011-09-29 13:03 ` Nicolas Goaziou
2011-09-29 13:46 ` Tassilo Horn
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2011-09-29 13:03 UTC (permalink / raw)
To: Tassilo Horn; +Cc: emacs-orgmode
Tassilo Horn <tassilo@member.fsf.org> writes:
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>> About your patch, I have but one question: I don't get a situation in
>> which the assert would be triggered, may you give me such an example?
> I don't either, and that's a good thing. I added that just as some
> extra paranoia so that you get an error if a footnote gets broken.
Well, provided the first part of the function doesn't modify the buffer,
I still don't see how the assert could fail, even with a broken
footnote. Now, I may also be less paranoid than you are in that case.
Do you still think that assert should be a stayer? If so, I'll apply
your patch.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix renumbering for footnotes at BOL.
2011-09-29 13:03 ` Nicolas Goaziou
@ 2011-09-29 13:46 ` Tassilo Horn
2011-09-29 14:01 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2011-09-29 13:46 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <n.goaziou@gmail.com> writes:
Hi!
>> I don't either, and that's a good thing. I added that just as some
>> extra paranoia so that you get an error if a footnote gets broken.
>
> Well, provided the first part of the function doesn't modify the
> buffer, I still don't see how the assert could fail, even with a
> broken footnote. Now, I may also be less paranoid than you are in
> that case.
You are right. And the regex doesn't even match broken footnotes, that
is, footnotes with missing numbers.
> Do you still think that assert should be a stayer?
Nope, feel free to remove that line.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-29 14:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 9:19 [PATCH] Fix renumbering for footnotes at BOL Tassilo Horn
2011-09-29 11:41 ` Nicolas Goaziou
2011-09-29 11:51 ` Tassilo Horn
2011-09-29 13:03 ` Nicolas Goaziou
2011-09-29 13:46 ` Tassilo Horn
2011-09-29 14:01 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).