From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Andreas_R=c3=b6hler?= Newsgroups: gmane.emacs.help Subject: Re: how to renumber footnotes? Date: Sat, 18 Apr 2020 08:06:55 +0200 Message-ID: References: <87v9lyvk3z.fsf@skimble.plus.com> <127dd11b-9379-361f-d315-d89882a5ac31@easy-emacs.de> <87ftd2kpsp.fsf@skimble.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="30957"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: help-gnu-emacs@gnu.org To: Sharon Kimble Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 18 08:09:19 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 1jPgfH-0007wt-38 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 08:09:19 +0200 Original-Received: from localhost ([::1]:55108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPgfG-0005Y3-3S for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 02:09:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44814) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPgd7-0005Wx-Mt for help-gnu-emacs@gnu.org; Sat, 18 Apr 2020 02:07:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPgd3-0006C5-Ao for help-gnu-emacs@gnu.org; Sat, 18 Apr 2020 02:07:03 -0400 Original-Received: from mout.kundenserver.de ([217.72.192.74]:60299) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPgd3-000608-0N for help-gnu-emacs@gnu.org; Sat, 18 Apr 2020 02:07:01 -0400 Original-Received: from [192.168.178.43] ([82.207.239.208]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MzQTm-1j3bRR0Iy0-00vRJn; Sat, 18 Apr 2020 08:06:57 +0200 In-Reply-To: <87ftd2kpsp.fsf@skimble.plus.com> Content-Language: en-US X-Provags-ID: V03:K1:qN/R1xn0owB+hX9U53/MkcYRDU3DHhXbdyHMWJEN0LXh59x3Ynl QV+sQWt9QCsmRYsoQ43WUtVVGAnQyRO/sTqICv398ctndjtGUiYSABJsCEYzXnjwgY+/Gg5 yx4a4lzxlg97NJ++3FLE07qV4KTRp9B1fms8QsORn54+1VH5vWySeiOqNfLkzef3UtlcreU 5W8pZCUW3n1HBN4tNkS9A== X-UI-Out-Filterresults: notjunk:1;V03:K0:3PuTfOYwg+I=:JBI2wXsY3NLKm8WOt+k56/ 7UROWao9mADnI+/KqXy/XTEgJox5Av7xlb6jk0A3vKfj+bKSiNnQ4GXlVbjwtmIkpsZ+XA6a0 sfA4RSu3X3n3XsJ4cqDK6g//ZRyL3d6h9ZolL5r2aR1DeesezX4LgfmapVC6SMEX+op/nYtyP Z/tJ25EGbajNF0DoULT2d/wfa3W3X0GSxiG6FxwdjsRlaIhSq1jRRBV+RDbsJt2paJfmk3QTn zbNxCiR+AF3miVWUJtec20Bqs7lCyGEvpkx3xKAP3KVZ8/Kkny3I0oxUX6Tu/nYpXU8/0Gx1n LZRWqsWiKOuI4MqGV+Rfj8VnZSjzT5k4eO+GYHTJ/23lIG4FFUU6ev2BfNrDUOI5yd6fYV/6S Ybo9WcAU7NwkpbxbYqzcQtbqe/b1nEGehwyFt6CkkcXOh66p96Rr444LQ9Bq2USg1OTIQM2kY 9r8+WOVT/miuKZGzOiKcTPBu8Dy3M76s/IXCveuEoCw89Kd42zB5EE4HpBxM5Xe1didEDN3Pb DNH44DY7MqGH9l5OR07VTJOXbtADbhgmIOncz5ReCiFfCZjdqtxW3IyHxR6Sq62UionbN7DRo nIZ62mehJBUNUUSfqG9HVjvd49CLcN5bhZnZKw2VW22fkyhGF5XWi1eF9+v/Yg8IhCRZA8ocs iSGWEFuAMBo7ZJHxSXXrmkkLsmwt3yu5rLVxQNBLfwxRqMXIKRWYC2g1PGqc/7LjJA0XuGzFN 0jsuG8nqCz9ETxp2icM0u+wTBH7EEtzchZGjwmtnbVOMd+MOIhcD2hPzuksGUxiDr9dh/cXX X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.74 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:122878 Archived-At: Am 17.04.20 um 19:03 schrieb Sharon Kimble: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Andreas Röhler 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.