Fixed!

On Sun, 4 Feb 2024 at 19:36, Ihor Radchenko <yanta...@posteo.net> wrote:

> Pedro Andres Aranda Gutierrez <paag...@gmail.com> writes:
>
> > Next version of the patch. I've done almost everything.
>
> Thanks!
> You dropped Org mailing list from CC. Was it intentional?
>
> > ... Still need to
> > consider the startup options stuff... but will need more time for that.
>
> It is easy.
> Just add
>
>     ("fnanon" org-footnote-auto-label 'anonymous)
>
> to `org-startup-options'.
> And, of course, the manual (just a row in table there).
>
> > +*** Add creation of anonymous footnotes
>
> It is not clear what this is about.
>
> Maybe
>
> *** ~org-footnote-new~ can be configured to insert anonymous footnotes by
> default
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>


-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet
From 0767bccaabde21241576eaac1103e917c7649f40 Mon Feb 05 00:00:00 2024
From: "Pedro A. Aranda GutiƩrrez" <paag...@gmail.com>
Date: Sat, 5 Feb 2024 07:30:00 +0100
Subject: [PATCH] Silent anonymous footnote creation

* lisp/org-footnote.el: Add symbol `anonymous' to `org-footnote-auto-label'.
With this, anonymous footnotes will be created. This is sometimes useful
in long texts. Mimics \footnote{} in LaTeX. Modify `org-footnote-new'
to generate anonymous footnotes directly.

* lisp/org.el: Add `fnanon' to startup options

* testing/lisp/test-org-footnote.el: Add a test for creation of anonymous
footnotes.

* etc/ORG-NEWS: Announce new anonymous footnote support.

* doc/org-manual.el: Document `fnanon' startup option

---
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 06869fd97..2eb991a4a 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -20381,6 +20381,7 @@ changes.
   | =fnconfirm=  | Offer automatic label for editing or confirmation.     |
   | =fnadjust=   | Automatically renumber and sort footnotes.             |
   | =nofnadjust= | Do not renumber and sort automatically.                |
+  | =fnanon=     | Create anonymous footnotes with ~org-footnote-new~.    |

   #+vindex: org-hide-block-startup
   #+vindex: org-hide-drawer-startup
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9847083b3..33a9d51b9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -917,6 +917,11 @@ Completion is enabled for links to man pages added using ~org-insert-link~:
 =C-c C-l man RET emacscl TAB= to get =emacsclient=.  Of course, the ~ol-man~
 library should be loaded first.

+*** ~org-footnote-new~ can be configured to create anonymous footnotes
+
+Add new value ~anonymous~ for ~org-footnote-auto-label~ to create
+anonymous footnotes automatically with ~org-footnote-new~.
+
 ** New functions and changes in function arguments
 *** New API functions to store data within ~org-element-cache~

diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index c9584c3b8..16ab7f279 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -137,6 +137,7 @@ Possible values are:

 nil        Prompt the user for each label.
 t          Create unique labels of the form [fn:1], [fn:2], etc.
+anonymous  Create anonymous footnotes
 confirm    Like t, but let the user edit the created value.
            The label can be removed from the minibuffer to create
            an anonymous footnote.
@@ -146,6 +147,7 @@ random	   Automatically generate a unique, random label."
 	  (const :tag "Prompt for label" nil)
 	  (const :tag "Create automatic [fn:N]" t)
 	  (const :tag "Offer automatic [fn:N] for editing" confirm)
+	  (const :tag "Create anoymous [fn::]" anonymous)
 	  (const :tag "Create a random label" random))
   :safe #'symbolp)

@@ -666,15 +668,16 @@ or new, let the user edit the definition of the footnote."
     (user-error "Cannot insert a footnote here"))
   (let* ((all (org-footnote-all-labels))
 	 (label
-	  (if (eq org-footnote-auto-label 'random)
-	      (format "%x" (abs (random)))
-	    (org-footnote-normalize-label
-	     (let ((propose (org-footnote-unique-label all)))
-	       (if (eq org-footnote-auto-label t) propose
-		 (completing-read
-		  "Label (leave empty for anonymous): "
-		  (mapcar #'list all) nil nil
-		  (and (eq org-footnote-auto-label 'confirm) propose))))))))
+          (unless (eq org-footnote-auto-label 'anonymous)
+	    (if (eq org-footnote-auto-label 'random)
+	        (format "%x" (abs (random)))
+	      (org-footnote-normalize-label
+	       (let ((propose (org-footnote-unique-label all)))
+	         (if (eq org-footnote-auto-label t) propose
+		   (completing-read
+		    "Label (leave empty for anonymous): "
+		    (mapcar #'list all) nil nil
+		    (and (eq org-footnote-auto-label 'confirm) propose)))))))))
     (cond ((not label)
 	   (insert "[fn::]")
 	   (backward-char 1))
diff --git a/lisp/org.el b/lisp/org.el
index 7aa7b09a1..0fab7f513 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4125,6 +4125,7 @@ After a match, the following groups carry important information:
     ("fnplain" org-footnote-auto-label plain)
     ("fnadjust" org-footnote-auto-adjust t)
     ("nofnadjust" org-footnote-auto-adjust nil)
+    ("fnanon" org-footnote-auto-label 'anonymous)
     ("constcgs" constants-unit-system cgs)
     ("constSI" constants-unit-system SI)
     ("noptag" org-tag-persistent-alist nil)
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index 1ab58a989..ccbaf8eb6 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -21,6 +21,18 @@

 (require 'org-footnote)

+(ert-deftest test-org-footnote/new-anon ()
+  "Test `org-footnote-new' specifications."
+  ;; `org-footnote-auto-label' is `anonymous'.
+  (should
+   (string-match-p
+    "Test\\[fn::\\]"
+    (org-test-with-temp-text "Test<point>"
+      (let ((org-footnote-auto-label 'anonymous)
+	    (org-footnote-section nil))
+	(org-footnote-new))
+      (buffer-string)))))
+
 (ert-deftest test-org-footnote/new ()
   "Test `org-footnote-new' specifications."
   ;; `org-footnote-auto-label' is t.
--
2.34.1

Reply via email to