From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: footnote export fails if footnote indented Date: Wed, 13 Jan 2010 11:51:57 +0100 Message-ID: <0D8AC6D2-35B9-4F0B-A47B-76A6FC28E83D@gmail.com> References: <87skabj973.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary=Apple-Mail-1--542607601 Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NV0pc-0008Pd-LP for emacs-orgmode@gnu.org; Wed, 13 Jan 2010 05:52:08 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NV0pX-0008OY-Km for emacs-orgmode@gnu.org; Wed, 13 Jan 2010 05:52:07 -0500 Received: from [199.232.76.173] (port=52922 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NV0pX-0008OU-Gm for emacs-orgmode@gnu.org; Wed, 13 Jan 2010 05:52:03 -0500 Received: from mail-ew0-f209.google.com ([209.85.219.209]:59621) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NV0pW-0003JC-Vm for emacs-orgmode@gnu.org; Wed, 13 Jan 2010 05:52:03 -0500 Received: by ewy1 with SMTP id 1so283192ewy.8 for ; Wed, 13 Jan 2010 02:52:00 -0800 (PST) In-Reply-To: <87skabj973.fsf@stats.ox.ac.uk> 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: Dan Davison Cc: emacs org-mode mailing list --Apple-Mail-1--542607601 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Jan 12, 2010, at 10:37 PM, Dan Davison wrote: > If you hit 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 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 --Apple-Mail-1--542607601 Content-Disposition: attachment; filename=footnote-detach.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="footnote-detach.patch" Content-Transfer-Encoding: 7bit diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 892bde7..bdff64e 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))))))) --Apple-Mail-1--542607601 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-1--542607601 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-1--542607601--