GNU bug report logs - #29756
25.2; Footnote-mode: recursive footnotes [PATCH included]

Previous Next

Package: emacs;

Reported by: Boruch Baum <boruch_baum <at> gmx.com>

Date: Sun, 17 Dec 2017 16:13:01 UTC

Severity: minor

Tags: patch, wontfix

Merged with 27777

Found in version 25.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Boruch Baum <boruch_baum <at> gmx.com>
To: 29756 <at> debbugs.gnu.org
Subject: bug#29756: 25.2; Footnote-mode: recursive footnotes [UPDATED PATCH]
Date: Sun, 17 Dec 2017 16:21:31 -0500
The updated code below improves the prior patch by forbidding a user
from creating a footnote WITHIN the text of
the`footnote-section-tag-text', and covering a case of the user manuall
deleting that same footnote-section-tag-text after creating a footnote.


(defun Footnote--abort-when-in-fn-area (orig-function &optional arg)
  "Do not allow 'recursive footnotes'."
  (interactive "P")
  (let ((p (point))
        (q (if (not footnote-text-marker-alist) (point-max)
            (if (string-equal footnote-section-tag "")
              (cdr (first footnote-text-marker-alist))
             (goto-char (cdr (first footnote-text-marker-alist)))
             (if (re-search-backward
                   (concat "^" footnote-section-tag-regexp) nil t)
               (match-beginning 0)
              ; This `else' should never happen, and indicates an error, ie. footnotes
              ; already exist and a footnote-section-tag is defined, but the section tag
              ; hasn't been found. We choose to assume that the user deleted it
              ; intentionally and wants us to behave in this buffer as if the section tag
              ; was set "", so we do that, now.
              (setq footnote-section-tag "")
              ; To illustrate the difference in behavior, create a few footnotes, delete
              ; the section tag, and create another footnote. Then undo, comment the
              ; above line (that sets the tag to ""), re-evaluate this function, and repeat.
              (cdr (first footnote-text-marker-alist))
            )))))
   (goto-char p) ; undo `re-search-backward' side-effect
   (if (< p q)
      (apply orig-function arg)
    (message "Add footnotes only while in text body"))))
(advice-add 'Footnote-add-footnote :around #'Footnote--abort-when-in-fn-area)

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0




This bug report was last modified 5 years and 363 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.