From: Dan Davison <davison@stats.ox.ac.uk>
To: Carsten Dominik <dominik@uva.nl>
Cc: emacs org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: footnote export fails if footnote indented
Date: Fri, 16 Apr 2010 12:53:32 -0400 [thread overview]
Message-ID: <87sk6vibjn.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <BC9E6833-120B-49DF-8734-229F6FCDAAE8@uva.nl> (Carsten Dominik's message of "Wed, 14 Apr 2010 16:50:19 +0200")
Carsten Dominik <dominik@uva.nl> writes:
> Hi Dan,
>
> have you given this patch any serious testing, and do you have
> any remarks about it?
Hi Carsten,
I hadn't forgotten about this but I have been conscious that I wasn't
giving it the testing it deserved. I don't export with footnotes that
much, and when I do it tends to be to HTML. So I haven't noticed any
problems, but perhaps some others who use footnotes more seriously than
me could test out this patch for a bit? Sorry, I know I should have sent
this email ages ago!
Dan
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 84cd7b3..e9a2822 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -62,7 +62,7 @@
"Regular expression for matching footnotes.")
(defconst org-footnote-definition-re
- (org-re "^\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)")
+ (org-re "^[ \t]*\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)")
"Regular expression matching the definition of a footnote.")
(defcustom org-footnote-section "Footnotes"
@@ -143,7 +143,12 @@ extracted will be filled again."
(defun org-footnote-at-reference-p ()
"Is the cursor at a footnote reference?
If yes, return the beginning position, the label, and the definition, if local."
- (when (org-in-regexp org-footnote-re 15)
+ (when (and (org-in-regexp org-footnote-re 15)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (progn (if (equal (char-after) ?\n) (forward-char 1)) t)
+ (save-match-data
+ (string-match "\\S-" (buffer-substring (point-at-bol) (point))))))
(list (match-beginning 0)
(or (match-string 1)
(if (equal (match-string 2) "fn:") nil (match-string 2)))
@@ -167,7 +172,7 @@ with start and label of the footnote if there is a definition at point."
(interactive "sLabel: ")
(org-mark-ring-push)
(setq label (org-footnote-normalize-label label))
- (let ((re (format "^\\[%s\\]\\|.\\[%s:" label label))
+ (let ((re (format "^[ \t]*\\[%s\\]\\|.\\[%s:" label label))
pos)
(save-excursion
(setq pos (or (re-search-forward re nil t)
@@ -385,13 +390,13 @@ referenced sequence."
(setq def (org-trim def))
(save-excursion
(goto-char (point-min))
- (if (not (re-search-forward (concat "^\\[" (regexp-quote ref)
+ (if (not (re-search-forward (concat "^[ \t]*\\[" (regexp-quote ref)
"\\]") nil t))
(setq def nil)
(setq beg (match-beginning 0))
(setq beg1 (match-end 0))
(re-search-forward
- (org-re "^[ \t]*$\\|^\\*+ \\|^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
+ (org-re "^[ \t]*$\\|^\\*+ \\|^[ \t]*\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
nil 'move)
(setq def (buffer-substring beg1 (or (match-beginning 0)
(point-max))))
@@ -524,14 +529,14 @@ and all references of a footnote label."
(goto-char (point-min))
(while (re-search-forward org-footnote-re nil t)
(setq l (or (match-string 1) (match-string 2)))
- (when (equal l label)
+ (when (and (equal l label) (org-footnote-at-reference-p))
(delete-region (1+ (match-beginning 0)) (match-end 0))
(incf nref)))
(goto-char (point-min))
- (setq def-re (concat "^\\[" (regexp-quote label) "\\]"))
+ (setq def-re (concat "^[ \t]*\\[" (regexp-quote label) "\\]"))
(while (re-search-forward def-re nil t)
(setq beg (match-beginning 0))
- (if (re-search-forward "^\\[\\|^[ \t]*$\\|^\\*+ " nil t)
+ (if (re-search-forward "^[ \t]*\\[\\|^[ \t]*$\\|^\\*+ " nil t)
(goto-char (match-beginning 0))
(goto-char (point-max)))
(delete-region beg (point))
@@ -567,7 +572,7 @@ and all references of a footnote label."
(org-footnote-normalize 'sort)
(when label
(goto-char (point-min))
- (and (re-search-forward (concat "^\\[" (regexp-quote label) "\\]")
+ (and (re-search-forward (concat "^[ \t]*\\[" (regexp-quote label) "\\]")
nil t)
(progn (insert " ")
(just-one-space)))))))
--8<---------------cut here---------------end--------------->8---
>
> Thanks.
>
> - Carsten
>
> On Jan 13, 2010, at 11:51 AM, Carsten Dominik wrote:
>
>>
>> On Jan 12, 2010, at 10:37 PM, Dan Davison wrote:
>>
>>> If you hit <TAB> on a footnote definition, it indents it away from
>>> column 1, to align with its heading. However, the footnote definition
>>> needs to start in column 1 in order for the footnote to be correctly
>>> exported. It would be nice if the footnote exported correctly even
>>> when
>>> indented (or if that's problematic, then a less preferable solution
>>> would be having <TAB> not indent it).
>>
>> Hi Dan,
>>
>> here is a patch that allows footnote definitions to be detached from
>> the left margin. However, I am not sure if it breaks anything else
>> - so extensive testing would be necessary...
>>
>> Also, renumbering footnotes etc will put them back at the margin
>> currently. I am not sure how that should be handled otherwise....
>>
>> - Carsten
>>
>> <footnote-detach.patch>
>
> - Carsten
next prev parent reply other threads:[~2010-04-16 16:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 21:37 footnote export fails if footnote indented Dan Davison
2010-01-13 10:51 ` Carsten Dominik
2010-04-14 14:50 ` Carsten Dominik
2010-04-16 16:53 ` Dan Davison [this message]
2010-04-16 18:11 ` Samuel Wales
2010-04-16 18:38 ` Dan Davison
2010-04-16 19:07 ` Samuel Wales
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sk6vibjn.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=dominik@uva.nl \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).