Commits

Anonymous committed e64ce6b

Patch from Hannu Koivisto <azure@iki.fi>

Comments (0)

Files changed (2)

+2000-01-22  Hannu Koivisto  <azure@iki.fi>
+
+	* footnote.el:
+	  * Now requires cl for Emacs use.
+	  * (footnote-always-blank-line-before-signature) New variable.
+	  * (footnote-style) Updated documentation string for new
+	    numeric-latin style.
+	  * (footnote-style-alist)
+	    * Style entries can now optionally have start and end tags
+	      as their fourth and fifth elements, respectively.
+	    * Added numeric-latin style.
+	  * (footnote-section-tag, footnote-section-tag-regexp,
+	     footnote-start-tag, footnote-end-tag) Changed from DEFCONSTs to
+	     DEFVARs.
+	  * (footnote-section-tag-regexp) Now initialized directly from
+	    footnote-section-tag.
+	  * (footnote-style-is-really-numeric-latin) New private variable.
+	  * (footnote-numeric-latin-regexp) New variable.
+	  * (Footnote-numeric-latin, Footnote-start-tag, Footnote-end-tag)
+	    New functions.
+	  * All uses of footnote-start-tag replaced with (Footnote-start-tag)
+	    and uses of footnote-end-tag with (Footnote-end-tag).
+	  * (Footnote-style-p) Modified to use FIRST and SECOND instead of
+	    NTH for clarity.
+	  * (Footnote-current-regexp) Ditto for FIRST and THIRD.
+	  * (Footnote-refresh-footnotes)
+	    * Now takes a style entry instead of just the index regexp
+	      as argument.
+	    * Rewritten to work with new and old styles having different
+	      start and end tags.
+	    * Can now transform indices with more than one digit.
+	  * (Footnote-assoc-index) Rewritten for clarity.
+	  * (Footnote-switch-style) New function.
+	  * (Footnote-cycle-style)
+	    * Added offset argument (how many styles to cycle through).
+	    * Modified to use Footnote-switch-style.
+	  * (Footnote-set-style) Added support for numeric-latin style.
+	  * (Footnote-insert-footnote)
+	    * Now returns t if the footnote was inserted before signature.
+	    * Now uses Footnote-goto-char-point-max instead of going to the
+	      end of the buffer (and past signature) if no footnotes after the
+	      footnote we are inserting after.
+	  * (Footnote-add-footnote)
+	    * Added support for numeric-latin style.
+	    * Rewrote misc. parts for clarity.
+	    * Now does what footnote-always-blank-line-before-signature tells
+	      to do.
+	  * (Footnote-delete-footnote)
+	    * Partly rewritten for clarity and...
+	    * Added support for numeric-latin style.
+	    * Added support for styles with an empty start tag.
+	    * Fixed not to delete parts of signature in certain cases.
+
 2000-05-23  Karl M. Hegbloom  <karlheg@debian.org>
 
 	* Makefile: Use BUILD_WITHOUT_MULE rather than BUILD_MULE.
 
 ;; Author: Steven L Baur <steve@xemacs.org>
 ;; Keywords: mail, news
-;; Version: 0.19
+;; Version: 0.20
 
 ;; This file is part of XEmacs.
 
 ;; Reasonable Undo support.
 ;; more language styles.
 
-;;; Change Log:
+;;; Change Log before introduction of the separate ChangeLog file:
 
-;; May-31-1998: In `Footnote-make-hole', `concat' was called with integer
-;;              argument; now use `Footnote-index-to-string' and `format'
 ;; Apr-04-1997: Added option to narrow buffer when editing the text of
 ;;		a footnote.
 ;;		Insertion and renumbering now works.
 
 ;;; Code:
 
