From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: how to renumber footnotes? Date: Fri, 17 Apr 2020 14:45:41 +0200 Message-ID: <87v9ly46x6.fsf@gmx.net> References: <87v9lyvk3z.fsf@skimble.plus.com> <87mu7aycm5.fsf@ebih.ebihd> <87a73aaar5.fsf@hillenius.net> <87a73av34s.fsf@skimble.plus.com> <87y2qu8g92.fsf@hillenius.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="110470"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org, Sharon Kimble To: =?utf-8?Q?G=C4=B3s?= Hillenius Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 17 14:49:18 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPQQn-000San-8a for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 17 Apr 2020 14:49:17 +0200 Original-Received: from localhost ([::1]:46822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPQQm-0001yH-2j for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 17 Apr 2020 08:49:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57831) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPQNV-0001yA-Rc for help-gnu-emacs@gnu.org; Fri, 17 Apr 2020 08:45:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPQNU-0005Mp-M8 for help-gnu-emacs@gnu.org; Fri, 17 Apr 2020 08:45:53 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:47959) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPQNU-0005Lm-AC for help-gnu-emacs@gnu.org; Fri, 17 Apr 2020 08:45:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1587127542; bh=1M3VkpImJ+nHmgZZw1Oq8CwDp6Zmz50Rdi7n5ib0dBs=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=UzmaFkwaACANQTGIppOiVlfQsoTX064BrwUSj6conNLR8cS8ye4OoULXOaxgUMU/h A89DXC9R2hYR6tGlHoqYjn6cR9EbBwL+dWyzjXb9tDRD03jd3d29HikFGHHqDIPCpz GVKUN0qbI07FsxB+9agAgYwwpI7+2+A0c/Y/BGCE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobe-jhalfs ([188.109.155.11]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MsYqv-1j5qKD2ZHn-00u0eq; Fri, 17 Apr 2020 14:45:42 +0200 In-Reply-To: <87y2qu8g92.fsf@hillenius.net> (=?utf-8?Q?=22G=C4=B3s?= Hillenius"'s message of "Fri, 17 Apr 2020 14:10:33 +0200") X-Provags-ID: V03:K1:sZhcVVNBjG1FGQ0qCVHVZVg6ZtVXQB/63ec1C8t4UJ0FPVOuy0L VLRah62sYsfFpoCCOe53cdH/meJ/q7zPANCpJ4rky3bfTQS7mB4g+L+rKEwG8naJWv+NEge vR+eG5QIjjw6b+z2sIn4AIZH5LesWLXgiBXEMZuX+V8kAzAhqS+csSa0gM/PS0ukvOyEy+R beyDFhEIMbiwtmVhY8XPw== X-UI-Out-Filterresults: notjunk:1;V03:K0:gETEEIAaRmM=:DV2CQnbJnZmLVyJsjA5xC8 T4A1aa+6W+fOvhehYjMVnAUTyoq6dm1q0v/CnW7xMrrRUiIfOLOofOnYK9PVpproDASZ4sIwv UMXIMi1d8NTEynU1aYHJynsmIuBkP68LH0WJCgZF0YQmPpbI8ITVgayX0FUZMjH2G8SoFRg6/ AY9RfQ48wOzEzEWARpNxLzKxtyEvd8am9036aP5qoeYGWUtmP/JRRwimmEvEYj/F0P9k4GoHJ vwVTM2nOiFiqhJ5u0p+H7hoekJ+RGKUFbPuYdArzGE21AhEk24dQhlHYG4k5yzr5LC2vcZHA8 eBm06Q9e5tOcsTWDOCgHIwPLzLRix6VstFPlkGmKWqlKo5YLMbKm8V+zxpVyv7HjWzPit2nwI Rxx14zjyb/5gjHb/2BxBtv+vjtBDNuHaqz8S06++n3bP6ny5Vc4srK56o1tzfefHLWGi62lit v1G0G14gjgyClw1g7c+gy3s5mKh5D0fAGrg1T/MXvylPy+BsKmWMcPv80bh/Yc+aHWLQbstP5 JVlJ4g4i4yVKcjXKjbQrHbZEQXFtcXNN3EzQLz3jHNIuHFV9oGBuidmB3raGdUGrvZgqgJQU5 S3R134HGrk/KUWL3IrFjUiDwHzaX134RERPm/amuH3k0UqZq9VVEZLYEdHqRUZZ9f7Dba/mHl D15CpPh0yiQ6jYasmx3nROKLsPbVH9mQiYWh7UtX5bu3BcZ2tsbR9CojePBjMFjejC7e+pxZJ QGUd/15XlGYPUZ7CRj62NCREuQRkyHsDo7wnszUpD1QP+iZ3w4dn+sC4AoDePzq97Ml46rDH X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.18 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122864 Archived-At: On Fri, 17 Apr 2020 14:10:33 +0200 G=C4=B3s Hillenius = 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=20 [fn:2] Note 2a=20 [fn:1] Note 1a=20 This is a test.[fn:1] This is a test.[fn:2] This is a test.[fn:3] ^ * Footnotes [fn:3] Note 3b=20 [fn:2] Note 2b=20 [fn:1] Note 1b=20 ---------------------------------------------------------------------- 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=20 [fn:2] Note 2a=20 [fn:1] Note 1a=20 This is a test.[fn:4] This is a test.[fn:5] This is a test.[fn:6] * Footnotes [fn:6] Note 3b=20 [fn:5] Note 2b=20 [fn:4] Note 1b=20 ---------------------------------------------------------------------- (In the replacement string you should replace `3' in `(+ \#2 3)' with the last footnote number of file-a.) Steve Berman