forked from mirrors/org-mode
Footnotes: Allow automatic sorting and renumbering
Customize the new variable org-footnote-auto-adjust or use the STARTUP option fnadjust to get automatic renumbering and sorting of footnotes after each insertion/deletion.
This commit is contained in:
parent
5eb2c3bf36
commit
0795e42daf
|
@ -1,3 +1,8 @@
|
|||
2009-07-03 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Footnotes): Document automatic renumbering and
|
||||
sorting.
|
||||
|
||||
2009-07-02 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Agenda commands): Document new bulk commands.
|
||||
|
|
31
doc/org.texi
31
doc/org.texi
|
@ -1524,7 +1524,9 @@ LaTeX}). Here are the valid references:
|
|||
|
||||
@table @code
|
||||
@item [1]
|
||||
A plain numeric footnote marker.
|
||||
A plain numeric footnote marker. Compatible with @file{footnote.el}, but not
|
||||
recommended because somthing like @samp{[1]} could easily be part of a code
|
||||
snippet.
|
||||
@item [fn:name]
|
||||
A named footnote reference, where @code{name} is a unique label word, or, for
|
||||
simplicity of automatic creation, a number.
|
||||
|
@ -1555,6 +1557,7 @@ is at a definition, jump to the (first) reference.
|
|||
|
||||
@vindex org-footnote-define-inline
|
||||
@vindex org-footnote-section
|
||||
@vindex org-footnote-auto-adjust
|
||||
Otherwise, create a new footnote. Depending on the variable
|
||||
@code{org-footnote-define-inline}@footnote{The corresponding in-buffer
|
||||
setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
|
||||
|
@ -1568,18 +1571,27 @@ options is offered:
|
|||
s @r{Sort the footnote definitions by reference sequence. During editing,}
|
||||
@r{Org makes no effort to sort footnote definitions into a particular}
|
||||
@r{sequence. If you want them sorted, use this command, which will}
|
||||
@r{also move entries according to @code{org-footnote-section}.}
|
||||
r @r{Renumber the simple @code{fn:N} footnotes.}
|
||||
@r{also move entries according to @code{org-footnote-section}. Automatic}
|
||||
@r{sorting after each insertion/deletion can be configured using the}
|
||||
@r{variable @code{org-footnote-auto-adjust}.}
|
||||
r @r{Renumber the simple @code{fn:N} footnotes. Automatic renumbering}
|
||||
@r{after each insertion/deletion can be configured using the variable}
|
||||
@r{@code{org-footnote-auto-adjust}.}
|
||||
S @r{Short for first @code{r}, then @code{s} action.}
|
||||
n @r{Normalize the footnotes by collecting all definitions (including}
|
||||
@r{inline definitions) into a special section, and then numbering them}
|
||||
@r{in sequence. The references will then also be numbers. This is}
|
||||
@r{meant to be the final step before finishing a document (@eg{} sending}
|
||||
@r{meant to be the final step before finishing a document (e.g. sending}
|
||||
@r{off an email). The exporters do this automatically, and so could}
|
||||
@r{something like @code{message-send-hook}.}
|
||||
d @r{Delete the footnote at point, and all definitions of and references}
|
||||
@r{to it.}
|
||||
@end example
|
||||
Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
|
||||
corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
|
||||
renumbering and sorting footnotes can be automatic after each insertion or
|
||||
deletion.
|
||||
|
||||
@kindex C-c C-c
|
||||
@item C-c C-c
|
||||
If the cursor is on a footnote reference, jump to the definition. If it is a
|
||||
|
@ -10114,16 +10126,19 @@ constSI @r{@file{constants.el} should use the SI unit system}
|
|||
@end example
|
||||
@vindex org-footnote-define-inline
|
||||
@vindex org-footnote-auto-label
|
||||
@vindex org-footnote-auto-adjust
|
||||
To influence footnote settings, use the following keywords. The
|
||||
corresponding variables are @code{org-footnote-define-inline} and
|
||||
@code{org-footnote-auto-label}.
|
||||
corresponding variables are @code{org-footnote-define-inline},
|
||||
@code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
|
||||
@cindex @code{fninline}, STARTUP keyword
|
||||
@cindex @code{fnnoinline}, STARTUP keyword
|
||||
@cindex @code{nofninline}, STARTUP keyword
|
||||
@cindex @code{fnlocal}, STARTUP keyword
|
||||
@cindex @code{fnprompt}, STARTUP keyword
|
||||
@cindex @code{fnauto}, STARTUP keyword
|
||||
@cindex @code{fnconfirm}, STARTUP keyword
|
||||
@cindex @code{fnplain}, STARTUP keyword
|
||||
@cindex @code{fnadjust}, STARTUP keyword
|
||||
@cindex @code{nofnadjust}, STARTUP keyword
|
||||
@example
|
||||
fninline @r{define footnotes inline}
|
||||
fnnoinline @r{define footnotes in separate section}
|
||||
|
@ -10132,6 +10147,8 @@ fnprompt @r{prompt for footnote labels}
|
|||
fnauto @r{create [fn:1]-like labels automatically (default)}
|
||||
fnconfirm @r{offer automatic label for editing or confirmation}
|
||||
fnplain @r{create [1]-like labels automatically}
|
||||
fnadjust @r{automatically renumber and sort footnotes}
|
||||
nofnadjust @r{do not renumber and sort automatically}
|
||||
@end example
|
||||
@cindex org-hide-block-startup
|
||||
To hide blocks on startup, use these keywords. The corresponding variable is
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
2009-07-03 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-footnote.el (org-footnote-auto-adjust): New option.
|
||||
(org-footnote-auto-adjust-maybe): New function.
|
||||
(org-footnote-new, org-footnote-delete): Call
|
||||
`org-footnote-auto-adjust-maybe'.
|
||||
|
||||
* org.el (org-startup-options): Add new footnote-related
|
||||
keywords.
|
||||
|
||||
* org-publish.el (org-publish-timestamp-filename): Additional
|
||||
arguments PUB-DIR and PUB-FUNC, which are included in the hash.
|
||||
(org-publish-needed-p): Additional arguments PUB-DIR PUB-FUNC
|
||||
|
|
|
@ -112,6 +112,23 @@ plain Automatically create plain number labels like [1]"
|
|||
(const :tag "Offer automatic [fn:N] for editing" confirm)
|
||||
(const :tag "Create automatic [N]" plain)))
|
||||
|
||||
(defcustom org-footnote-auto-adjust nil
|
||||
"Non-nil means, automatically adjust footnotes after insert/delete.
|
||||
When this is t, after each insertion or deletion of a footnote,
|
||||
simple fn:N footnotes will be renumbered, and all footnotes will be sorted.
|
||||
If you want to have just sorting or just renumbering, set this variable
|
||||
to `sort' or `renumber'.
|
||||
|
||||
The main values of this variable can be set with in-buffer options:
|
||||
|
||||
#+STARTUP: fnadjust
|
||||
#+STARTUP: nofnadjust"
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "Renumber" renumber)
|
||||
(const :tag "Sort" sort)
|
||||
(const :tag "Renumber and Sort" t)))
|
||||
|
||||
(defcustom org-footnote-fill-after-inline-note-extraction nil
|
||||
"Non-nil means, fill paragraphs after extracting footnotes.
|
||||
When extracting inline footnotes, the lengths of lines can change a lot.
|
||||
|
@ -247,10 +264,12 @@ or new, let the user edit the definition of the footnote."
|
|||
(message "New reference to existing note"))
|
||||
(org-footnote-define-inline
|
||||
(insert "[" label ": ]")
|
||||
(backward-char 1))
|
||||
(backward-char 1)
|
||||
(org-footnote-auto-adjust-maybe))
|
||||
(t
|
||||
(insert "[" label "]")
|
||||
(org-footnote-create-definition label)))))
|
||||
(org-footnote-create-definition label)
|
||||
(org-footnote-auto-adjust-maybe)))))
|
||||
|
||||
(defun org-footnote-create-definition (label)
|
||||
"Start the definition of a footnote with label LABEL."
|
||||
|
@ -322,7 +341,7 @@ With prefix arg SPECIAL, offer additional commands in a menu."
|
|||
;;;###autoload
|
||||
(defun org-footnote-normalize (&optional sort-only for-preprocessor)
|
||||
"Collect the footnotes in various formats and normalize them.
|
||||
This find the different sorts of footnotes allowed in Org, and
|
||||
This finds the different sorts of footnotes allowed in Org, and
|
||||
normalizes them to the usual [N] format that is understood by the
|
||||
Org-mode exporters.
|
||||
When SORT-ONLY is set, only sort the footnote definitions into the
|
||||
|
@ -510,6 +529,7 @@ and all references of a footnote label."
|
|||
(goto-char (point-max)))
|
||||
(delete-region beg (point))
|
||||
(incf ndef))))
|
||||
(org-footnote-auto-adjust-maybe)
|
||||
(message "%d definition(s) of and %d reference(s) of footnote %s removed"
|
||||
ndef nref label))))
|
||||
|
||||
|
@ -531,6 +551,20 @@ and all references of a footnote label."
|
|||
(while (re-search-forward "\\(\\[fn:\\)\\([0-9]+\\)\\([]:]\\)" nil t)
|
||||
(replace-match (concat "\\1" (cdr (assq (string-to-number (match-string 2)) map)) "\\3")))))))
|
||||
|
||||
(defun org-footnote-auto-adjust-maybe ()
|
||||
"Renumber and/or sort footnotes according to user settings."
|
||||
(when (memq org-footnote-auto-adjust '(t renumber))
|
||||
(org-footnote-renumber-fn:N))
|
||||
(when (memq org-footnote-auto-adjust '(t sort))
|
||||
(let ((label (nth 1 (org-footnote-at-definition-p))))
|
||||
(org-footnote-normalize 'sort)
|
||||
(when label
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward (concat "^\\[" (regexp-quote label) "\\]")
|
||||
nil t)
|
||||
(progn (insert " ")
|
||||
(just-one-space)))))))
|
||||
|
||||
(provide 'org-footnote)
|
||||
|
||||
;; arch-tag: 1b5954df-fb5d-4da5-8709-78d944dbfc37
|
||||
|
|
|
@ -3414,6 +3414,8 @@ After a match, the following groups carry important information:
|
|||
("fnprompt" org-footnote-auto-label nil)
|
||||
("fnconfirm" org-footnote-auto-label confirm)
|
||||
("fnplain" org-footnote-auto-label plain)
|
||||
("fnadjust" org-footnote-auto-adjust t)
|
||||
("nofnadjust" org-footnote-auto-adjust nil)
|
||||
("constcgs" constants-unit-system cgs)
|
||||
("constSI" constants-unit-system SI)
|
||||
("noptag" org-tag-persistent-alist nil)
|
||||
|
|
Loading…
Reference in New Issue