From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#29756: 25.2; Footnote-mode: recursive footnotes [UPDATED PATCH] Date: Sun, 17 Dec 2017 16:21:31 -0500 Message-ID: <20171217212131.v46ijlpze6dsws6i@E15-2016.optimum.net> References: <20171217161156.ojy5s3c37dqtgjch@E15-2016.optimum.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1513545627 18480 195.159.176.226 (17 Dec 2017 21:20:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Dec 2017 21:20:27 +0000 (UTC) User-Agent: NeoMutt/20171208 To: 29756@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 17 22:20:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQgMA-0004PZ-6Y for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Dec 2017 22:20:22 +0100 Original-Received: from localhost ([::1]:55537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQgO8-0001BA-Gn for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Dec 2017 16:22:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQgNr-0000yH-5L for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2017 16:22:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQgNm-0004y2-Oo for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2017 16:22:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQgNm-0004xy-KY for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2017 16:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eQgNm-00060O-Es for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2017 16:22:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <20171217161156.ojy5s3c37dqtgjch@E15-2016.optimum.net> Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Dec 2017 21:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29756 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 29756-submit@debbugs.gnu.org id=B29756.151354570323042 (code B ref 29756); Sun, 17 Dec 2017 21:22:02 +0000 Original-Received: (at 29756) by debbugs.gnu.org; 17 Dec 2017 21:21:43 +0000 Original-Received: from localhost ([127.0.0.1]:39379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQgNT-0005zZ-Ez for submit@debbugs.gnu.org; Sun, 17 Dec 2017 16:21:43 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:53549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQgNR-0005zH-IV for 29756@debbugs.gnu.org; Sun, 17 Dec 2017 16:21:42 -0500 Original-Received: from E15-2016.optimum.net ([108.6.168.221]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Ltr89-1f7g1T0d5J-011DMv for <29756@debbugs.gnu.org>; Sun, 17 Dec 2017 22:21:34 +0100 Content-Disposition: inline X-Provags-ID: V03:K0:JgBgtQvf0a8avtLOlBOT2e1GWl4lZGmfHyt6kQLoSqo9NRfTfZO 8qUi5mgg04pRKOykIOLmzQnhNePtRfFzpXwe0pDa3fX60yXlt3Ox1VQNDHlXBElFczLUnGI GCggimqeWjW3x8mFSMTJOgb6lqFSCjD/wfmito87ZLjxCCGTDV1FWMNMuhGeiTM7A/4+Ngl s+3Co8XGzxC8gPJy2g2IA== X-UI-Out-Filterresults: notjunk:1;V01:K0:ymfOhlOvu0w=:TPq4VaTx0x8FqmSKJSfuez 2jbduQ1fqQlH8F5EeHpXPFExy0NQ3HR2CWZgt0PIorVoUSXMlpmWMYXUMqCyEbdbqyp9W6WiR CE8KyuDElVBx3bZXTb3VcCCs4MYuIby4gxurpohkLw1lwDUS9MTSOL170zTDwUCYlA02k0u5T hI67IP2IFGqXtlGO/EZehgXIFWdutahb3cRgyDoRJk6NagiiF1ln2FtT4XS5XEQE4fSpZllmd IFrtE8F6vYsw23OSh+zRbxdxMShf5iSEieWVMPc5FnJzgLLRXN5JPAF5CStJYg7te/2JMNyCy KX9ratmRRw+RKmAQY9ldTE7cct6zoGaYC6ID6mox7dwscS62TGxxWyaTlzu7gJpTPQnQmXvRw CLRxTCgWHg2fIERqJUNG+HZi2e/NpNUXEWyGhKg53wLyYwnwqdaG0JbfpZpVHICBJx6enFz9a j3fU+yk7SLHu+dFsF/US8fw/KXS1OIe3DXHyNso7yDTNUahBN8XoKLqO4NdcSO4+uppA7zRyP kTbIM2bgmIkaCy/TTmSz7U/uPNmirhDz3y/iME+4lCf3mILCmuv/0dzHtE11CzW4YVomR4tnk 13yP/eP4O5QZDJL8IaAD9rNpvPGaegXBD8fwjRY2MHf04CZZaU9J0/lw5y+V+m97NvzMMN0OO ORMJvikor70IgpWjAksam8SroZ/UUOIHiRTTGGvHVkESeoLZivfxfeoF2T3aSi+d1g4sz0y27 xkfzT1rjyCrBhdUb2W8FfnIDTCKvgvY8C/l3p97uXZT8r+/9Z4g0ocanrJPW3HYJg1fLQ4S0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141209 Archived-At: 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