]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix footnote-mode problem when reopening an old file
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Jan 2021 18:42:21 +0000 (19:42 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Jan 2021 18:42:21 +0000 (19:42 +0100)
* 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.

lisp/mail/footnote.el

index ea109eec12a7e89b1df5b2c21de10eb312ed5bac..9c1a738035e713463eaae79536d28c20e45d7b17 100644 (file)
@@ -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)