unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 29756@debbugs.gnu.org
Subject: bug#29756: 25.2; Footnote-mode: recursive footnotes [UPDATED PATCH]
Date: Sun, 24 Dec 2017 18:37:31 -0500	[thread overview]
Message-ID: <20171224233731.766dkag7jso7zlgv@E15-2016.optimum.net> (raw)
In-Reply-To: <83y3lulua1.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

On 2017-12-22 16:19, Eli Zaretskii wrote:
> Could you please rewrite the patch without using advice?  We generally
> avoid using that in Emacs's own sources.

Done, but in an organizationally messy manner. In parallel with this bug
report, I had proposed a separate feature on the dev mailing list, and
that snippet got swallowed into code Stefan Monnier is reviewing.

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

[-- Attachment #2: footnote.el.patch --]
[-- Type: text/x-diff, Size: 2620 bytes --]

--- /home/optimum/Downloads/footnote.el--downloaded_from_gnu.orig	2017-12-24 18:12:15.000000000 -0500
+++ /home/optimum/Downloads/footnote.el--downloaded_from_gnu	2017-12-24 18:35:34.199506628 -0500
@@ -747,6 +747,40 @@ footnote area, returns `point-max'."
 	(setq i (1+ i)))
       rc)))
 
+(defun Footnote--get-area-point-min (&optional arg)
+  "Return POINT of the beginning of the footnote area, being the
+start of the first footnote. If there is no footnote area,
+returns POINT-MAX. With optional arg, consider the
+footnote-section-tag to be part of the footnote area."
+  (if (not footnote-text-marker-alist)
+    (point-max)
+   (if (not arg)
+     (cdr (first footnote-text-marker-alist))
+    (when arg
+      (if (string-equal footnote-section-tag "")
+        (cdr (first footnote-text-marker-alist))
+       (let ((p (point)) min)
+        (goto-char (cdr (first footnote-text-marker-alist)))
+        (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
+          (setq min (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 "")
+         ; HOWEVER: The rest of footnote mode does not currently honor or account
+         ; for this.
+         ;
+         ; 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.
+         ;
+         ; TODO: integrate sanity checks at reasonable operational points.
+         (setq min (cdr (first footnote-text-marker-alist))))
+        (goto-char p)
+        min))))))
+
 (defun Footnote-add-footnote (&optional arg)
   "Add a numbered footnote.
 The number the footnote receives is dependent upon the relative location
@@ -755,6 +789,8 @@ If the variable `footnote-narrow-to-foot
 the buffer is narrowed to the footnote body.  The restriction is removed
 by using `Footnote-back-to-message'."
   (interactive "*P")
+  (if (> (point) (Footnote--get-area-point-min "including section tag"))
+    (error "Add footnotes only while in text body."))
   (let ((num
          (if footnote-text-marker-alist
              (if (< (point) (cl-cadar (last footnote-pointer-marker-alist)))

  reply	other threads:[~2017-12-24 23:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-17 16:11 bug#29756: 25.2; Footnote-mode: recursive footnotes [PATCH included] Boruch Baum
2017-12-17 21:21 ` bug#29756: 25.2; Footnote-mode: recursive footnotes [UPDATED PATCH] Boruch Baum
2017-12-22 14:19   ` Eli Zaretskii
2017-12-24 23:37     ` Boruch Baum [this message]
2019-06-24 15:32       ` Lars Ingebrigtsen
2019-06-24 17:00         ` Boruch Baum
2019-06-24 20:43           ` Lars Ingebrigtsen
2019-07-23  0:17             ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171224233731.766dkag7jso7zlgv@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=29756@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).