help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to renumber footnotes?


From: Giovanni Bono
Subject: Re: how to renumber footnotes?
Date: Fri, 17 Apr 2020 15:53:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]