emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Footnote sorting bug
@ 2011-03-07 19:06 Matt Lundin
  2011-03-07 23:04 ` Matt Lundin
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Lundin @ 2011-03-07 19:06 UTC (permalink / raw)
  To: Org Mode

Sorting footnotes when org-footnote-section is nil can have very
destructive consequences. For instance, the following file...

--8<---------------cut here---------------start------------->8---
* Heading one

A footnote.[fn:one]

[fn:one] A footnote

Another footnote.[fn:two]

[fn:two] Another footnote

A third footnote.[fn:three]

[fn:three] A third

* Heading two

Some text
--8<---------------cut here---------------end--------------->8---

...loses the second heading when sorted....


--8<---------------cut here---------------start------------->8---
* Heading one

A footnote.[fn:one]

Another footnote.[fn:two]

A third footnote.[fn:three]


[fn:one] A footnote


[fn:two] Another footnote* Heading two

Some text


[fn:three] A third
--8<---------------cut here---------------end--------------->8---

I traced the problem to an extra forward-line added to
org-footnote-goto-local-insertion-point with commit
145109dc4a6f161e4ad826bea9cc970363649280, but seems to have had some
unintended consequences for org buffers.

The following patch fixes the sorting problem in org buffers. AFAICT, it
has no effect on footnote insertion in message mode buffers with
signatures. (Unfortunately, footnote sorting in message buffers with
signatures is broken both before and after this patch.)

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index b6a9bca..d28161e 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -511,8 +511,7 @@ ENTRY is (fn-label num-mark definition)."
     (beginning-of-line 0))
   (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
   (end-of-line 1)
-  (skip-chars-backward "\n\r\t ")
-  (forward-line))
+  (skip-chars-backward "\n\r\t "))
 
 (defun org-footnote-delete (&optional label)
   "Delete the footnote at point.
--8<---------------cut here---------------end--------------->8---

Best,
Matt

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Footnote sorting bug
  2011-03-07 19:06 Footnote sorting bug Matt Lundin
@ 2011-03-07 23:04 ` Matt Lundin
  2011-03-08  1:04   ` Matt Lundin
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Lundin @ 2011-03-07 23:04 UTC (permalink / raw)
  To: Org Mode

Matt Lundin <mdl@imapmail.org> writes:

> I traced the problem to an extra forward-line added to
> org-footnote-goto-local-insertion-point with commit
> 145109dc4a6f161e4ad826bea9cc970363649280.
>
> The following patch fixes the sorting problem in org buffers. AFAICT, it
> has no effect on footnote insertion in message mode buffers with
> signatures. (Unfortunately, footnote sorting in message buffers with
> signatures is broken both before and after this patch.)
>
> diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
> index b6a9bca..d28161e 100644
> --- a/lisp/org-footnote.el
> +++ b/lisp/org-footnote.el
> @@ -511,8 +511,7 @@ ENTRY is (fn-label num-mark definition)."
>      (beginning-of-line 0))
>    (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
>    (end-of-line 1)
> -  (skip-chars-backward "\n\r\t ")
> -  (forward-line))
> +  (skip-chars-backward "\n\r\t "))
>  
>  (defun org-footnote-delete (&optional label)
>    "Delete the footnote at point.

My apologies. Please disregard this patch. It does not fix the issue and
cause problems when creating footnotes.

I'll take a closer look at the code when I get a chance.

- Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Footnote sorting bug
  2011-03-07 23:04 ` Matt Lundin
@ 2011-03-08  1:04   ` Matt Lundin
  2011-03-09 10:46     ` [Accepted] [O] " Bastien Guerry
  2011-03-09 10:47     ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Matt Lundin @ 2011-03-08  1:04 UTC (permalink / raw)
  To: Org Mode

Matt Lundin <mdl@imapmail.org> writes:

> Matt Lundin <mdl@imapmail.org> writes:
>
>> I traced the problem to an extra forward-line added to
>> org-footnote-goto-local-insertion-point with commit
>> 145109dc4a6f161e4ad826bea9cc970363649280.
>>
>> The following patch fixes the sorting problem in org buffers. AFAICT, it
>> has no effect on footnote insertion in message mode buffers with
>> signatures. (Unfortunately, footnote sorting in message buffers with
>> signatures is broken both before and after this patch.)
>>
> My apologies. Please disregard this patch. It does not fix the issue and
> cause problems when creating footnotes.
>
> I'll take a closer look at the code when I get a chance.

