emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Another low-hanging fruit
@ 2024-02-03  7:19 Pedro Andres Aranda Gutierrez
  2024-02-03 16:06 ` Ihor Radchenko
  2024-02-04 13:59 ` Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2024-02-03  7:19 UTC (permalink / raw)
  To: Org Mode List, orgmode, Ihor Radchenko


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

Hi,

This is another low hanging fruit. I was a bit annoyed to have to leave an
empty label for inlined footnotes (à la LaTeX)... I don't know if this
qualifies as a TINYCHANGE...

Best, /PA
-- 
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: 781 bytes --]

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

From 0767bccaabde21241576eaac1103e917c7649f40 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutiérrez" <paaguti@gmail.com>
Date: Sat, 3 Feb 2024 08:12:12 +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 more
useful in long texts. Mimics \footnote{} in LaTeX.

---
 lisp/org-footnote.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index c9584c3b8..b0b392122 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 labels
 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))
--
2.34.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Another low-hanging fruit
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2024-02-03 16:06 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: Org Mode List, orgmode

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

> This is another low hanging fruit. I was a bit annoyed to have to leave an
> empty label for inlined footnotes (à la LaTeX)... I don't know if this
> qualifies as a TINYCHANGE...

Don't you have FSF copyright assignment?

-- 
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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another low-hanging fruit
  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>
  1 sibling, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-02-04 13:59 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: Org Mode List, orgmode

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

> Subject: [PATCH] Silent anonymous footnote creation

This is a bit confusing. Maybe something like

org-footnote-new: Add an option to create new anonymous labels

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

This is a reasonable addition.

Although, please fix the changelog entry to mention that
`org-footnote-new' is altered.

> --- 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 labels

This wording is confusing. No labels are actually created. Just
anonymous footnote. Please reword.

Also, this is a new feature and should thus be announced in
etc/ORG-NEWS.

Further, please consider adding a new #+STARTUP option to
`org-startup-options'. We already have some facilities to set
`org-footnote-auto-label' there: fnauto, fnprompt, etc.
If you do, you will also need to update the manual section "Summary of
In-Buffer Settings".

Finally, please add a test for the new option to `test-org-footnote/new'
in testing/lisp/test-org-footnote.el

-- 
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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another low-hanging fruit
       [not found]     ` <87cytc13ad.fsf@localhost>
@ 2024-02-05  6:27       ` Pedro Andres Aranda Gutierrez
  2024-02-05 14:41         ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2024-02-05  6:27 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org Mode List


[-- 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Another low-hanging fruit
  2024-02-05  6:27       ` Pedro Andres Aranda Gutierrez
@ 2024-02-05 14:41         ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2024-02-05 14:41 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: Org Mode List

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

> Fixed!
> ...
> 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

Applied, onto main, with amendments.
I changed the commit message to follow our ChangeLog entry conventions,
as described in
https://orgmode.org/worg/org-contribute.html#commit-messages
I reworded the commit message and the ORG-NEWS entry.
I also fixed the quoting in `org-startup-options'.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=10d2868c5

-- 
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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-05 15:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2024-02-05 14:41         ` Ihor Radchenko

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).