summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTassilo Horn <tassilo@member.fsf.org>2010-10-22 11:53:19 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-10-24 18:19:57 +0200
commit145109dc4a6f161e4ad826bea9cc970363649280 (patch)
tree9828500b7571e8cda3e67e4fcdde55181939e580
parent6e73bcbf44c8ce00ae0ef0ff189dbf6bec9cc969 (diff)
downloadorg-mode-145109dc4a6f161e4ad826bea9cc970363649280.tar.gz
Make footnotes work correctly in message-mode
* lisp/org-footnote.el (org-footnote-create-definition) (org-footnote-goto-local-insertion-point): Add footnotes before signature when in message-mode.
-rw-r--r--lisp/org-footnote.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index e73e996..9c51db6 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -302,15 +302,19 @@ or new, let the user edit the definition of the footnote."
(t
(setq re (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$"))
(unless (re-search-forward re nil t)
- (goto-char (point-max))
- (skip-chars-backward " \t\r\n")
- (insert "\n\n")
- (delete-region (point) (point-max))
- (insert org-footnote-tag-for-non-org-mode-files "\n"))
- (goto-char (point-max))
- (skip-chars-backward " \t\r\n")))
- (insert "\n\n")
- (insert "[" label "] ")
+ (let ((max (if (and (eq major-mode 'message-mode)
+ (re-search-forward message-signature-separator nil t))
+ (progn (beginning-of-line) (point))
+ (goto-char (point-max)))))
+ (skip-chars-backward " \t\r\n")
+ (delete-region (point) max)
+ (insert "\n\n")
+ (insert org-footnote-tag-for-non-org-mode-files "\n")))))
+ ;; Skip existing footnotes
+ (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t)
+ (forward-line))
+ (insert "[" label "] \n")
+ (goto-char (1- (point)))
(message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
;;;###autoload
@@ -506,7 +510,8 @@ ENTRY is (fn-label num-mark definition)."
(beginning-of-line 0))
(if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
(end-of-line 1)
- (skip-chars-backward "\n\r\t "))
+ (skip-chars-backward "\n\r\t ")
+ (forward-line))
(defun org-footnote-delete (&optional label)
"Delete the footnote at point.