From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 61QmG4mpml6OPAAA0tVLHw (envelope-from ) for ; Sat, 18 Apr 2020 07:17:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AJryBI6pml7GTgAAbx9fmQ (envelope-from ) for ; Sat, 18 Apr 2020 07:17:34 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 870BF941CCC for ; Sat, 18 Apr 2020 07:17:32 +0000 (UTC) Received: from localhost ([::1]:55462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPhjG-0006xK-4E for larch@yhetil.org; Sat, 18 Apr 2020 03:17:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33541) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPhgS-0006wo-LJ for emacs-orgmode@gnu.org; Sat, 18 Apr 2020 03:14:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPhgR-0003KB-B9 for emacs-orgmode@gnu.org; Sat, 18 Apr 2020 03:14:36 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:39485) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jPhgO-0002rE-TN for emacs-orgmode@gnu.org; Sat, 18 Apr 2020 03:14:35 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 58A8A5C0086 for ; Sat, 18 Apr 2020 03:14:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 18 Apr 2020 03:14:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=fm2; bh=PN0xnsoIAomGb l8mI22BY75XQ59VMrssedvUdF6h/jY=; b=Ekk22zhMjlIl/JvDcQotgiHU+Cx+X myuPP8RqGUM8sIstsS/WedCaGnwm+bxCxET8TjrdRyhOWAjvYuWTrLRoiF+hKPlJ 4F2rDwPGeWAaJKGSWtgIyb4yB1FNsrn9VO21YD7BOEWfYhZ2w+ZfKTI24lQarfQN rKJ1FHYnI9CGxNzr9evade3zwFerqeevem23nBzHyry0ebtnuwfyXgoYT+K4hdvV wqyJKrgb/tDotHnuJAEXKdtkubQloIUZB5VnyNVbVZEimDvbx8rUeZOGQ5TI0G+g Dg/urDcrSfGAsKbKFnUSPhLVj6yvTDvyp0HNQ0bto7hkspWSm622CTHfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=PN0xnsoIAomGbl8mI22BY75XQ59VMrssedvUdF6h/jY=; b=kSxtIVNG zDvGarPlwPck463Yc49nEOgJVwU6pgyqF+ujCgL4QW5DzMdqXqHEecsfWweNocY9 n6Ye/uSax1unIxSXcYpOku1qAiCb7F+M6s7Ym3++MnuvrScjTYU4BPpKNcHZLsDk bJvi3Uyxey/XnzClR4ZewE0dZd+iPvM6+6GanJI92HBCIJ9H2tZmP3qEWC6sCCwf lxMVIBRSVVp1lYjhwppV8rq3kFBThgfFUb9gtQU5hPt7BtZk5Dn5GhcdpUO3QbQI GtZwOmaG4/RwhZye2Rm8K7kpJwCHjYhDPomLcchKWfuvVkljra8h/Z6R6yj0d0cS vU+2Nt3rzLCrrw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfeekgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvufffkfggtgfgsehtqhertddtreejnecuhfhrohhmpeflohhoshht ucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhmqe enucfkphepleehrdeltddrvddtuddriedvnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilh drfhhm X-ME-Proxy: Received: from Lenovo.fastmail.com (ip5f5ac93e.dynamic.kabel-deutschland.de [95.90.201.62]) by mail.messagingengine.com (Postfix) with ESMTPA id DDF00306005F for ; Sat, 18 Apr 2020 03:14:29 -0400 (EDT) References: <87v9lyvk3z.fsf@skimble.plus.com> <87mu7aycm5.fsf@ebih.ebihd> <87a73aaar5.fsf@hillenius.net> <87a73av34s.fsf@skimble.plus.com> <87d086s8q3.fsf@fastmail.fm> User-agent: mu4e 1.3.10; emacs 27.0.90 From: Joost Kremers To: Org Mode Subject: Fwd: Re: how to renumber footnotes? Date: Sat, 18 Apr 2020 09:14:26 +0200 Message-ID: <87imhxnu3x.fsf@fastmail.fm> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.81 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fastmail.fm header.s=fm2 header.b=Ekk22zhM; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=kSxtIVNG; dmarc=pass (policy=none) header.from=fastmail.fm; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.81 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.57465572930098]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[fastmail.fm]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.25), country: US(-0.01), ip: 209.51.188.17(-0.57)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; DKIM_TRACE(0.00)[fastmail.fm:+,messagingengine.com:+]; DMARC_POLICY_ALLOW(-0.50)[fastmail.fm,none]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[95.90.201.62:received]; RCVD_IN_DNSWL_LOW(-0.10)[209.51.188.17:from]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[joostkremers@fastmail.fm,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[fastmail.fm:s=fm2,messagingengine.com:s=fm2]; URIBL_BLOCKED(0.00)[messagingengine.com:dkim,fastmail.fm:dkim]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[fastmail.fm:dkim]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: bVYGLSXF9Z+5 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=20 > beginning is in > the right place when confronted with footnote 1 ([fn:1])=20 > half-way > through! No, obviously, so you'll have to renumber the footnotes in the=20 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.=20 > Unfortunately my > lisp skills are almost nil, hence my request for someone to=20 > help. I use the following function for renumbering stuff such as=20 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=20 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 =C2=AB355=C2=BB to the number you want to start the footnotes in the= =20 second file with. If you already merged the two files and don't want to separate=20 them again, you could take out the line `(goto-char (point-min))`, put point at=20 the position where you want to start renumbering footnotes and then call the=20 function. But I'd play it safe and renumber the footnotes before merging the=20 files. HTH --=20 Joost Kremers Life has its moments