1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-25 07:27:57 +00:00

LaTeX export: Avoid footnote processing in LATEX_HEADER lines

Nick Dokos writes:

> I define a LaTeX macro at the top of my document, like so:
>
> ,----
> | ...
> | #+LATEX_HEADER: \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
> | #+LATEX_HEADER:   #1\ignorespaces
> | #+LATEX_HEADER: }
> | ...
> `----
>
> and export - I get the following inserted:
>
> ,----
> | ...
> | \begin{document}
> |
> |
> |
> |
> |
> | \$\^{}{1}\$ FOOTNOTE DEFINITION NOT FOUND: 1
> | ...
> `----
>
> Obviously, the macro argument spec is mistaken for a footnote.
This commit is contained in:
Carsten Dominik 2009-08-21 06:44:29 +01:00
parent 38f3009927
commit a48fe32c4c
3 changed files with 46 additions and 36 deletions

View File

@ -1,3 +1,7 @@
2009-08-21 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-in-commented-line): New function.
2009-08-20 Carsten Dominik <carsten.dominik@gmail.com> 2009-08-20 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-hide-block-toggle): Make folded blocks searchable. * org.el (org-hide-block-toggle): Make folded blocks searchable.

View File

@ -363,42 +363,44 @@ referenced sequence."
;; Now find footnote references, and extract the definitions ;; Now find footnote references, and extract the definitions
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward org-footnote-re nil t) (while (re-search-forward org-footnote-re nil t)
(org-if-unprotected (unless (org-in-commented-line)
(setq def (match-string 4) (org-if-unprotected
idef def (setq def (match-string 4)
ref (or (match-string 1) (match-string 2)) idef def
before (char-to-string (char-after (match-beginning 0)))) ref (or (match-string 1) (match-string 2))
(if (equal ref "fn:") (setq ref nil)) before (char-to-string (char-after (match-beginning 0))))
(if (and ref (setq a (assoc ref ref-table))) (if (equal ref "fn:") (setq ref nil))
(progn (if (and ref (setq a (assoc ref ref-table)))
(setq marker (nth 1 a)) (progn
(unless (nth 2 a) (setf (caddr a) def))) (setq marker (nth 1 a))
(setq marker (number-to-string (incf count)))) (unless (nth 2 a) (setf (caddr a) def)))
(save-match-data (setq marker (number-to-string (incf count))))
(if def (save-match-data
(setq def (org-trim def)) (if def
(save-excursion (setq def (org-trim def))
(goto-char (point-min)) (save-excursion
(if (not (re-search-forward (concat "^\\[" (regexp-quote ref) (goto-char (point-min))
"\\]") nil t)) (if (not (re-search-forward (concat "^\\[" (regexp-quote ref)
(setq def nil) "\\]") nil t))
(setq beg (match-beginning 0)) (setq def nil)
(setq beg1 (match-end 0)) (setq beg (match-beginning 0))
(re-search-forward (setq beg1 (match-end 0))
(org-re "^[ \t]*$\\|^\\*+ \\|^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]") (re-search-forward
nil 'move) (org-re "^[ \t]*$\\|^\\*+ \\|^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
(setq def (buffer-substring beg1 (or (match-beginning 0) nil 'move)
(point-max)))) (setq def (buffer-substring beg1 (or (match-beginning 0)
(goto-char beg) (point-max))))
(skip-chars-backward " \t\n\t") (goto-char beg)
(delete-region (1+ (point)) (match-beginning 0)))))) (skip-chars-backward " \t\n\t")
(unless sort-only (delete-region (1+ (point)) (match-beginning 0))))))
(replace-match (concat before "[" marker "]")) (unless sort-only
(and idef (replace-match (concat before "[" marker "]"))
org-footnote-fill-after-inline-note-extraction (and idef
(fill-paragraph))) org-footnote-fill-after-inline-note-extraction
(if (not a) (push (list ref marker def (if idef t nil)) ref-table)))) (fill-paragraph)))
(if (not a) (push (list ref marker def (if idef t nil))
ref-table)))))
;; First find and remove the footnote section ;; First find and remove the footnote section
(goto-char (point-min)) (goto-char (point-min))
(cond (cond

View File

@ -15547,6 +15547,10 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
(display-buffer buf) (display-buffer buf)
(sit-for 0)))) (sit-for 0))))
(defun org-in-commented-line ()
"Is point in a line starting with `#'?"
(equal (char-after (point-at-bol)) ?#))
(defun org-goto-marker-or-bmk (marker &optional bookmark) (defun org-goto-marker-or-bmk (marker &optional bookmark)
"Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK." "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK."
(if (and marker (marker-buffer marker) (if (and marker (marker-buffer marker)