The following patch fixes the sorting bug. It also inserts a blank line
above a new footnote definition, which is consistent with the spacing
that results when sorting footnotes. 

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index b6a9bca..f2b3489 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -314,7 +314,7 @@ or new, let the user edit the definition of the footnote."
     ;; Skip existing footnotes
     (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t)
       (forward-line))
-    (insert "[" label "] \n")
+    (insert "\n[" label "] \n")
     (goto-char (1- (point)))
     (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
 
@@ -500,7 +500,7 @@ ENTRY is (fn-label num-mark definition)."
     (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (car entry)))
 			     nil t)
       (org-footnote-goto-local-insertion-point)
-      (insert (format "\n\n[%s] %s" (car entry) (nth 2 entry))))))
+      (insert (format "\n[%s] %s\n" (car entry) (nth 2 entry))))))
 
 (defun org-footnote-goto-local-insertion-point ()
   "Find insertion point for footnote, just before next outline heading."
--8<---------------cut here---------------end--------------->8---

Best,
Matt

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Accepted] [O] Re: Footnote sorting bug
  2011-03-08  1:04   ` Matt Lundin
@ 2011-03-09 10:46     ` Bastien Guerry
  2011-03-09 10:47     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien Guerry @ 2011-03-09 10:46 UTC (permalink / raw)
  To: emacs-orgmode

Patch 658 (http://patchwork.newartisans.com/patch/658/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C8762rul8xr.fsf%40fastmail.fm%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] Re: Footnote sorting bug
> Date: Tue, 08 Mar 2011 06:04:00 -0000
> From: Matt Lundin <mdl@imapmail.org>
> X-Patchwork-Id: 658
> Message-Id: <8762rul8xr.fsf@fastmail.fm>
> To: Org Mode <emacs-orgmode@gnu.org>
> 
> Matt Lundin <mdl@imapmail.org> writes:
> 
> > Matt Lundin <mdl@imapmail.org> writes:
> >
> >> I traced the problem to an extra forward-line added to
> >> org-footnote-goto-local-insertion-point with commit
> >> 145109dc4a6f161e4ad826bea9cc970363649280.
> >>
> >> The following patch fixes the sorting problem in org buffers. AFAICT, it
> >> has no effect on footnote insertion in message mode buffers with
> >> signatures. (Unfortunately, footnote sorting in message buffers with
> >> signatures is broken both before and after this patch.)
> >>
> > My apologies. Please disregard this patch. It does not fix the issue and
> > cause problems when creating footnotes.
> >
> > I'll take a closer look at the code when I get a chance.
> 
> The following patch fixes the sorting bug. It also inserts a blank line
> above a new footnote definition, which is consistent with the spacing
> that results when sorting footnotes. 
> 
> --8<---------------cut here---------------start------------->8---
> --8<---------------cut here---------------end--------------->8---
> 
> Best,
> Matt
> 
> 
> diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
> index b6a9bca..f2b3489 100644
> --- a/lisp/org-footnote.el
> +++ b/lisp/org-footnote.el
> @@ -314,7 +314,7 @@ or new, let the user edit the definition of the footnote."
>      ;; Skip existing footnotes
>      (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t)
>        (forward-line))
> -    (insert "[" label "] \n")
> +    (insert "\n[" label "] \n")
>      (goto-char (1- (point)))
>      (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
>  
> @@ -500,7 +500,7 @@ ENTRY is (fn-label num-mark definition)."
>      (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (car entry)))
>  			     nil t)
>        (org-footnote-goto-local-insertion-point)
> -      (insert (format "\n\n[%s] %s" (car entry) (nth 2 entry))))))
> +      (insert (format "\n[%s] %s\n" (car entry) (nth 2 entry))))))
>  
>  (defun org-footnote-goto-local-insertion-point ()
>    "Find insertion point for footnote, just before next outline heading."
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: Footnote sorting bug
  2011-03-08  1:04   ` Matt Lundin
  2011-03-09 10:46     ` [Accepted] [O] " Bastien Guerry
@ 2011-03-09 10:47     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2011-03-09 10:47 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Org Mode

Matt Lundin <mdl@imapmail.org> writes:

> The following patch fixes the sorting bug. It also inserts a blank line
> above a new footnote definition, which is consistent with the spacing
> that results when sorting footnotes. 

Applied, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-09 10:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-07 19:06 Footnote sorting bug Matt Lundin
2011-03-07 23:04 ` Matt Lundin
2011-03-08  1:04   ` Matt Lundin
2011-03-09 10:46     ` [Accepted] [O] " Bastien Guerry
2011-03-09 10:47     ` Bastien

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).