+(require 'cl)
+
 (defgroup footnote nil
   "Support for footnotes in mail and news messages."
   :group 'message)
   :type 'boolean
   :group 'footnote)
 
+(defcustom footnote-always-blank-line-before-signature t
+  "If set true, a blank line will always be inserted before signature.
+This has visible effect only when `footnote-spaced-footnotes' is not true."
+  :type 'boolean
+  :group 'footnote)
+
 (defcustom footnote-style 'numeric
   "*Style used for footnoting.
 numeric == 1, 2, 3, ...
+numeric-latin == {�, �, �} | {1, 2, 3, 4, ...}
 english-lower == a, b, c, ...
 english-upper == A, B, C, ...
 roman-lower == i, ii, iii, iv, v, ...
 
 ;;; Interface variables that probably shouldn't be changed
 
-(defconst footnote-section-tag "Footnotes: "
+;; FIXME!  Make this customize-able?
+(defvar footnote-section-tag "Footnotes: "
   "*Tag inserted at beginning of footnote section.")
 
-(defconst footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
+(defvar footnote-section-tag-regexp footnote-section-tag
   "*Regexp which indicates the start of a footnote section.")
 
-;; The following three should be consumed by footnote styles.
-(defconst footnote-start-tag "["
+;; FIXME!  Make these customize-able?
+(defvar footnote-start-tag "["
   "*String used to denote start of numbered footnote.")
 
-(defconst footnote-end-tag "]"
+(defvar footnote-end-tag "]"
   "*String used to denote end of numbered footnote.")
 
 (defvar footnote-signature-separator (if (boundp 'message-signature-separator)
 
 ;;; Private variables
 
-(defvar footnote-style-number nil
-  "Footnote style represented as an index into footnote-style-alist.")
-(make-variable-buffer-local 'footnote-style-number)
-
 (defvar footnote-text-marker-alist nil
   "List of markers pointing to text of footnotes in message buffer.")
 (make-variable-buffer-local 'footnote-text-marker-alist)
   "Variable indicating whether footnote minor mode is active.")
 (make-variable-buffer-local 'footnote-mode)
 
+(defvar footnote-style-is-really-numeric-latin nil
+  "Whether current numeric style is actually numeric-latin.")
+(make-variable-buffer-local 'footnote-style-is-really-numeric-latin)
+
 ;;; Default styles
+;;; NUMERIC-LATIN
+(defconst footnote-numeric-latin-regexp "[���]"
+  "Regexp for Latin superscript digits.")
+
+(defun Footnote-numeric-latin (n)
+  "Numeric-latin footnote style.
+Use latin superscript digits if no more than three footnotes."
+  (case n
+    (1 "�")
+    (2 "�")
+    (3 "�")
+    (t (error "This should never happen."))))
+
 ;;; NUMERIC
 (defconst footnote-numeric-regexp "[0-9]"
   "Regexp for digits.")
 
 ;;; list of all footnote styles
 (defvar footnote-style-alist
-  `((numeric Footnote-numeric ,footnote-numeric-regexp)
+  `((numeric       Footnote-numeric       ,footnote-numeric-regexp)
+    (numeric-latin Footnote-numeric-latin ,footnote-numeric-latin-regexp
+                   ""                     "")
     (english-lower Footnote-english-lower ,footnote-english-lower-regexp)
     (english-upper Footnote-english-upper ,footnote-english-upper-regexp)
-    (roman-lower Footnote-roman-lower ,footnote-roman-lower-regexp)
-    (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp))
+    (roman-lower   Footnote-roman-lower   ,footnote-roman-lower-regexp)
+    (roman-upper   Footnote-roman-upper   ,footnote-roman-upper-regexp))
   "Styles of footnote tags available.
-By default only boring Arabic numbers, English letters and Roman Numerals
-are available.
+By default only boring Arabic numbers, latin superscript numbers, English
+letters and Roman Numerals are available.
 See footnote-han.el, footnote-greek.el and footnote-hebrew.el for more
 exciting styles.")
 
 ;;; Style utilities & functions
+
+(defun* Footnote-start-tag (&optional (style footnote-style))
+  (or (fourth (assq style footnote-style-alist))
+                  footnote-start-tag))
+
+(defun* Footnote-end-tag (&optional (style footnote-style))
+  (or (fifth (assq style footnote-style-alist))
+      footnote-end-tag))
+
 (defun Footnote-style-p (style)
   "Return non-nil if style is a valid style known to footnote-mode."
   (assq style footnote-style-alist))
 Conversion is done based upon the current selected style."
   (let ((alist (if (Footnote-style-p footnote-style)
 		   (assq footnote-style footnote-style-alist)
-		 (nth 0 footnote-style-alist))))
-    (funcall (nth 1 alist) index)))
+		 (first footnote-style-alist))))
+    (funcall (second alist) index)))
 
 (defun Footnote-current-regexp ()
   "Return the regexp of the index of the current style."
-  (concat (nth 2 (or (assq footnote-style footnote-style-alist)
-		     (nth 0 footnote-style-alist))) "*"))
+  (concat (third (or (assq footnote-style footnote-style-alist)
+		     (first footnote-style-alist))) "+"))
 
-(defun Footnote-refresh-footnotes (&optional index-regexp)
+(defun* Footnote-refresh-footnotes (&optional (old-style
+                                               (assq footnote-style
+                                                     footnote-style-alist)))
   "Redraw all footnotes.
-You must call this or arrange to have this called after changing footnote
-styles."
-  (unless index-regexp
-    (setq index-regexp (Footnote-current-regexp)))
-  (save-excursion
-    ;; Take care of the pointers first
-    (let ((i 0) locn alist)
-      (while (setq alist (nth i footnote-pointer-marker-alist))
-	(setq locn (cdr alist))
-	(while locn
-	  (goto-char (car locn))
-	  (search-backward footnote-start-tag nil t)
-	  (when (looking-at (concat
-			     (regexp-quote footnote-start-tag)
-			     "\\(" index-regexp "\\)"
-			     (regexp-quote footnote-end-tag)))
-	    (replace-match (concat
-			    footnote-start-tag
-			    (Footnote-index-to-string (1+ i))
-			    footnote-end-tag)
-			   nil "\\1"))
-	  (setq locn (cdr locn)))
-	(setq i (1+ i))))
+The old footnotes are assumed to be of OLD-STYLE and the style they will
+be redrawn is the current one.  You must call this or arrange to have this
+called after changing footnote styles."
+  (let ((old-ind-regexp (third old-style))
+        (old-start-tag  (Footnote-start-tag (first old-style)))
+        (old-end-tag    (Footnote-end-tag (first old-style)))
+        (new-start-tag  (Footnote-start-tag))
+        (new-end-tag    (Footnote-end-tag)))
+    (save-excursion
+      ;; Take care of the pointers first
+      (loop for i from 1
+            for footnote-entry in footnote-pointer-marker-alist
+            do (loop for location in (cdr footnote-entry)
+                     do
+                     (setf (point) location)
+                     (search-backward-regexp (concat (regexp-quote old-start-tag)
+                                                     old-ind-regexp)
+                                             nil t)
+                     (when (looking-at (concat
+                                        (regexp-quote old-start-tag)
+                                        "\\(" old-ind-regexp "+\\)"
+                                        (regexp-quote old-end-tag)))
+                       (replace-match (concat
+                                       new-start-tag
+                                       (Footnote-index-to-string i)
+                                       new-end-tag)
+                                      nil "\\1"))))
 
-    ;; Now take care of the text section
-    (let ((i 0) alist)
-      (while (setq alist (nth i footnote-text-marker-alist))
-	(goto-char (cdr alist))
-	(when (looking-at (concat
-			   (regexp-quote footnote-start-tag)
-			   "\\(" index-regexp "\\)"
-			   (regexp-quote footnote-end-tag)))
-	  (replace-match (concat
-			  footnote-start-tag
-			  (Footnote-index-to-string (1+ i))
-			  footnote-end-tag)
-			 nil "\\1"))
-	(setq i (1+ i))))))
+      ;; Now take care of the text section
+      (loop for i from 1
+            for footnote-entry in footnote-text-marker-alist
+            do (setf (point) (cdr footnote-entry))
+               (when (looking-at (concat
+                                  (regexp-quote old-start-tag)
+                                  "\\(" old-ind-regexp "+\\)"
+                                  (regexp-quote old-end-tag)))
+                 (replace-match (concat
+                                 new-start-tag
+                                 (Footnote-index-to-string i)
+                                 new-end-tag)
+                                nil "\\1"))))))
 
 (defun Footnote-assoc-index (key alist)
   "Give index of key in alist."
-  (let ((i 0) (max (length alist)) rc)
-    (while (and (null rc)
-		(< i max))
-      (when (eq key (car (nth i alist)))
-	(setq rc i))
-      (setq i (1+ i)))
-    rc))
+  (position key alist :key #'first))
 
-(defun Footnote-cycle-style ()
-  "Select next defined footnote style."
-  (interactive)
-  (let ((old (Footnote-assoc-index footnote-style footnote-style-alist))
-	(max (length footnote-style-alist))
-	idx)
-    (setq idx (1+ old))
-    (when (>= idx max)
-      (setq idx 0))
-    (setq footnote-style (car (nth idx footnote-style-alist)))
-    (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
+(defun Footnote-switch-style (to)
+  "Switch to another footnote style TO, refreshing the footnotes."
+  (let ((old (assq footnote-style footnote-style-alist))
+        (to  (if (and (eq footnote-style 'numeric)
+                      (eq to 'numeric-latin)
+                      footnote-style-is-really-numeric-latin)
+                 (or (car (first (rest (member* 'numeric-latin
+                                                footnote-style-alist :key #'car))))
+                     (car (first footnote-style-alist)))
+               to)))
+    (cond ((and (eq to 'numeric-latin)
+                (>= (length footnote-text-marker-alist) 4))
+           (message "You won't see latin superscripts until you have less than four footnotes.")
+           (Footnote-set-style 'numeric)
+           (setq footnote-style-is-really-numeric-latin t))
+          (t (Footnote-set-style to)))
+    (Footnote-refresh-footnotes old)))
+
+(defun* Footnote-cycle-style (&optional (arg 1))
+  "Select ARG'th (from the current one) defined footnote style."
+  (interactive "p")
+  (Footnote-switch-style
+   (first (nth (mod (+ (Footnote-assoc-index footnote-style
+                                             footnote-style-alist)
+                       arg)
+                    (length footnote-style-alist))
+               footnote-style-alist))))
 
 (defun Footnote-set-style (&optional style)
   "Select a specific style."
    (list (intern (completing-read
 		  "Footnote Style: "
 		  obarray #'Footnote-style-p 'require-match))))
+  (setq footnote-style-is-really-numeric-latin nil)
   (setq footnote-style style))
 
 ;; Internal functions
   "Insert numbered footnote at (point)."
   (let* ((start (point))
 	 (end (progn
-		(insert-before-markers (concat footnote-start-tag
+		(insert-before-markers (concat (Footnote-start-tag)
 					       (Footnote-index-to-string arg)
-					       footnote-end-tag))
+					       (Footnote-end-tag)))
 		(point))))
 
     (add-text-properties start end
     (setcar text-alist to)
     (while posn-list
       (goto-char (car posn-list))
-      (search-backward footnote-start-tag nil t)
+      (search-backward (Footnote-start-tag) nil t)
       (when (looking-at (format "%s%s%s"
-				(regexp-quote footnote-start-tag)
+				(regexp-quote (Footnote-start-tag))
 				(Footnote-current-regexp)
-				(regexp-quote footnote-end-tag)))
+				(regexp-quote (Footnote-end-tag))))
 	(add-text-properties (match-beginning 0) (match-end 0)
 			     (list 'footnote-number to))
 	(replace-match (format "%s%s%s"
-			       footnote-start-tag
+			       (Footnote-start-tag)
 			       (Footnote-index-to-string to)
-			       footnote-end-tag)))
+			       (Footnote-end-tag))))
       (setq posn-list (cdr posn-list)))
     (goto-char (cdr text-alist))
     (when (looking-at (format "%s%s%s"
-			      (regexp-quote footnote-start-tag)
+			      (regexp-quote (Footnote-start-tag))
 			      (Footnote-current-regexp)
-			      (regexp-quote footnote-end-tag)))
+			      (regexp-quote (Footnote-end-tag))))
       (add-text-properties (match-beginning 0) (match-end 0)
 			   (list 'footnote-number to))
       (replace-match (format "%s%s%s"
-			     footnote-start-tag
+			     (Footnote-start-tag)
 			     (Footnote-index-to-string to)
-			     footnote-end-tag) nil t))))
+			     (Footnote-end-tag)) nil t))))
 
 ;; Not needed?
 (defun Footnote-narrow-to-footnotes ()
   (Footnote-insert-pointer-marker arg (point))
   (Footnote-insert-numbered-footnote arg t)
   (Footnote-goto-char-point-max)
-  (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
-      (save-restriction
-	(when footnote-narrow-to-footnotes-when-editing 
-	  (Footnote-narrow-to-footnotes))
-	(Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
-	;; (message "Inserting footnote %d" arg)
-	(unless
-	    (or (eq arg 1)
-		(when (re-search-forward
-		       (if footnote-spaced-footnotes
-			   "\n\n"
-			 (concat "\n"
-				 (regexp-quote footnote-start-tag)
-				 (Footnote-current-regexp)
-				 (regexp-quote footnote-end-tag)))
-		       nil t)
-		  (unless (beginning-of-line) t))
-		(goto-char (point-max)))))
-    (unless (looking-at "^$")
-      (insert "\n"))
-    (when (eobp)
-      (insert "\n"))
-    (insert footnote-section-tag "\n"))
-  (let ((old-point (point)))
-    (Footnote-insert-numbered-footnote arg nil)
-    (Footnote-insert-text-marker arg old-point)))
+  (let (insertion-before-signature)
+    (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
+        (save-restriction
+          (when footnote-narrow-to-footnotes-when-editing 
+            (Footnote-narrow-to-footnotes))
+          (Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
+          (or (= arg 1)
+              (when (re-search-forward (if footnote-spaced-footnotes
+                                           "\n\n"
+                                         (concat "\n"
+                                                 (regexp-quote (Footnote-start-tag))
+                                                 (Footnote-current-regexp)
+                                                 (regexp-quote (Footnote-end-tag))))
+                                       nil t)
+                (beginning-of-line)
+                t)
+              (progn (Footnote-goto-char-point-max)
+                     (when (and (setq insertion-before-signature
+                                      (looking-at footnote-signature-separator))
+                                (not footnote-spaced-footnotes)
+                                footnote-always-blank-line-before-signature)
+                       (forward-line -1)
+                       (when (looking-at "^$")
+                         (delete-char 1))))))
+      ;; Need to create footnote section.
+      (setq insertion-before-signature (looking-at footnote-signature-separator))
+      (unless (looking-at "^$")
+        (insert "\n"))
+      (when (eobp)
+        (insert "\n"))
+      (insert footnote-section-tag "\n"))
+    (let ((old-point (point)))
+      (Footnote-insert-numbered-footnote arg nil)
+      (Footnote-insert-text-marker arg old-point))
+    insertion-before-signature))
 
 (defun Footnote-sort (list)
   (sort list (lambda (e1 e2)
 the buffer is narrowed to the footnote body.  The restriction is removed
 by using `Footnote-back-to-message'."
   (interactive "*P")
-  (let (num)
-    (if footnote-text-marker-alist
-	(if (< (point) (cadar (last footnote-pointer-marker-alist)))
-	    (setq num (Footnote-make-hole))
-	  (setq num (1+ (caar (last footnote-text-marker-alist)))))
-      (setq num 1))
+  (when (and (eq footnote-style 'numeric-latin)
+             (= 3 (length footnote-text-marker-alist)))
+    (Footnote-switch-style 'numeric)
+    (setq footnote-style-is-really-numeric-latin t))
+  (let ((num (if footnote-text-marker-alist
+                 (if (< (point) (cadar (last footnote-pointer-marker-alist)))
+                     (Footnote-make-hole)
+                   (1+ (caar (last footnote-text-marker-alist))))
+               1)))
     (message "Adding footnote %d" num)
-    (Footnote-insert-footnote num)
-    (insert-before-markers (make-string footnote-body-tag-spacing ? ))
-    (let ((opoint (point)))
-      (save-excursion
-	(insert-before-markers
-	 (if footnote-spaced-footnotes
-	     "\n\n"
-	   "\n"))
-	(when footnote-narrow-to-footnotes-when-editing
-	  (Footnote-narrow-to-footnotes)))
-      ;; Emacs/XEmacs bug?  save-excursion doesn't restore point when using
-      ;; insert-before-markers.
-      (goto-char opoint))))
+    (let ((insertion-before-signature (Footnote-insert-footnote num)))
+      (insert-before-markers (make-string footnote-body-tag-spacing ? ))
+      (let ((opoint (point)))
+        (save-excursion
+          (insert-before-markers
+           (if (or footnote-spaced-footnotes
+                   (and footnote-always-blank-line-before-signature
+                        insertion-before-signature))
+               "\n\n"
+             "\n"))
+          (when footnote-narrow-to-footnotes-when-editing
+            (Footnote-narrow-to-footnotes)))
+        ;; Emacs/XEmacs bug?  save-excursion doesn't restore point when using
+        ;; insert-before-markers.
+        (goto-char opoint)))))
 
 (defun Footnote-delete-footnote (&optional arg)
   "Delete a numbered footnote.
 With no parameter, delete the footnote under (point).  With arg specified,
 delete the footnote with that number."
   (interactive "*P")
-  (unless arg
-    (setq arg (Footnote-under-cursor)))
-  (when (and arg
-	     (or (not footnote-prompt-before-deletion)
-		 (y-or-n-p (format "Really delete footnote %d?" arg))))
-    (let (alist-ptr alist-txt locn)
-      (setq alist-ptr (assq arg footnote-pointer-marker-alist))
-      (setq alist-txt (assq arg footnote-text-marker-alist))
-      (unless (and alist-ptr alist-txt)
-	(error "Can't delete footnote %d" arg))
-      (setq locn (cdr alist-ptr))
-      (while (car locn)
-	(save-excursion
-	  (goto-char (car locn))
-	  (let* ((end (point))
-		 (start (search-backward footnote-start-tag nil t)))
-	    (kill-region start end)))
-	(setq locn (cdr locn)))
-      (save-excursion
-	(goto-char (cdr alist-txt))
-	(kill-region (point) (search-forward "\n\n" nil t)))
-      (setq footnote-pointer-marker-alist
-	    (delq alist-ptr footnote-pointer-marker-alist))
-      (setq footnote-text-marker-alist
-	    (delq alist-txt footnote-text-marker-alist))
-      (Footnote-renumber-footnotes)
-      (when (and (null footnote-text-marker-alist)
-		 (null footnote-pointer-marker-alist))
-	(save-excursion
-	  (let* ((end (Footnote-goto-char-point-max))
-		 (start (1- (re-search-backward
-			     (concat "^" footnote-section-tag-regexp)
-			     nil t))))
-	    (forward-line -1)
-	    (when (looking-at "\n")
-	      (kill-line))
-	    (kill-region start (if (< end (point-max))
-				   end
-				 (point-max)))))))))
+  (let ((arg (or arg (Footnote-under-cursor))))
+    (when (and arg
+               (or (not footnote-prompt-before-deletion)
+                   (y-or-n-p (format "Really delete footnote %d?" arg))))
+      (let* ((alist-ptr      (assq arg footnote-pointer-marker-alist))
+             (alist-at-entry (member* arg footnote-text-marker-alist :key #'car))
+             (alist-txt      (first alist-at-entry)))
+        (unless (and alist-ptr alist-txt)
+          (error "Can't delete footnote %d" arg))
+        (loop for location in (cdr alist-ptr)
+              do (save-excursion
+                   (setf (point) location)
+                   (kill-region (search-backward-regexp
+                                 (concat (regexp-quote (Footnote-start-tag))
+                                         (Footnote-current-regexp))
+                                 nil t)
+                                location)))
+        (save-excursion
+          (if (rest alist-at-entry)
+              (Footnote-goto-footnote (1+ arg))
+            (Footnote-goto-char-point-max)
+            (unless (or (looking-at "^$")
+                        footnote-spaced-footnotes
+                        footnote-always-blank-line-before-signature))
+            (when (and (not (looking-at "^$"))
+                       (not footnote-spaced-footnotes)
+                       footnote-always-blank-line-before-signature)
+              (forward-line -1)))
+          (kill-region (cdr alist-txt)
+                       (point)))
+        (setq footnote-pointer-marker-alist
+              (delq alist-ptr footnote-pointer-marker-alist))
+        (setq footnote-text-marker-alist
+              (delq alist-txt footnote-text-marker-alist))
+        (Footnote-renumber-footnotes)
+        (when (and footnote-style-is-really-numeric-latin
+                   (eq footnote-style 'numeric)
+                   (< (length footnote-text-marker-alist) 4))
+          (Footnote-switch-style 'numeric-latin))
+        (when (and (null footnote-text-marker-alist)
+                   (null footnote-pointer-marker-alist))
+          (save-excursion
+            (let ((end   (Footnote-goto-char-point-max))
+                  (start (1- (re-search-backward
+                              (concat "^" footnote-section-tag-regexp)
+                              nil t))))
+              (forward-line -1)
+              (let ((end (- end (cond ((looking-at "\n")
+                                       (kill-line)
+                                       1)
+                                      (t 0)))))
+                (kill-region start (if (< end (point-max))
+                                       end
+                                     (point-max)))))))))))
 
 (defun Footnote-renumber-footnotes (&optional arg)
   "Renumber footnotes, starting from 1."
       ;; add tokens to filladapt to match footnotes
       ;; 1] xxxxxxxxxxx x x x or [1] x x x x x x x
       ;;    xxx x xx xxx xxxx	     x x x xxxxxxxxxx
-      (let ((bullet-regexp (concat (regexp-quote footnote-start-tag)
+      (let ((bullet-regexp (concat (regexp-quote (Footnote-start-tag))
 				   "?[0-9a-zA-Z]+"
-				   (regexp-quote footnote-end-tag)
+				   (regexp-quote (Footnote-end-tag))
 				   "[ \t]")))
 	(unless (assoc bullet-regexp filladapt-token-table)
 	  (setq filladapt-token-table