emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Another low-hanging fruit
Date: Mon, 5 Feb 2024 07:27:19 +0100	[thread overview]
Message-ID: <CAO48Bk-Q9t_H06Wf6oaSAeLT1RYie7fPC9NE=wx1xC-Ja1Znug@mail.gmail.com> (raw)
In-Reply-To: <87cytc13ad.fsf@localhost>


[-- Attachment #1.1: Type: text/plain, Size: 1222 bytes --]

Fixed!

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

> Pedro Andres Aranda Gutierrez <paaguti@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

[-- Attachment #1.2: Type: text/html, Size: 2197 bytes --]

[-- Attachment #2: 0001-Silent-anonymous-footnote-creation.patch --]
[-- Type: text/x-patch, Size: 5140 bytes --]

From 0767bccaabde21241576eaac1103e917c7649f40 Mon Feb 05 00:00:00 2024
From: "Pedro A. Aranda Gutiérrez" <paaguti@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

  parent reply	other threads:[~2024-02-05  6:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-03  7:19 Another low-hanging fruit Pedro Andres Aranda Gutierrez
2024-02-03 16:06 ` Ihor Radchenko
2024-02-04 13:59 ` Ihor Radchenko
     [not found]   ` <CAO48Bk-7kxHbYvbNT90QQ_3O5L23bdcQzMrqwa5bXnJjxepg-Q@mail.gmail.com>
     [not found]     ` <87cytc13ad.fsf@localhost>
2024-02-05  6:27       ` Pedro Andres Aranda Gutierrez [this message]
2024-02-05 14:41         ` Ihor Radchenko

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.orgmode.org/

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

  git send-email \
    --in-reply-to='CAO48Bk-Q9t_H06Wf6oaSAeLT1RYie7fPC9NE=wx1xC-Ja1Znug@mail.gmail.com' \
    --to=paaguti@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /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/org-mode.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).