* Fwd: Re: how to renumber footnotes?
[not found] ` <87d086s8q3.fsf@fastmail.fm>
@ 2020-04-18 7:14 ` Joost Kremers
2020-04-18 15:53 ` Kyle Meyer
0 siblings, 1 reply; 2+ messages in thread
From: Joost Kremers @ 2020-04-18 7:14 UTC (permalink / raw)
To: Org Mode
Accidentally sent this message off-list. Trying again:
On Fri, Apr 17 2020, Sharon Kimble 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!
No, obviously, so you'll have to renumber the footnotes in the
second file
before you merge the two files.
> 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.
I use the following function for renumbering stuff such as
footnotes:
#+begin_src emacs-lisp
(defun jk-renumber-counters (start regexp)
"Renumber counters.
Renumbering starts at START. REGEXP describes the counters to be
renumbered. The actual number must be enclosed in a group."
(save-excursion
(goto-char (point-min))
;; because we incf the counter before using it, we need to
adjust:
(let ((counter (1- start))
(counters (make-hash-table :test 'equal))
fn)
(while (re-search-forward regexp nil t)
(setq fn (match-string 1))
(replace-match (or (gethash fn counters)
(puthash fn (format "%s" (cl-incf
counter)) counters))
nil nil nil 1)))))
#+end_src
In your case, you should be able to call this function with:
M-: (jk-renumber-footnotes 355 "\\[fn:\\([0-9]+\\)\\]") RET
Change «355» to the number you want to start the footnotes in the
second file
with.
If you already merged the two files and don't want to separate
them again, you
could take out the line `(goto-char (point-min))`, put point at
the position
where you want to start renumbering footnotes and then call the
function. But
I'd play it safe and renumber the footnotes before merging the
files.
HTH
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fwd: Re: how to renumber footnotes?
2020-04-18 7:14 ` Fwd: Re: how to renumber footnotes? Joost Kremers
@ 2020-04-18 15:53 ` Kyle Meyer
0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2020-04-18 15:53 UTC (permalink / raw)
To: Joost Kremers; +Cc: emacs-orgmode, Sharon Kimble
Joost Kremers <joostkremers@fastmail.fm> writes:
> Accidentally sent this message off-list. Trying again:
Hmm I didn't find any of the six messages in the References: header when
I searched <https://lists.gnu.org/archive/html/emacs-orgmode/>. I see
the same messages missing in the thread displayed at
<https://yhetil.org/orgmode/87imhxnu3x.fsf@fastmail.fm/T/#u>. So it
looks like a lot of this thread went off list, or at least is very
delayed in the pipeline.
I guess this thread was related but separate from Sharon's "Subject:
org-footnote renumbering" post at
<https://yhetil.org/orgmode/87y2r71ibd.fsf@skimble.plus.com/>.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-18 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <87v9lyvk3z.fsf@skimble.plus.com>
[not found] ` <87mu7aycm5.fsf@ebih.ebihd>
[not found] ` <mailman.453.1587096748.3066.help-gnu-emacs@gnu.org>
[not found] ` <87a73aaar5.fsf@hillenius.net>
[not found] ` <87a73av34s.fsf@skimble.plus.com>
[not found] ` <87d086s8q3.fsf@fastmail.fm>
2020-04-18 7:14 ` Fwd: Re: how to renumber footnotes? Joost Kremers
2020-04-18 15:53 ` Kyle Meyer
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).