On 2016-02-28 Sun 02:23, Nicolas Goaziou wrote: > Hello, > > Martin Carlé writes: > >> Well, I wrapped the exporter mechanism into some advice functions that >> allow for many different exports from a single file in such a manner that >> multiple exports are not restricted to subtrees. > > Not sure to understand this. Never mind, I shall explain and release all the hack, if there is more time. > >> This extended export mechanism collects sections as marked by tags. >> This is why, I need to tag the org-footnote-section as well. > > Why don't you also collect systematically the footnote section? Because, tags are a general and convenient way of collecting sections and I'like to avoid special where ever possible. All in all, below are the tiny changes I was looking for, marked in comments as 'hack'. All best, mc > ,---- > | > | (defun org-footnote--clear-footnote-section () > | "Remove all footnote sections in buffer and create a new one. > | New section is created at the end of the buffer, before any file > | local variable definition. Leave point within the new section." > | (when org-footnote-section > | (goto-char (point-min)) > | (let ((regexp > | (format org-complex-heading-regexp-format ;; "^\\*+ +%s[ \t]*$" > | (regexp-quote org-footnote-section))) > | tags) ;;; hack > | (while (re-search-forward regexp nil t) > | > | ;; ;;; hack > | (save-match-data > | (save-excursion > | (beginning-of-line 1) > | (looking-at org-todo-line-tags-regexp) > | (when (match-beginning 4) > | (setq tags (concat " " (buffer-substring (match-beginning 4) (match-end 4))))))) > | > | (delete-region > | (match-beginning 0) > | (progn (org-end-of-subtree t t) > | (if (not (eobp)) (point) > | (org-footnote--goto-local-insertion-point) > | (skip-chars-forward " \t\n") > | (if (eobp) (point) (line-beginning-position)))))) > | (goto-char (point-max)) > | (org-footnote--goto-local-insertion-point) > | (when (and (cdr (assq 'heading org-blank-before-new-entry)) > | (zerop (save-excursion (org-back-over-empty-lines)))) > | (insert "\n")) > | ;; (insert "* " org-footnote-section "\n") > | (insert "* " org-footnote-section (or tags "") "\n") ;;; hack — the simple way > | (when tags > | (save-excursion > | (org-back-to-heading t) > | (org-set-tags nil 'align))) ;;; hack — the aligned way > | > | ))) > | > `---- > ,---- > | > | (defun org-footnote-create-definition (label) > | "Start the definition of a footnote with label LABEL. > | Return buffer position at the beginning of the definition. This > | function doesn't move point." > | (let ((label (org-footnote-normalize-label label)) > | electric-indent-mode) ; Prevent wrong indentation. > | (org-with-wide-buffer > | (cond > | ((not org-footnote-section) (org-footnote--goto-local-insertion-point)) > | ((save-excursion > | (goto-char (point-min)) > | (re-search-forward > | ;; (concat "^\\*+[ \t]+" (regexp-quote org-footnote-section) "[ \t]*$") > | (format org-complex-heading-regexp-format (regexp-quote org-footnote-section)) ;;; hack > | nil t)) > | (goto-char (match-end 0)) > | (forward-line) > | (unless (bolp) (insert "\n"))) > | (t (org-footnote--clear-footnote-section))) > | (when (zerop (org-back-over-empty-lines)) (insert "\n")) > | (insert "[fn:" label "] \n") > | (line-beginning-position 0)))) > `---- -- Fetch my gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 7E3CA33F