From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Roehler Newsgroups: gmane.emacs.devel Subject: Re: footnote-style latin doesn't renumber Date: Mon, 16 Apr 2007 14:00:13 +0200 Message-ID: <4623654D.20804@easy-emacs.de> References: <461C8F10.3090009@easy-emacs.de> <461CD911.7070000@gmx.at> <461DD6B6.3070403@easy-emacs.de> <461DEAE7.4090209@gmx.at> <461E6404.60309@easy-emacs.de> <461E9B39.7030305@gmx.at> <461F77F5.3080501@easy-emacs.de> <462097DC.1060707@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1176724815 1377 80.91.229.12 (16 Apr 2007 12:00:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Apr 2007 12:00:15 +0000 (UTC) Cc: Chong Yidong , "Stephen J. Turnbull" , Richard Stallman , Stefan Monnier , emacs-devel To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 16 14:00:08 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HdPsN-0006Jm-MN for ged-emacs-devel@m.gmane.org; Mon, 16 Apr 2007 14:00:08 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdPwy-0004jS-V2 for ged-emacs-devel@m.gmane.org; Mon, 16 Apr 2007 08:04:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HdPvu-0003ec-Jm for emacs-devel@gnu.org; Mon, 16 Apr 2007 08:03:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HdPvt-0003dT-C5 for emacs-devel@gnu.org; Mon, 16 Apr 2007 08:03:45 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdPvs-0003d4-V5 for emacs-devel@gnu.org; Mon, 16 Apr 2007 08:03:45 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.171]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HdPrF-0002rK-Pp; Mon, 16 Apr 2007 07:58:58 -0400 Original-Received: from [84.190.199.87] (helo=[192.168.178.25]) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), id 0MKwtQ-1HdPqF2anq-0004fg; Mon, 16 Apr 2007 13:57:58 +0200 User-Agent: Thunderbird 1.5.0.4 (X11/20060516) In-Reply-To: <462097DC.1060707@gmx.at> X-Provags-ID: V01U2FsdGVkX184j8L+KOpEiBLh4AvrtjFjdnb1XuS0TLAA5bB PwYnh/dohEEpDA9RsF74UC5niji+Qkp6i5YimpvVpdDV+U5LTz +uG4jvlxnvCDR4fhZhg4A== X-detected-kernel: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69489 Archived-At: Herewith correct renumbering of already existing footnotes should be possible. Footnote-init reads in existing footnodes. Customize `footnote-mode-hook' with this function should do the right thing when footnote-mode is switched on. Footnote-init.el needs a patched footnote.el. This patch IMO is needed in any case, to get renumbering work so far. Patch below. Andreas Roehler BTW Is footnote.el at the right place in /mail? IMO it's a text-mode. *** footnote.el Mon Apr 16 10:03:44 2007 --- footnote.el Mon Apr 16 11:26:30 2007 *************** *** 360,365 **** --- 360,368 ---- (let ((i 0) alist) (while (setq alist (nth i footnote-text-marker-alist)) (goto-char (cdr alist)) + ;; 2007-04-16 a.roehler@web.de changed section start + (search-backward footnote-start-tag nil t) + ;; 2007-04-16 a.roehler@web.de changed section end (when (looking-at (concat (regexp-quote footnote-start-tag) "\\(" index-regexp "\\)" *************** *** 437,442 **** --- 440,448 ---- footnote-end-tag))) (setq posn-list (cdr posn-list))) (goto-char (cdr text-alist)) + ;; 2007-04-16 a.roehler@web.de changed section start + (search-backward footnote-start-tag nil t) + ;; 2007-04-16 a.roehler@web.de changed section end (when (looking-at (format "%s%s%s" (regexp-quote footnote-start-tag) (Footnote-current-regexp) ;;;;;;;;;;; patch ends here ;;; footnote-init.el --- Reads in existing footnotes ;; Copyright (C) 2007 Andreas Roehler ;; Author: Andreas Roehler ;; Keywords: wp, mail, news ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: Provides a `footnote-init' usable as ;;; footnote-mode-hook, which reads in existing ;;; footnodes. Customize `footnote-mode-hook' with this ;;; function should do the right thing when switching ;;; footnote-mode on. ;; ;;; Code: (defvar footnote-regexp nil "`footnote-regexp' in effect after `footnote-init' is called Possible values are defined in footnote-style-alist: `footnote-numeric-regexp', footnote-english-lower-regexp etc. ") (defun footnote-init (&optional ispec) "Let's footnote take notice of already existing footnotes" (interactive "p") (unless footnote-mode (footnote-mode)) (let ((documents-footnote-style (footnote-what-style ispec))) (setq footnote-regexp (concat (nth 2 documents-footnote-style) "+")) (footnote-init-markers t) (Footnote-set-style (nth 0 documents-footnote-style)))) (defun footnote-what-style (&optional ispec) "Returns style in effect according footnote-style-alist: default is (numeric Footnote-numeric ,footnote-numeric-regexp)" (interactive "p") (let((length-fn-start-tag (length footnote-start-tag)) (length-fn-end-tag (length footnote-end-tag)) style-in-effect found) (save-excursion (goto-char (point-min)) (search-forward footnote-start-tag nil t 1) (goto-char (match-beginning 0)) (setq found (buffer-substring-no-properties (+ length-fn-start-tag (point)) (- (re-search-forward footnote-end-tag (line-end-position) t 1) length-fn-end-tag))) (dolist (styles footnote-style-alist) (when (string-match (nth 2 styles) found) (setq style-in-effect styles))) (when ispec (message "Footnote style in effect: %s" style-in-effect))) style-in-effect)) (defun footnote-init-markers (&optional ispec) " " (interactive "p") (save-excursion (let ((count 0) (footnote-section-tag-pos (or (search-forward footnote-section-tag nil t 1) (re-search-forward footnote-section-tag-regexp nil t 1)))) (goto-char (point-min)) (while (re-search-forward (concat footnote-start-tag footnote-regexp footnote-end-tag) footnote-section-tag-pos t 1) (setq count (1+ count)) (Footnote-insert-pointer-marker count (point))) (setq count 0) (while (re-search-forward (concat footnote-start-tag footnote-regexp footnote-end-tag) nil t 1) (setq count (1+ count)) (Footnote-insert-text-marker count (point))) (when ispec (message "footnote-pointer-marker-alist: %s\nfootnote-text-marker-alist: %s" footnote-pointer-marker-alist footnote-text-marker-alist)) footnote-pointer-marker-alist footnote-text-marker-alist))) (provide 'footnote-init) ;;; footnote-init.el ends here