summaryrefslogtreecommitdiff
path: root/lisp/mail/footnote.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-01-20 19:42:21 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-01-20 19:42:21 +0100
commit434057ad925cad3ebcae1802fab60733ae5decae (patch)
tree13001c2b846c0dc485d901aea9e76a1f53f1907a /lisp/mail/footnote.el
parent7fe7efe0bbb00a541df1da68ca4cb4af14441fe1 (diff)
downloademacs-434057ad925cad3ebcae1802fab60733ae5decae.tar.gz
emacs-434057ad925cad3ebcae1802fab60733ae5decae.tar.bz2
emacs-434057ad925cad3ebcae1802fab60733ae5decae.zip
Fix footnote-mode problem when reopening an old file
* lisp/mail/footnote.el (footnote--regenerate-alist): New function (bug#7258). (footnote-mode): Use it to restore footnotes after opening an old file with footnotes.
Diffstat (limited to 'lisp/mail/footnote.el')
-rw-r--r--lisp/mail/footnote.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el
index ea109eec12a..9c1a738035e 100644
--- a/lisp/mail/footnote.el
+++ b/lisp/mail/footnote.el
@@ -910,7 +910,32 @@ play around with the following keys:
(unless (assoc bullet-regexp filladapt-token-table)
(setq filladapt-token-table
(append filladapt-token-table
- (list (list bullet-regexp 'bullet)))))))))
+ (list (list bullet-regexp 'bullet)))))))
+ (footnote--regenerate-alist)))
+
+(defun footnote--regenerate-alist ()
+ (save-excursion
+ (goto-char (point-min))
+ (if (not (re-search-forward footnote-section-tag-regexp nil t))
+ (error "No footnote section in this buffer")
+ (setq footnote--markers-alist
+ (cl-loop
+ with start-of-footnotes = (match-beginning 0)
+ with regexp = (footnote--current-regexp)
+ for (note text) in
+ (cl-loop for pos = (re-search-forward regexp nil t)
+ while pos
+ collect (list (match-string 1)
+ (copy-marker (match-beginning 0) t)))
+ do (goto-char (point-min))
+ collect (cl-list*
+ (string-to-number note)
+ text
+ (cl-loop
+ for pos = (re-search-forward regexp start-of-footnotes t)
+ while pos
+ when (equal note (match-string 1))
+ collect (copy-marker (match-beginning 0) t))))))))
(provide 'footnote)