* how to renumber footnotes? @ 2020-04-17 3:58 Sharon Kimble 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor ` (2 more replies) 0 siblings, 3 replies; 16+ messages in thread From: Sharon Kimble @ 2020-04-17 3:58 UTC (permalink / raw) To: help-gnu-emacs -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Please, can someone help me sort out an org-mode footnote problem? I have 2 org-mode documents called 'file-a' and 'file-b', and both have got several hundred footnotes starting with 1. I'm adding file-b on to the end of file-a, and trying to renumber the footnotes, so that even if file-a has 354 footnotes, and file-b has 421 footnotes, the whole file renumbers the footnotes and continues on from 354 to 355, 356, 357, etc and onwards. But how can I do this please? The org-mode footnote program can't do it, so how do I do it please? (The footnote numbers I've shown are purely arbitrary, some files that I'm wanting to do this with have up to 700 footnotes in their combined files, others over a thousand!) Thanks Sharon. - -- A taste of linux = http://www.sharons.org.uk TGmeds = http://www.tgmeds.org.uk DrugFacts = https://www.drugfacts.org.uk Debian 10.2, fluxbox 1.3.7, emacs 27.0.90, org 9.3.6 -----BEGIN PGP SIGNATURE----- iQJPBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl6ZKXAbHGJvdWRpY2Nh c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbdGUP/iFn3GZOhDhpycst+Gab l9euxI1p0DB6ep0AVzMZ7Hdv7DAaE89nzG34MpXdRSds8rCCsSNz5faWbYjsyguP KfacqlJylyZTq7kHYwSd+bvh1db1QixD3fvWXy7U0SVBLxoQCwXXBuOR4eewQ0Z9 TD40qgDlEE8Vdwr7ZVYK2OY2AhQ63OFX5UnPfbPktVwTTmfn9d6dOL5tFZokzfBD 1PesQoDBya0FbngDARJsbm6WiTHjOLySsltqD1+OjPlq/2SOhTiXSaFMklZ0V1eC sNjscRUUrF7u6G+TzvwnymXRLGfcjKWeuSldW7jMBluTdW1+BSYjIQguVBmYb4N3 ukHky108mM9euneH6r1Nc74SkwZfobagAubp4v3/Tkbt/g1pATCB15xBIo79O80a QSH9cuuixy1L3lI15RDHBiCESJMpmBTHPcXPkmVv1XGky2AUhku1wJBQl/OZGNpb ZwX5rEKcRasPRtdlFDD6u5dhXaVWpN8l4wx2z0EpakkEYo6UwFyLWmMP4q0gPP/W iL4saRii9BllzXH9kuN/YDnMK94sQm2mgP+QmuoYyNYuHzqrGcYBrcM0p37JRW8P OBQdjv9EbVuhi9wPG2F+XV18Ra/DyppgrPYcT0e7vMS4XLxUARauctQEkxXbbre+ KvyPR3p1dL2XAPUkYglitEYJ =yKkV -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 3:58 how to renumber footnotes? Sharon Kimble @ 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor [not found] ` <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org> 2020-04-17 10:16 ` Sharon Kimble 2020-04-17 16:10 ` Andreas Röhler 2020-04-19 15:00 ` Andreas Röhler 2 siblings, 2 replies; 16+ messages in thread From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-04-17 4:12 UTC (permalink / raw) To: help-gnu-emacs Sharon Kimble wrote: > I have 2 org-mode documents called 'file-a' and > 'file-b', and both have got several hundred footnotes > starting with 1. I'm adding file-b on to the end of > file-a, and trying to renumber the footnotes, so that > even if file-a has 354 footnotes, and file-b has 421 > footnotes, the whole file renumbers the footnotes and > continues on from 354 to 355, 356, 357, etc > and onwards. > > But how can I do this please? The org-mode footnote > program can't do it [...] Yes, all tho I'm not an org-mode user, I'm pretty sure it can :) Else that would be plain horrible. How do you make a reference/footnote in org-mode? Because if its all good in document A, and all good in document B, you should be able to just merge A an B into a new document AB and then get correct footnotes. (here, merge = find-file AB, yank A, yank B, org-mode does its thing -> correct footnotes) -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org>]
* Re: how to renumber footnotes? [not found] ` <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org> @ 2020-04-17 6:26 ` Gijs Hillenius 2020-04-17 10:05 ` Sharon Kimble 0 siblings, 1 reply; 16+ messages in thread From: Gijs Hillenius @ 2020-04-17 6:26 UTC (permalink / raw) To: help-gnu-emacs On 17 April 2020 06:12 Emanuel Berg, wrote: > Sharon Kimble wrote: > >> I have 2 org-mode documents called 'file-a' and >> 'file-b', and both have got several hundred footnotes >> starting with 1. I'm adding file-b on to the end of >> file-a, and trying to renumber the footnotes, so that >> even if file-a has 354 footnotes, and file-b has 421 >> footnotes, the whole file renumbers the footnotes and >> continues on from 354 to 355, 356, 357, etc >> and onwards. >> >> But how can I do this please? The org-mode footnote >> program can't do it [...] I'm not seeing the whole message here, and perhaps you tried this already: "prefix argument C-c C-x f r"[enumber] and once more, with s[ort] and if so, did that not work? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 6:26 ` Gijs Hillenius @ 2020-04-17 10:05 ` Sharon Kimble 2020-04-17 12:10 ` Gijs Hillenius 0 siblings, 1 reply; 16+ messages in thread From: Sharon Kimble @ 2020-04-17 10:05 UTC (permalink / raw) To: Gijs Hillenius; +Cc: help-gnu-emacs -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Gijs Hillenius <gijs@hillenius.net> writes: > On 17 April 2020 06:12 Emanuel Berg, wrote: > >> Sharon Kimble wrote: >> >>> I have 2 org-mode documents called 'file-a' and >>> 'file-b', and both have got several hundred footnotes >>> starting with 1. I'm adding file-b on to the end of >>> file-a, and trying to renumber the footnotes, so that >>> even if file-a has 354 footnotes, and file-b has 421 >>> footnotes, the whole file renumbers the footnotes and >>> continues on from 354 to 355, 356, 357, etc >>> and onwards. >>> >>> But how can I do this please? The org-mode footnote >>> program can't do it [...] > > I'm not seeing the whole message here, and perhaps you tried this > already: > > "prefix argument C-c C-x f r"[enumber] and once more, with s[ort] > > and if so, did that not work? To achieve the footnote menu you need to do 'C-u C-c C-x f r', and neither does footnote renumber or footnote sort achieve my desired aim. org-footnote can't tell that footnote 1 ([fn:1]) at the beginning is in the right place when confronted with footnote 1 ([fn:1]) half-way through! Which is why I'm looking for some other solution, and I believe that it might be able to be achieved programmatically. Unfortunately my lisp skills are almost nil, hence my request for someone to help. Thanks Sharon. - -- A taste of linux = http://www.sharons.org.uk TGmeds = http://www.tgmeds.org.uk DrugFacts = https://www.drugfacts.org.uk Debian 10.2, fluxbox 1.3.7, emacs 27.0.90, org 9.3.6 -----BEGIN PGP SIGNATURE----- iQJPBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl6Zf2QbHGJvdWRpY2Nh c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbODMP/2v7lPYdsqMZXiHkybzN yXhs5c4TuxgGxKr5BOa7bA/nd5BipLC9zIWGGKnJLkp3+2mfyjTcjTRMiViJ4ZzP uw+bvtm816vcPPLjkd70Q/GRHi5WNYNcNIhjAYrSLY4Ue7tQPmbofYXG+xqoayau ucESW4frhn8Y3r/4cGKa/L5K47E8/tvxeeHy3FFelEf83N5PBUx50xO3RzaSqWLf J+LbNpc9kjHKYoYf+ledktbly3N7Zl6IzHgCpk6/38rHIi/RG2IvSHICdi1Fc0Nc sg0JUM7cJ4e868JXykN1jw9GqE4L3ntVZfGfiljQ5mYp/f3oo+ialzmlXr7nK9Jd 7XlhhE/l5TGPudg8bzbhTDXbVKh1DWQ4XCQ5hUZi1KIpCGKfsqV5pp7zTt6Ucv2J ENKX6+52QZ0mT+S8VJs2lhwzdK6uxY5DaAs5ECaFjq0O6VO8CbQiSipTnEK1HrSM Y5dotUtD3Nz0G+1Use+KdRyY6FUN6wRV/eH3HNSABse8KKrZjHYDqsunlATTXt/5 j7qXHr4xosQQ1JrImQtbLuMruJsLYBdfzXiH5WOQT2hH4TspvnHLu+iN/Ljkn0B+ fTkJXXutLShO7M9uvq7CJ2wRGhbdwInPtic/RhnrhR3w/wEG1Fnc55X1Uflwt6q3 flzY7P0ppgCjnlwHBbAxKywJ =Nw70 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 10:05 ` Sharon Kimble @ 2020-04-17 12:10 ` Gijs Hillenius 2020-04-17 12:45 ` Giovanni Bono 2020-04-17 12:45 ` Stephen Berman 0 siblings, 2 replies; 16+ messages in thread From: Gijs Hillenius @ 2020-04-17 12:10 UTC (permalink / raw) To: Sharon Kimble; +Cc: help-gnu-emacs [...] > org-footnote can't tell that footnote 1 ([fn:1]) at the beginning is in > the right place when confronted with footnote 1 ([fn:1]) half-way > through! Which is why I'm looking for some other solution, and I believe > that it might be able to be achieved programmatically. Unfortunately my > lisp skills are almost nil, hence my request for someone to help. Ah! Suppose file A has 372 footnotes, and B has another x. I would create a macro that I start just ahead of the second [fn:1], and that adds 372 to [fn:1] so it becomes [fn:373] and repeat that to x. It might take you a few tries, but something like put point at the second [fn:1] c-X ( to start recording the macro, search for [fn: copy the 1 (+ "yank" 273) paste (<-- I'm missing a step here, I bet), and then end the macro-recording with C-x ). ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 12:10 ` Gijs Hillenius @ 2020-04-17 12:45 ` Giovanni Bono 2020-04-17 13:53 ` Giovanni Bono 2020-04-17 12:45 ` Stephen Berman 1 sibling, 1 reply; 16+ messages in thread From: Giovanni Bono @ 2020-04-17 12:45 UTC (permalink / raw) To: Gijs Hillenius; +Cc: help-gnu-emacs, Sharon Kimble Gijs Hillenius <gijs@hillenius.net> writes: > [...] > >> org-footnote can't tell that footnote 1 ([fn:1]) at the beginning is in >> the right place when confronted with footnote 1 ([fn:1]) half-way >> through! Which is why I'm looking for some other solution, and I believe >> that it might be able to be achieved programmatically. Unfortunately my >> lisp skills are almost nil, hence my request for someone to help. > > Ah! > > Suppose file A has 372 footnotes, and B has another x. I would create a > macro that I start just ahead of the second [fn:1], and that adds 372 to > [fn:1] so it becomes [fn:373] and repeat that to x. > > It might take you a few tries, but something like put point at the > second [fn:1] c-X ( to start recording the macro, search for [fn: copy > the 1 (+ "yank" 273) paste (<-- I'm missing a step here, I bet), and > then end the macro-recording with C-x ). An even simpler manual solution could be adding a sentence with 372 footnotes at the beginning of file-b and merging the relevant part of file-b with file-a. Maybe with something like: (let ((org-footnote-define-inline t) (org-footnote-auto-adjust t)) (dotimes (x 371) (insert (concat "a [fn:" (number-to-string (1+ x)) ":a] ")))) Regards, Giovanni ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 12:45 ` Giovanni Bono @ 2020-04-17 13:53 ` Giovanni Bono 0 siblings, 0 replies; 16+ messages in thread From: Giovanni Bono @ 2020-04-17 13:53 UTC (permalink / raw) To: Gijs Hillenius; +Cc: help-gnu-emacs, Sharon Kimble Giovanni Bono <giovanni.bono@unimi.it> writes: > Gijs Hillenius <gijs@hillenius.net> writes: > >> [...] >> >>> org-footnote can't tell that footnote 1 ([fn:1]) at the beginning is in >>> the right place when confronted with footnote 1 ([fn:1]) half-way >>> through! Which is why I'm looking for some other solution, and I believe >>> that it might be able to be achieved programmatically. Unfortunately my >>> lisp skills are almost nil, hence my request for someone to help. >> >> Ah! >> >> Suppose file A has 372 footnotes, and B has another x. I would create a >> macro that I start just ahead of the second [fn:1], and that adds 372 to >> [fn:1] so it becomes [fn:373] and repeat that to x. >> >> It might take you a few tries, but something like put point at the >> second [fn:1] c-X ( to start recording the macro, search for [fn: copy >> the 1 (+ "yank" 273) paste (<-- I'm missing a step here, I bet), and >> then end the macro-recording with C-x ). > > An even simpler manual solution could be adding a sentence with 372 > footnotes at the beginning of file-b and merging the relevant part of > file-b with file-a. Maybe with something like: > > (let ((org-footnote-define-inline t) > (org-footnote-auto-adjust t)) > (dotimes (x 371) > (insert (concat "a [fn:" (number-to-string (1+ x)) ":a] ")))) > > Regards, > > Giovanni sorry, that was untested. I tried it and it does not work. The following apparently does: (let ((org-footnote-auto-adjust t) (ins 0)) (dotimes (x 371) (goto-char (+ ins (length (number-to-string x)) 5)) (insert " a ") (setq ins (point)) (call-interactively #'org-footnote-new nil [(number-to-string (1+ x))]))) The initial value of the ‘ins’ let variable should be the point where you want the sentence inserted. Regards, Giovanni ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 12:10 ` Gijs Hillenius 2020-04-17 12:45 ` Giovanni Bono @ 2020-04-17 12:45 ` Stephen Berman 1 sibling, 0 replies; 16+ messages in thread From: Stephen Berman @ 2020-04-17 12:45 UTC (permalink / raw) To: Gijs Hillenius; +Cc: help-gnu-emacs, Sharon Kimble On Fri, 17 Apr 2020 14:10:33 +0200 Gijs Hillenius <gijs@hillenius.net> wrote: > [...] > >> org-footnote can't tell that footnote 1 ([fn:1]) at the beginning is in >> the right place when confronted with footnote 1 ([fn:1]) half-way >> through! Which is why I'm looking for some other solution, and I believe >> that it might be able to be achieved programmatically. Unfortunately my >> lisp skills are almost nil, hence my request for someone to help. > > Ah! > > Suppose file A has 372 footnotes, and B has another x. I would create a > macro that I start just ahead of the second [fn:1], and that adds 372 to > [fn:1] so it becomes [fn:373] and repeat that to x. > > It might take you a few tries, but something like put point at the > second [fn:1] c-X ( to start recording the macro, search for [fn: copy > the 1 (+ "yank" 273) paste (<-- I'm missing a step here, I bet), and > then end the macro-recording with C-x ). You could also use query-replace-regexp (`C-M-%') with a Lisp expression in the replacement. E.g., if this is the result of appending file-b to file-a, with point at the position indicated with `^': ---------------------------------------------------------------------- This is a test.[fn:1] This is a test.[fn:2] This is a test.[fn:3] * Footnotes [fn:3] Note 3a [fn:2] Note 2a [fn:1] Note 1a This is a test.[fn:1] This is a test.[fn:2] This is a test.[fn:3] ^ * Footnotes [fn:3] Note 3b [fn:2] Note 2b [fn:1] Note 1b ---------------------------------------------------------------------- then type C-M-% and at the prompt enter this for the search string: \(\[fn:\)\([0-9]+\)\(\]\) then RET, then at the next prompt enter this for the replacement string: \1\,(+ \#2 3)\3 then RET and then `!' to make all replacements without confirmation. The result is this: ---------------------------------------------------------------------- This is a test.[fn:1] This is a test.[fn:2] This is a test.[fn:3] * Footnotes [fn:3] Note 3a [fn:2] Note 2a [fn:1] Note 1a This is a test.[fn:4] This is a test.[fn:5] This is a test.[fn:6] * Footnotes [fn:6] Note 3b [fn:5] Note 2b [fn:4] Note 1b ---------------------------------------------------------------------- (In the replacement string you should replace `3' in `(+ \#2 3)' with the last footnote number of file-a.) Steve Berman ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor [not found] ` <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org> @ 2020-04-17 10:16 ` Sharon Kimble 2020-04-18 1:37 ` Emanuel Berg via Users list for the GNU Emacs text editor 1 sibling, 1 reply; 16+ messages in thread From: Sharon Kimble @ 2020-04-17 10:16 UTC (permalink / raw) To: help-gnu-emacs -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes: > Sharon Kimble wrote: > >> I have 2 org-mode documents called 'file-a' and >> 'file-b', and both have got several hundred footnotes >> starting with 1. I'm adding file-b on to the end of >> file-a, and trying to renumber the footnotes, so that >> even if file-a has 354 footnotes, and file-b has 421 >> footnotes, the whole file renumbers the footnotes and >> continues on from 354 to 355, 356, 357, etc >> and onwards. >> >> But how can I do this please? The org-mode footnote >> program can't do it [...] > > Yes, all tho I'm not an org-mode user, I'm pretty sure > it can :) Else that would be plain horrible. You're right, it is horrible! org-mode cannot differentiate between [fn:1] at the beginning is different from [fn:1] halfway through! And so with all the other footnotes! > How do you make a reference/footnote in org-mode? > Because if its all good in document A, and all good in > document B, you should be able to just merge A an B into > a new document AB and then get correct footnotes. (here, > merge = find-file AB, yank A, yank B, org-mode does its > thing -> correct footnotes) I copy file-b and paste it into file-a, and the renumbering of the footnotes does not take place, for the reason I explained earlier. Hence my request for someone to help programmatically. I believe that if the script looks back at say 3 previous footnotes, stores the numbers into a string/variable, and then commences footnote renumbering from the highest number in the string/variable. So the second footnote [fn:1] is changed to [fn:315] and onwards. But I'm not a programmer, hence my request for programming help. Thanks Sharon. - -- A taste of linux = http://www.sharons.org.uk TGmeds = http://www.tgmeds.org.uk DrugFacts = https://www.drugfacts.org.uk Debian 10.2, fluxbox 1.3.7, emacs 27.0.90, org 9.3.6 -----BEGIN PGP SIGNATURE----- iQJPBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl6ZgeYbHGJvdWRpY2Nh c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbyVMP/juI1jqvxpcYNo6GM3mW biyqJ7xBrr7mRA8EM6AQK1j+cyHmwE/jU3uzsYcoqnjdQ7UVqPk8xJPWhJ3NRn3O FERjxQLslFHAoKB/lZhjAw0SCuennayXXmUaeFm21yR26U7c/S1Z3xTTCH1fxPEC doQVnsT0E93g8QRHe9UsybI6+B0OEKBg8GQIQCP0++QBZ8fojxzHRjmKCfVTRQhs 4APOe6e3w+4ZRUaf3KgJX4NUNaXka/mXFQtBByZ3UtSUnKOAzoqJqk5kti2NLNUo zZ9wlQkbVr1iDv09IVVo6izRlmsQaTX5FDfP8t/2579mAPxgsAVWkByRotl6tjqd lBE1bcrYcVZLuYqo1CsKsVSFqzN76pbhNFqs0F5yEd/f1JE4UUxHiDAi4SuHCZn9 SlJYRAzXpF8z0GDbfPGYekKxRyOLI1oHF/2d4tN01vso/X2tlrwl6N+E/HMV6fXb gLl8ePet5kusJqDl4FU2namh0YZxa8RnPXww3e2bI+9R8FrWUQxqEC6WEvFWzND9 cKv01NnWV7BkcKdQ/A9h7CLo/iIDroL7qdbXD3pxKyjKH1lUtMvBBz5KMevZ3/rg gP3VjydyHhxA1U/r58tG9wDDwgGh2bhwi+WmDDC76yEkkKDVy009F1c026rnIWNG PT0FpU2jvLMXqjFyXCVhkqlO =AIv5 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 10:16 ` Sharon Kimble @ 2020-04-18 1:37 ` Emanuel Berg via Users list for the GNU Emacs text editor 0 siblings, 0 replies; 16+ messages in thread From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-04-18 1:37 UTC (permalink / raw) To: help-gnu-emacs Sharon Kimble wrote: >> Yes, all tho I'm not an org-mode user, I'm pretty >> sure it can :) Else that would be plain horrible. > > You're right, it is horrible! org-mode cannot > differentiate between [fn:1] at the beginning is > different from [fn:1] halfway through! And so with all > the other footnotes! I see, either its poor engineering, because why would you enumerate the footnotes manually? This not only makes things difficult in your use case, it also screws things up if you want to add a footnote between say number 4 and 5. Are you then supposed to increment every single one of them from the old 5 (now a 6) to the total number of footnotes? Either that, _or_ it isn't supposed to work like that. Instead one is to assign a unique name for each footnote and then org-mode does enumeration when it is compiled to a PDF or whatever, it just looks for where the footnote is defined, if you will. Even so (the second case), it doesn't really make sense because then one would have to figure out names all the time for no reason. Instead, why not keep it all together at one place, like in LaTeX? This is a footnote: \footnote{ This is a footnote and it appears here, where it is defined, and there is no other reference or definition to it anywhere in the document. The LaTeX to PDF compiler will make sure it gets the correct number later. } And this is a reference: \cite[p. PAGE]{BOOK} Anyway what you need is a regexp search for the pattern [fn:NUMBER] and then the replace string should be the same, only NUMBER should be NUMBER + OFFSET where OFFSET is the number of footnotes in A. Apply this on the region that is the old document B. But it looks like you already got help so I'll leave it it at that... -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 3:58 how to renumber footnotes? Sharon Kimble 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-04-17 16:10 ` Andreas Röhler 2020-04-17 17:03 ` Sharon Kimble 2020-04-19 15:00 ` Andreas Röhler 2 siblings, 1 reply; 16+ messages in thread From: Andreas Röhler @ 2020-04-17 16:10 UTC (permalink / raw) To: help-gnu-emacs On 17.04.20 05:58, Sharon Kimble wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > > Please, can someone help me sort out an org-mode footnote problem? > > I have 2 org-mode documents called 'file-a' and 'file-b', and both have > got several hundred footnotes starting with 1. I'm adding file-b on to > the end of file-a, and trying to renumber the footnotes, so that even if > file-a has 354 footnotes, and file-b has 421 footnotes, the whole file > renumbers the footnotes and continues on from 354 to 355, 356, 357, etc > and onwards. > > But how can I do this please? The org-mode footnote program can't do it, > so how do I do it please? > > (The footnote numbers I've shown are purely arbitrary, some files that > I'm wanting to do this with have up to 700 footnotes in their combined Make sure there is only one footnote-section at the end of file and all fn appear in correct order: (defun ar-org-footnote-renumber-intern () (let ((c 0)) (while (re-search-forward org-footnote-re nil t) (backward-char 2) (when (looking-at "[0-9]+") (replace-match (number-to-string (cl-incf c))))))) (defun ar-org-footnote-renumber () "Renumber footnotes." (interactive "*") (save-restriction (widen) (goto-char (point-min)) (when (re-search-forward "^* Footnotes" nil t) ;; first renumber fns in text section, afterwards the ;; fn-definitions (save-restriction (narrow-to-region (point-min) (line-beginning-position)) (goto-char (point-min)) (ar-org-footnote-renumber-intern) (widen) (when (re-search-forward "^* Footnotes" nil t) (narrow-to-region (line-beginning-position) (point-max)) (goto-char (point-min)) (ar-org-footnote-renumber-intern)))))) HTH, Andreas ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 16:10 ` Andreas Röhler @ 2020-04-17 17:03 ` Sharon Kimble 2020-04-17 19:16 ` Andreas Röhler ` (2 more replies) 0 siblings, 3 replies; 16+ messages in thread From: Sharon Kimble @ 2020-04-17 17:03 UTC (permalink / raw) To: Andreas Röhler; +Cc: help-gnu-emacs -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Andreas Röhler <andreas.roehler@easy-emacs.de> writes: > On 17.04.20 05:58, Sharon Kimble wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA512 >> >> >> Please, can someone help me sort out an org-mode footnote problem? >> >> I have 2 org-mode documents called 'file-a' and 'file-b', and both have >> got several hundred footnotes starting with 1. I'm adding file-b on to >> the end of file-a, and trying to renumber the footnotes, so that even if >> file-a has 354 footnotes, and file-b has 421 footnotes, the whole file >> renumbers the footnotes and continues on from 354 to 355, 356, 357, etc >> and onwards. >> >> But how can I do this please? The org-mode footnote program can't do it, >> so how do I do it please? >> >> (The footnote numbers I've shown are purely arbitrary, some files that >> I'm wanting to do this with have up to 700 footnotes in their combined > > Make sure there is only one footnote-section at the end of file and all fn appear in correct order: > > (defun ar-org-footnote-renumber-intern () > (let ((c 0)) > (while (re-search-forward org-footnote-re nil t) > (backward-char 2) > (when (looking-at "[0-9]+") > (replace-match (number-to-string (cl-incf c))))))) > > (defun ar-org-footnote-renumber () > "Renumber footnotes." > (interactive "*") > (save-restriction > (widen) > (goto-char (point-min)) > (when (re-search-forward "^* Footnotes" nil t) > ;; first renumber fns in text section, afterwards the > ;; fn-definitions > (save-restriction > (narrow-to-region (point-min) (line-beginning-position)) > (goto-char (point-min)) > (ar-org-footnote-renumber-intern) > (widen) > (when (re-search-forward "^* Footnotes" nil t) > (narrow-to-region (line-beginning-position) (point-max)) > (goto-char (point-min)) > (ar-org-footnote-renumber-intern)))))) > Thanks Andreas, but all my footnotes are inline. Perhaps I should've said that earlier on, sorry! Perhaps I could put them at the end but I'm too tired at the moment to think about it, but plenty of time at the weekend, hooray! Thanks Sharon. - -- A taste of linux = http://www.sharons.org.uk TGmeds = http://www.tgmeds.org.uk DrugFacts = https://www.drugfacts.org.uk Debian 10.2, fluxbox 1.3.7, emacs 27.0.90, org 9.3.6 -----BEGIN PGP SIGNATURE----- iQJPBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl6Z4W8bHGJvdWRpY2Nh c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbkEYP/2dwUATppGxBm+wUz4sM KD76bdvePUB82SN5aXMEy8fBUvgs+ts/zgi/wqafh4s/HHgkxbfBftHaYqTXJXsI djcNGg84yQBZ28PKZpbpeqB52bjs5pIaUtfoQNUbto0/cS++u0GaLbf4n4nNAR6D Xu76+45RxOhlMRkJaS89GfvK4rl1ii7UMhyrx054NStQWZg/obz0ihMub7ADzdMq tajsdfo2/vWbZSk2vlFR4Wt46G334jczz7hVggh8JaIM2Z04ias+SqTfLd47sUE3 QJNAjlRMpnUhC+4Z6lC0P607bU2UKuwPut1rMk7jDds5R06SidkJCDM4T1HwUgv0 ZzSRI30Zqb28FzZ0aP9ec6hAgrADEqsqh+6ueOVR/YUOiIs0vSw2b0E65V+ZfGTP TuQQV+pzZnvPeOgaVrGcnLEOW5g6skIdC8YWbjpjkyCq+gyV0BUmu6D9jUanjZMT ZdJouKRHl/MhovcyF6mHgVF+GDvCBM6jI4nT8+iyr3ZFPCU4iLtMReItTFK66nuU 5WVrob1IVi2zr9Vu5g+ku78u7shfQ/2/rSu94uAT5egYZF8q2XUVV1BpyKdItY21 zb54mJci4W0WBOEo28f1NRJlSmFyO36SrDjnALvFYEaomSWQKSLWDhU1J/JKwZ3A Ot/8PlVpIIwQkNbgBELgRorX =akPr -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 17:03 ` Sharon Kimble @ 2020-04-17 19:16 ` Andreas Röhler 2020-04-18 6:06 ` Andreas Röhler 2020-04-18 9:00 ` Andreas Röhler 2 siblings, 0 replies; 16+ messages in thread From: Andreas Röhler @ 2020-04-17 19:16 UTC (permalink / raw) To: Sharon Kimble; +Cc: help-gnu-emacs Am 17.04.20 um 19:03 schrieb Sharon Kimble: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Andreas Röhler <andreas.roehler@easy-emacs.de> writes: > >> On 17.04.20 05:58, Sharon Kimble wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA512 >>> >>> >>> Please, can someone help me sort out an org-mode footnote problem? >>> >>> I have 2 org-mode documents called 'file-a' and 'file-b', and both have >>> got several hundred footnotes starting with 1. I'm adding file-b on to >>> the end of file-a, and trying to renumber the footnotes, so that even if >>> file-a has 354 footnotes, and file-b has 421 footnotes, the whole file >>> renumbers the footnotes and continues on from 354 to 355, 356, 357, etc >>> and onwards. >>> >>> But how can I do this please? The org-mode footnote program can't do it, >>> so how do I do it please? >>> >>> (The footnote numbers I've shown are purely arbitrary, some files that >>> I'm wanting to do this with have up to 700 footnotes in their combined >> Make sure there is only one footnote-section at the end of file and all fn appear in correct order: >> >> (defun ar-org-footnote-renumber-intern () >> (let ((c 0)) >> (while (re-search-forward org-footnote-re nil t) >> (backward-char 2) >> (when (looking-at "[0-9]+") >> (replace-match (number-to-string (cl-incf c))))))) >> >> (defun ar-org-footnote-renumber () >> "Renumber footnotes." >> (interactive "*") >> (save-restriction >> (widen) >> (goto-char (point-min)) >> (when (re-search-forward "^* Footnotes" nil t) >> ;; first renumber fns in text section, afterwards the >> ;; fn-definitions >> (save-restriction >> (narrow-to-region (point-min) (line-beginning-position)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern) >> (widen) >> (when (re-search-forward "^* Footnotes" nil t) >> (narrow-to-region (line-beginning-position) (point-max)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern)))))) >> > Thanks Andreas, but all my footnotes are inline. Perhaps I should've > said that earlier on, sorry! Was just my pleasure. Maybe send some example before/after. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 17:03 ` Sharon Kimble 2020-04-17 19:16 ` Andreas Röhler @ 2020-04-18 6:06 ` Andreas Röhler 2020-04-18 9:00 ` Andreas Röhler 2 siblings, 0 replies; 16+ messages in thread From: Andreas Röhler @ 2020-04-18 6:06 UTC (permalink / raw) To: Sharon Kimble; +Cc: help-gnu-emacs Am 17.04.20 um 19:03 schrieb Sharon Kimble: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Andreas Röhler <andreas.roehler@easy-emacs.de> writes: > >> On 17.04.20 05:58, Sharon Kimble wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA512 >>> >>> >>> Please, can someone help me sort out an org-mode footnote problem? >>> >>> I have 2 org-mode documents called 'file-a' and 'file-b', and both have >>> got several hundred footnotes starting with 1. I'm adding file-b on to >>> the end of file-a, and trying to renumber the footnotes, so that even if >>> file-a has 354 footnotes, and file-b has 421 footnotes, the whole file >>> renumbers the footnotes and continues on from 354 to 355, 356, 357, etc >>> and onwards. >>> >>> But how can I do this please? The org-mode footnote program can't do it, >>> so how do I do it please? >>> >>> (The footnote numbers I've shown are purely arbitrary, some files that >>> I'm wanting to do this with have up to 700 footnotes in their combined >> Make sure there is only one footnote-section at the end of file and all fn appear in correct order: >> >> (defun ar-org-footnote-renumber-intern () >> (let ((c 0)) >> (while (re-search-forward org-footnote-re nil t) >> (backward-char 2) >> (when (looking-at "[0-9]+") >> (replace-match (number-to-string (cl-incf c))))))) >> >> (defun ar-org-footnote-renumber () >> "Renumber footnotes." >> (interactive "*") >> (save-restriction >> (widen) >> (goto-char (point-min)) >> (when (re-search-forward "^* Footnotes" nil t) >> ;; first renumber fns in text section, afterwards the >> ;; fn-definitions >> (save-restriction >> (narrow-to-region (point-min) (line-beginning-position)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern) >> (widen) >> (when (re-search-forward "^* Footnotes" nil t) >> (narrow-to-region (line-beginning-position) (point-max)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern)))))) >> > Thanks Andreas, but all my footnotes are inline. Perhaps I should've > said that earlier on, sorry! > > Perhaps I could put them at the end but I'm too tired at the moment to > think about it, but plenty of time at the weekend, hooray! > > Thanks > Sharon. > - -- Another, simplified try: (defun ar-renumber-footnote-in-region (&optional beg end) "Renumber footnotes in active region." (interactive "*") (let ((beg (cond (beg) ((use-region-p) (region-beginning)))) (end (cond (end) ((use-region-p) (copy-marker (region-end)))))) (if (and beg end) (progn (save-restriction (narrow-to-region beg end) (goto-char (point-min)) (ar-org-footnote-renumber-intern))) (error "Need an active region to work on!")))) BTW seems footnotes are stored in reverse order if not inlined. That needs a small modification still. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 17:03 ` Sharon Kimble 2020-04-17 19:16 ` Andreas Röhler 2020-04-18 6:06 ` Andreas Röhler @ 2020-04-18 9:00 ` Andreas Röhler 2 siblings, 0 replies; 16+ messages in thread From: Andreas Röhler @ 2020-04-18 9:00 UTC (permalink / raw) To: Sharon Kimble; +Cc: help-gnu-emacs Am 17.04.20 um 19:03 schrieb Sharon Kimble: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Andreas Röhler <andreas.roehler@easy-emacs.de> writes: > >> On 17.04.20 05:58, Sharon Kimble wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA512 >>> >>> >>> Please, can someone help me sort out an org-mode footnote problem? >>> >>> I have 2 org-mode documents called 'file-a' and 'file-b', and both have >>> got several hundred footnotes starting with 1. I'm adding file-b on to >>> the end of file-a, and trying to renumber the footnotes, so that even if >>> file-a has 354 footnotes, and file-b has 421 footnotes, the whole file >>> renumbers the footnotes and continues on from 354 to 355, 356, 357, etc >>> and onwards. >>> >>> But how can I do this please? The org-mode footnote program can't do it, >>> so how do I do it please? >>> >>> (The footnote numbers I've shown are purely arbitrary, some files that >>> I'm wanting to do this with have up to 700 footnotes in their combined >> Make sure there is only one footnote-section at the end of file and all fn appear in correct order: >> >> (defun ar-org-footnote-renumber-intern () >> (let ((c 0)) >> (while (re-search-forward org-footnote-re nil t) >> (backward-char 2) >> (when (looking-at "[0-9]+") >> (replace-match (number-to-string (cl-incf c))))))) >> >> (defun ar-org-footnote-renumber () >> "Renumber footnotes." >> (interactive "*") >> (save-restriction >> (widen) >> (goto-char (point-min)) >> (when (re-search-forward "^* Footnotes" nil t) >> ;; first renumber fns in text section, afterwards the >> ;; fn-definitions >> (save-restriction >> (narrow-to-region (point-min) (line-beginning-position)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern) >> (widen) >> (when (re-search-forward "^* Footnotes" nil t) >> (narrow-to-region (line-beginning-position) (point-max)) >> (goto-char (point-min)) >> (ar-org-footnote-renumber-intern)))))) >> > Thanks Andreas, but all my footnotes are inline. Perhaps I should've > said that earlier on, sorry! > > Perhaps I could put them at the end but I'm too tired at the moment to > think about it, but plenty of time at the weekend, hooray! > > Thanks > Sharon. > - -- > A taste of linux = http://www.sharons.org.uk > TGmeds = http://www.tgmeds.org.uk > DrugFacts = https://www.drugfacts.org.uk > Debian 10.2, fluxbox 1.3.7, emacs 27.0.90, org 9.3.6 This version allows re-numbering in reverse order, as some footnote-mode seem to require. Inlined fn should be supported. Works only on active region. (defun ar-org-footnote-renumber-intern (&optional reverse) (let* ((c 0) (nav-function (if reverse 're-search-backward 're-search-forward))) (if reverse (goto-char (point-max)) (goto-char (point-min))) (while (funcall nav-function org-footnote-re nil t) (save-excursion (goto-char (match-beginning 0)) (search-forward ":") (when (looking-at "[0-9]+") (replace-match (number-to-string (cl-incf c)))))))) (defun ar-renumber-footnote-in-region (arg &optional beg end) "Renumber footnotes in active region. ARG: With \\[universal-argument] renumber in reverse order. Optional BEG: specify start position ignoring region. Optional END: specify end position ignoring region. " (interactive "*P") (save-excursion (let ((beg (cond (beg) ((use-region-p) (region-beginning)))) (end (cond (end) ((use-region-p) (copy-marker (region-end))))) (reverse (eq 4 (prefix-numeric-value arg)))) (if (and beg end) (progn (save-restriction (narrow-to-region beg end) (ar-org-footnote-renumber-intern reverse))) (error "Need an active region to work on!"))))) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: how to renumber footnotes? 2020-04-17 3:58 how to renumber footnotes? Sharon Kimble 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor 2020-04-17 16:10 ` Andreas Röhler @ 2020-04-19 15:00 ` Andreas Röhler 2 siblings, 0 replies; 16+ messages in thread From: Andreas Röhler @ 2020-04-19 15:00 UTC (permalink / raw) To: help-gnu-emacs Am 17.04.20 um 05:58 schrieb Sharon Kimble: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > > Please, can someone help me sort out an org-mode footnote problem? > > I have 2 org-mode documents called 'file-a' and 'file-b', and both have > got several hundred footnotes starting with 1. I'm adding file-b on to > the end of file-a, and trying to renumber the footnotes, so that even if > file-a has 354 footnotes, and file-b has 421 footnotes, the whole file > renumbers the footnotes and continues on from 354 to 355, 356, 357, etc > and onwards. > > But how can I do this please? The org-mode footnote program can't do it, > so how do I do it please? M-x org-footnote-renumber-fn:N RET works for me. ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-04-19 15:00 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-17 3:58 how to renumber footnotes? Sharon Kimble 2020-04-17 4:12 ` Emanuel Berg via Users list for the GNU Emacs text editor [not found] ` <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org> 2020-04-17 6:26 ` Gijs Hillenius 2020-04-17 10:05 ` Sharon Kimble 2020-04-17 12:10 ` Gijs Hillenius 2020-04-17 12:45 ` Giovanni Bono 2020-04-17 13:53 ` Giovanni Bono 2020-04-17 12:45 ` Stephen Berman 2020-04-17 10:16 ` Sharon Kimble 2020-04-18 1:37 ` Emanuel Berg via Users list for the GNU Emacs text editor 2020-04-17 16:10 ` Andreas Röhler 2020-04-17 17:03 ` Sharon Kimble 2020-04-17 19:16 ` Andreas Röhler 2020-04-18 6:06 ` Andreas Röhler 2020-04-18 9:00 ` Andreas Röhler 2020-04-19 15:00 ` Andreas Röhler
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).