From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Subject: Re: [PATCH] org-latex: Don't append newline to end of footnote Date: Thu, 31 Mar 2011 00:06:20 +0200 Message-ID: <878vvwe00z.fsf@gmail.com> References: <4D91DA12.1070707@gmail.com> <87d3l9kesc.fsf@gmail.com> <4D934249.5020602@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=45468 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q53X0-0005Ha-TS for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 18:06:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q53Wz-0006lQ-L2 for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 18:06:26 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:35360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q53Wz-0006ks-GQ for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 18:06:25 -0400 Received: by wyf19 with SMTP id 19so1798164wyf.0 for ; Wed, 30 Mar 2011 15:06:24 -0700 (PDT) In-Reply-To: <4D934249.5020602@gmail.com> (Rainer M. Krug's message of "Wed, 30 Mar 2011 16:46:33 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rainer M Krug Cc: Lawrence Mitchell , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Rainer M Krug writes: > Additional information: I changed to 7.5 (released version) and it works > there as expected. > > Rainer > > > On 30/03/11 11:14, Lawrence Mitchell wrote: >> Nicolas wrote: >>> Hello, >> >>> Lawrence Mitchell writes: >> >> >> [...] >> >>> The analysis is good, but unfortunately the patch has a flaw. >> >>> In fact, your patch work in that particular situation, but not if >>> a footnote definition ends with a list, nor if it ends with a link. To >>> solve the latter, you need to insert a white-space before the closing >>> bracket. To solve the former, I thought adding a newline instead of the >>> white-space was enough, but it now appears it was a bad idea. >> >>> Thus, the solution lies elsewhere. >> >> Ugh, indeed. I wonder whether it would be enough to add the >> correct list indent to the beginning of the line with the closing >> brace. >> >> ALthough I notice without my patch, the export of a footnote >> containing a list which is in a list also does not work: >> >> - Hello [fn:1] >> >> * Footnotes >> >> [fn:1] Goodbye >> - an item >> >> No idea how to fix this though, sorry. Would the attached patch work ? I've tested it successfully on the following buffer: --8<---------------cut here---------------start------------->8--- #+title: Test footnotes * Titre Text [fn:1] and a list - [fn:2] - three Another try [fn:3] * Footnotes [fn:1] A definition with - a list - of two elements [fn:2] Test [fn:3] [[file:~/.bashrc][bashrc]] --8<---------------cut here---------------end--------------->8--- Regards, -- Nicolas --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-org-latex-fix-footnotes-wrt-lists-and-links.patch Content-Description: footnote patch >From ccba9a10dddffb805635ecc10e760e92bf6ca8d2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 30 Mar 2011 23:52:33 +0200 Subject: [PATCH] org-latex: fix footnotes wrt lists and links * lisp/org-latex.el: pay attention to end of footnote. Before closing the command, ensure that list is properly closed or that last link is separated from the curly brace. --- lisp/org-latex.el | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index e42b64d..47fdfa7 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -2418,12 +2418,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (replace-match (org-export-latex-protect-string (concat "$^{" (match-string 1) "}$"))) (replace-match "") - (let ((end (save-excursion - (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t) - (match-beginning 0) (point-max))))) - (setq footnote (concat (org-trim (buffer-substring (point) end)) - ; last } won't be part of a link or list. - "\n")) + (let* ((end (save-excursion + (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t) + (match-beginning 0) (point-max)))) + (body (org-trim (buffer-substring (point) end)))) + ;; Fix for footnotes ending on a link or a list. + (setq footnote + (concat body + (if (string-match "ORG-LIST-END-MARKER\\'" body) + "\n" " "))) (delete-region (point) end)) (goto-char foot-beg) (delete-region foot-beg foot-end) -- 1.7.4.2 --=-=-=--