Browse Source

Footnotes: Allow notes to be placed into the current entry.

Setting org-footnote-section to nil now causes definitions to be
inserted at the end of the current outline node, instead of into a
special node names "Footnotes".
Carsten Dominik 16 years ago
parent
commit
b956d4077b
2 changed files with 30 additions and 21 deletions
  1. 1 1
      ORGWEBPAGE/Changes.org
  2. 29 20
      lisp/org-footnote.el

+ 1 - 1
ORGWEBPAGE/Changes.org

@@ -98,7 +98,7 @@ convert them to numbered ones before export.  Thanks, Paul!
 Literal examples introduced with =#+BEGIN_EXAMPLE= or =#+BEGIN_SRC=
 Literal examples introduced with =#+BEGIN_EXAMPLE= or =#+BEGIN_SRC=
 do now allow optional line numbering in the example.
 do now allow optional line numbering in the example.
 Furthermore, links to specific code lines are supported, greatly
 Furthermore, links to specific code lines are supported, greatly
-increasing Org-mode utility for writing tutorials and other
+increasing Org-mode's utility for writing tutorials and other
 similar documents.
 similar documents.
 
 
 Code references use special labels embedded directly into the
 Code references use special labels embedded directly into the

+ 29 - 20
lisp/org-footnote.el

@@ -62,15 +62,17 @@
 
 
 (defcustom org-footnote-section "Footnotes"
 (defcustom org-footnote-section "Footnotes"
   "Outline heading containing footnote definitions before export.
   "Outline heading containing footnote definitions before export.
-During editing, Org-mode places footnote definitions under this
-special outline heading.  You can have several such sections in a buffer,
-Org-mode will always use the nearest.  So, for example, each top-level
-heading could have its own level-2 child for footnotes.
-This is the heading where Org places the definition automatically.  However,
-by hand you may place definitions *anywhere*.
-During export, all subtrees starting with this heading will be removed."
+This can be nil, to place footnotes locally at the end of the current
+outline node.  If can also be the name of a special outline heading
+under which footnotes should be put.
+This variable defines the place where Org puts the definition
+automatically.  However, by hand you may place definitions *anywhere*.
+If this is a string, during export, all subtrees starting with this
+heading will be removed after extracting footnote definitions."
   :group 'org-footnotes
   :group 'org-footnotes
-  :type 'string)
+  :type '(choice
+	  (string :tag "Special outline node name")
+	  (const :tag "Define footnotes in the current outline node" nil)))
 
 
 (defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:"
 (defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:"
   "Tag marking the beginning of footnote section.
   "Tag marking the beginning of footnote section.
@@ -205,12 +207,17 @@ or new, let the user edit the definition of the footnote."
   (let (re p)
   (let (re p)
     (cond
     (cond
      ((org-mode-p)
      ((org-mode-p)
-      (setq re (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$"))
-      (unless (or (re-search-forward re nil t)
-		  (and (progn (widen) t)
-		       (re-search-forward re nil t)))
-	(goto-char (point-max))
-	(insert "\n\n* " org-footnote-section))
+      (if (not org-footnote-section)
+	  ;; No section, put foornote into the curren outline node
+	  nil
+	;; Try to find or make the special node
+	(setq re (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$"))
+	(unless (or (re-search-forward re nil t)
+		    (and (progn (widen) t)
+			 (re-search-forward re nil t)))
+	  (goto-char (point-max))
+	  (insert "\n\n* " org-footnote-section)))
+      ;; Now go to the end of this entry and insert there.
       (outline-next-heading)
       (outline-next-heading)
       (setq p (point))
       (setq p (point))
       (skip-chars-backward " \t\n\r")
       (skip-chars-backward " \t\n\r")
@@ -304,10 +311,11 @@ referenced sequence."
       (goto-char (point-min))
       (goto-char (point-min))
       (cond
       (cond
        ((org-mode-p)
        ((org-mode-p)
-	(if (re-search-forward
-	     (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
-		     "[ \t]*$")
-	     nil t)
+	(if (and org-footnote-section
+		 (re-search-forward
+		  (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
+			  "[ \t]*$")
+		  nil t))
 	    (if for-preprocessor
 	    (if for-preprocessor
 		(replace-match "")
 		(replace-match "")
 	      (org-back-to-heading t)
 	      (org-back-to-heading t)
@@ -316,8 +324,9 @@ referenced sequence."
 	      (delete-region (point) (org-end-of-subtree t)))
 	      (delete-region (point) (org-end-of-subtree t)))
 	  (goto-char (point-max))
 	  (goto-char (point-max))
 	  (unless for-preprocessor
 	  (unless for-preprocessor
-	    (insert "* " org-footnote-section "\n")
-	    (setq ins-point (point)))))
+	    (when org-footnote-section
+	      (insert "* " org-footnote-section "\n")
+	      (setq ins-point (point))))))
        (t
        (t
 	(if (re-search-forward 
 	(if (re-search-forward 
 	     (concat "^"
 	     (concat "^"