annotate lisp/mail/footnote.el @ 100267:c851df8e004e

2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-goto-calendar): Remove duplicate let bindings of calendar variables. * org-table.el (org-table-find-row-type): Renamed from `org-find-row-type'. (org-table-rewrite-old-row-references): Renamed from `org-rewrite-old-row-references'. (org-table-shift-refpart): Renamed from `org-shift-refpart'. (org-table-cleanup-narrow-column-properties): Renamed from `org-cleanup-narrow-column-properties'. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-find-row-type): New arguments DESC and CLINE, for better error messages. (org-table-get-descriptor-line): Supply the new arguments to `org-find-row-type'. (org-table-error-on-row-ref-crossing-hline): New option. * org.el (org-target-link-regexp): Make buffer-local. (org-move-subtree-down): Fix bug with trees at beginning of buffer. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-faces.el (org-set-tag-faces): New function. (org-tags-special-faces-re): New variable. * org.el (org-font-lock-add-tag-faces, org-get-tag-face): New functions. * org-faces.el (org-tag-faces): New option. (org-tag): Mention `org-tag-faces' in the docstring. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-style-default): Implement new quoting. * org-jsinfo.el (org-infojs-template): Implement new quoting. * org-w3m.el (w3m-minor-mode-hook): Also add the special copy command to the `w3m-minor-mode-map'. * org-archive.el (org-archive-to-archive-sibling): Protect `this-command' to avoid appending kills during archiving. * org-exp.el (org-export-with-priority): New variable. (org-export-add-options-to-plist): Use `org-export-plist-vars' instead of internal list of strings and properties. (org-print-icalendar-entries): Retrieve the location property with inheritance. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-with-todo-keywords): New option. (org-export-plist-vars): Include also the keys for the #+OPTIONS line. (org-default-export-plist, org-export-add-options-to-plist) (org-export-as-ascii, org-export-as-html): Use the new structure of `org-export-plist-vars'. * org.el (org-map-entries): Return all values. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-matcher-time): Recognize more special values. * org-gnus.el (fboundp): Fix defvaralias for XEmacs. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-tags-exclude-from-inheritance): New option. (org-tag-inherit-p, org-remove-uniherited-tags): Respect `org-tags-exclude-from-inheritance'. * org-agenda.el (org-agenda-show-inherited-tags): New option. (org-format-agenda-item): Add inherited tags to the agenda line string, and make sure that properties are kept when downcasing the tags list. (org-agenda-add-inherited-tags): New function. (org-downcase-keep-props): New function. * org.el (org-scan-tags): Mark inherited tags with a text property. (org-get-tags-at): Mark inherited tags with a text property. (org-add-prop-inherited): New function. * org-agenda.el (org-agenda-add-inherited-tags): New function. (org-agenda-show-inherited-tags): New option. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-modules): Add org-w3m to the default modules. * org-table.el (orgtbl-self-insert-command): Make S-SPC work in orgtbl-mode. (orgtabl-create-or-convert-from-region): New command. * org-exp.el (org-export-as-ascii): Remove the handling of targets. (org-export-ascii-preprocess): Handle targets already in this function. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-timer.el (org-timer-start-time): Define this variable. (org-timer-item): Make argument optional. * org-list.el (org-insert-item): Automatically insert a timer item if the current list is a timer list. * org-timer.el: New file. * org-publish.el (org-publish-org-index): Only exclude the index file in the main directory from being added to the site-map. (org-publish-get-project-from-filename): If the current project is a component, start publishing from the parent project. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (orgtbl-ret): Fix RET at beginning-of-buffer. * org-publish.el (org-publish-org-index): Improve removal of temporary buffers.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 07 Dec 2008 18:36:02 +0000
parents 647e1c7496bf
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 27830
diff changeset
1 ;;; footnote.el --- footnote support for message mode -*- coding: iso-latin-1;-*-
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
2
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004,
79712
de499b20517a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79632
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
5
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Author: Steven L Baur <steve@xemacs.org>
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
7 ;; Keywords: mail, news
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
8 ;; Version: 0.19
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
9
26815
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
10 ;; This file is part of GNU Emacs.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
11
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; (at your option) any later version.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
16
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
20 ;; GNU General Public License for more details.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
21
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
24
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
26
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;; This file provides footnote[1] support for message-mode in emacsen.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
28 ;; footnote-mode is implemented as a minor mode.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
29
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
30 ;; [1] Footnotes look something like this. Along with some decorative
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; stuff.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
32
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
33 ;; TODO:
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
34 ;; Reasonable Undo support.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
35 ;; more language styles.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
36
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
37 ;;; Code:
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
38
26815
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
39 (eval-when-compile
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
40 (require 'cl)
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
41 (defvar filladapt-token-table))
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
42
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
43 (defgroup footnote nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
44 "Support for footnotes in mail and news messages."
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
45 :version "21.1"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
46 :group 'message)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
47
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
48 (defcustom footnote-mode-line-string " FN"
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
49 "String to display in modes section of the mode-line."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
50 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
51
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
52 (defcustom footnote-mode-hook nil
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
53 "Hook functions run when footnote-mode is activated."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
54 :type 'hook
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
55 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
56
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
57 (defcustom footnote-narrow-to-footnotes-when-editing nil
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
58 "If non-nil, narrow to footnote text body while editing a footnote."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
59 :type 'boolean
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
60 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
61
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
62 (defcustom footnote-prompt-before-deletion t
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
63 "If non-nil, prompt before deleting a footnote.
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
64 There is currently no way to undo deletions."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
65 :type 'boolean
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
66 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
67
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
68 (defcustom footnote-spaced-footnotes t
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
69 "If non-nil, insert an empty line between footnotes.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
70 Customizing this variable has no effect on buffers already
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
71 displaying footnotes."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
72 :type 'boolean
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
73 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
74
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
75 (defcustom footnote-use-message-mode t ; Nowhere used.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
76 "If non-nil, assume Footnoting will be done in `message-mode'."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
77 :type 'boolean
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
78 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
79
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
80 (defcustom footnote-body-tag-spacing 2
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
81 "Number of spaces separating a footnote body tag and its text.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
82 Customizing this variable has no effect on buffers already
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
83 displaying footnotes."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
84 :type 'integer
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
85 :group 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
86
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
87 (defvar footnote-prefix [(control ?c) ?!]
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
88 "*When not using `message-mode', the prefix to bind in `mode-specific-map'")
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
89
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
90 ;;; Interface variables that probably shouldn't be changed
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
91
56448
b56847dec7b7 (footnote-section-tag): Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
92 (defcustom footnote-section-tag "Footnotes: "
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
93 "Tag inserted at beginning of footnote section.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
94 If you set this to the empty string, no tag is inserted and the
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
95 value of `footnote-section-tag-regexp' is ignored. Customizing
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
96 this variable has no effect on buffers already displaying
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
97 footnotes."
56448
b56847dec7b7 (footnote-section-tag): Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
98 :type 'string
b56847dec7b7 (footnote-section-tag): Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
99 :group 'footnote)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
100
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
101 (defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
102 "Regexp which indicates the start of a footnote section.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
103 This variable is disregarded when `footnote-section-tag' is the
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
104 empty string. Customizing this variable has no effect on buffers
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
105 already displaying footnotes."
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
106 :type 'regexp
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
107 :group 'footnote)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
108
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
109 ;; The following three should be consumed by footnote styles.
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
110 (defcustom footnote-start-tag "["
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
111 "String used to denote start of numbered footnote.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
112 Should not be set to the empty string. Customizing this variable
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
113 has no effect on buffers already displaying footnotes."
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
114 :type 'string
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
115 :group 'footnote)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
116
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
117 (defcustom footnote-end-tag "]"
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
118 "String used to denote end of numbered footnote.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
119 Should not be set to the empty string. Customizing this variable
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
120 has no effect on buffers already displaying footnotes."
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
121 :type 'string
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
122 :group 'footnote)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
123
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
124 (defvar footnote-signature-separator (if (boundp 'message-signature-separator)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
125 message-signature-separator
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
126 "^-- $")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
127 "*String used to recognize .signatures.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
128
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
129 ;;; Private variables
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
130
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
131 (defvar footnote-style-number nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
132 "Footnote style represented as an index into footnote-style-alist.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
133 (make-variable-buffer-local 'footnote-style-number)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
134
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
135 (defvar footnote-text-marker-alist nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
136 "List of markers pointing to text of footnotes in message buffer.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
137 (make-variable-buffer-local 'footnote-text-marker-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
138
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
139 (defvar footnote-pointer-marker-alist nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
140 "List of markers pointing to footnote pointers in message buffer.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
141 (make-variable-buffer-local 'footnote-pointer-marker-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
142
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
143 (defvar footnote-mouse-highlight 'highlight
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
144 "Text property name to enable mouse over highlight.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
145
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
146 (defvar footnote-mode nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
147 "Variable indicating whether footnote minor mode is active.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
148 (make-variable-buffer-local 'footnote-mode)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
149
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
150 ;;; Default styles
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
151 ;;; NUMERIC
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
152 (defconst footnote-numeric-regexp "[0-9]+"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
153 "Regexp for digits.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
154
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
155 (defun Footnote-numeric (n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
156 "Numeric footnote style.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
157 Use Arabic numerals for footnoting."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
158 (int-to-string n))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
159
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
160 ;;; ENGLISH UPPER
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
161 (defconst footnote-english-upper "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
162 "Upper case English alphabet.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
163
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
164 (defconst footnote-english-upper-regexp "[A-Z]+"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
165 "Regexp for upper case English alphabet.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
166
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
167 (defun Footnote-english-upper (n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
168 "Upper case English footnoting.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
169 Wrapping around the alphabet implies successive repetitions of letters."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
170 (let* ((ltr (mod (1- n) (length footnote-english-upper)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
171 (rep (/ (1- n) (length footnote-english-upper)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
172 (chr (char-to-string (aref footnote-english-upper ltr)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
173 rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
174 (while (>= rep 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
175 (setq rc (concat rc chr))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
176 (setq rep (1- rep)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
177 rc))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
178
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
179 ;;; ENGLISH LOWER
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
180 (defconst footnote-english-lower "abcdefghijklmnopqrstuvwxyz"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
181 "Lower case English alphabet.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
182
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
183 (defconst footnote-english-lower-regexp "[a-z]+"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
184 "Regexp of lower case English alphabet.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
185
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
186 (defun Footnote-english-lower (n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
187 "Lower case English footnoting.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
188 Wrapping around the alphabet implies successive repetitions of letters."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
189 (let* ((ltr (mod (1- n) (length footnote-english-lower)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
190 (rep (/ (1- n) (length footnote-english-lower)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
191 (chr (char-to-string (aref footnote-english-lower ltr)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
192 rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
193 (while (>= rep 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
194 (setq rc (concat rc chr))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
195 (setq rep (1- rep)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
196 rc))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
197
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
198 ;;; ROMAN LOWER
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
199 (defconst footnote-roman-lower-list
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
200 '((1 . "i") (5 . "v") (10 . "x")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
201 (50 . "l") (100 . "c") (500 . "d") (1000 . "m"))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
202 "List of roman numerals with their values.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
203
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
204 (defconst footnote-roman-lower-regexp "[ivxlcdm]+"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
205 "Regexp of roman numerals.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
206
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
207 (defun Footnote-roman-lower (n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
208 "Generic Roman number footnoting."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
209 (Footnote-roman-common n footnote-roman-lower-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
210
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
211 ;;; ROMAN UPPER
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
212 (defconst footnote-roman-upper-list
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
213 '((1 . "I") (5 . "V") (10 . "X")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
214 (50 . "L") (100 . "C") (500 . "D") (1000 . "M"))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
215 "List of roman numerals with their values.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
216
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
217 (defconst footnote-roman-upper-regexp "[IVXLCDM]+"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
218 "Regexp of roman numerals. Not complete")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
219
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
220 (defun Footnote-roman-upper (n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
221 "Generic Roman number footnoting."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
222 (Footnote-roman-common n footnote-roman-upper-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
223
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
224 (defun Footnote-roman-common (n footnote-roman-list)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
225 "Lower case Roman footnoting."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
226 (let* ((our-list footnote-roman-list)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
227 (rom-lngth (length our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
228 (rom-high 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
229 (rom-low 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
230 (rom-div -1)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
231 (count-high 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
232 (count-low 0))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
233 ;; find surrounding numbers
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
234 (while (and (<= count-high (1- rom-lngth))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
235 (>= n (car (nth count-high our-list))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
236 ;; (message "Checking %d" (car (nth count-high our-list)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
237 (setq count-high (1+ count-high)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
238 (setq rom-high count-high)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
239 (setq rom-low (1- count-high))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
240 ;; find the appropriate divisor (if it exists)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
241 (while (and (= rom-div -1)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
242 (< count-low rom-high))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
243 (when (or (> n (- (car (nth rom-high our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
244 (/ (car (nth count-low our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
245 2)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
246 (= n (- (car (nth rom-high our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
247 (car (nth count-low our-list)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
248 (setq rom-div count-low))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
249 ;; (message "Checking %d and %d in div loop" rom-high count-low)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
250 (setq count-low (1+ count-low)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
251 ;;(message "We now have high: %d, low: %d, div: %d, n: %d"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
252 ;; rom-high rom-low (if rom-div rom-div -1) n)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
253 (let ((rom-low-pair (nth rom-low our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
254 (rom-high-pair (nth rom-high our-list))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
255 (rom-div-pair (if (not (= rom-div -1)) (nth rom-div our-list) nil)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
256 ;; (message "pairs are: rom-low: %S, rom-high: %S, rom-div: %S"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
257 ;; rom-low-pair rom-high-pair rom-div-pair)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
258 (cond
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
259 ((< n 0) (error "Footnote-roman-common called with n < 0"))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
260 ((= n 0) "")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
261 ((= n (car rom-low-pair)) (cdr rom-low-pair))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
262 ((= n (car rom-high-pair)) (cdr rom-high-pair))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
263 ((= (car rom-low-pair) (car rom-high-pair))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
264 (concat (cdr rom-low-pair)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
265 (Footnote-roman-common
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
266 (- n (car rom-low-pair))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
267 footnote-roman-list)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
268 ((>= rom-div 0) (concat (cdr rom-div-pair) (cdr rom-high-pair)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
269 (Footnote-roman-common
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
270 (- n (- (car rom-high-pair)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
271 (car rom-div-pair)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
272 footnote-roman-list)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
273 (t (concat (cdr rom-low-pair)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
274 (Footnote-roman-common
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
275 (- n (car rom-low-pair))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
276 footnote-roman-list)))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
277
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
278 ;; Latin-1
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
279
77164
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
280 (defconst footnote-latin-string "¹²³ºª§¶"
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
281 "String of Latin-1 footnoting characters.")
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
282
79299
6ba7088444ec (footnote-numeric-regexp)
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
283 ;; Note not [...]+, because this style cycles.
77164
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
284 (defconst footnote-latin-regexp (concat "[" footnote-latin-string "]")
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
285 "Regexp for Latin-1 footnoting characters.")
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
286
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
287 (defun Footnote-latin (n)
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
288 "Latin-1 footnote style.
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
289 Use a range of Latin-1 non-ASCII characters for footnoting."
77164
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
290 (string (aref footnote-latin-string
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
291 (mod (1- n) (length footnote-latin-string)))))
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
292
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
293 ;;; list of all footnote styles
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
294 (defvar footnote-style-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
295 `((numeric Footnote-numeric ,footnote-numeric-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
296 (english-lower Footnote-english-lower ,footnote-english-lower-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
297 (english-upper Footnote-english-upper ,footnote-english-upper-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
298 (roman-lower Footnote-roman-lower ,footnote-roman-lower-regexp)
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
299 (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp)
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
300 (latin Footnote-latin ,footnote-latin-regexp))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
301 "Styles of footnote tags available.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
302 By default only boring Arabic numbers, English letters and Roman Numerals
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
303 are available.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
304 See footnote-han.el, footnote-greek.el and footnote-hebrew.el for more
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
305 exciting styles.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
306
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
307 (defcustom footnote-style 'numeric
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
308 "Default style used for footnoting.
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
309 numeric == 1, 2, 3, ...
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
310 english-lower == a, b, c, ...
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
311 english-upper == A, B, C, ...
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
312 roman-lower == i, ii, iii, iv, v, ...
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
313 roman-upper == I, II, III, IV, V, ...
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
314 latin == ¹ ² ³ º ª § ¶
77227
8a6e5c01dde1 (footnote-style): Clarify docstring to state that customizing this
Chong Yidong <cyd@stupidchicken.com>
parents: 77225
diff changeset
315 See also variables `footnote-start-tag' and `footnote-end-tag'.
8a6e5c01dde1 (footnote-style): Clarify docstring to state that customizing this
Chong Yidong <cyd@stupidchicken.com>
parents: 77225
diff changeset
316
8a6e5c01dde1 (footnote-style): Clarify docstring to state that customizing this
Chong Yidong <cyd@stupidchicken.com>
parents: 77225
diff changeset
317 Customizing this variable has no effect on buffers already
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
318 displaying footnotes. To change the style of footnotes in such a
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
319 buffer use the command `Footnote-set-style'."
27830
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
320 :type (cons 'choice (mapcar (lambda (x) (list 'const (car x)))
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
321 footnote-style-alist))
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
322 :group 'footnote)
99b1d31f039b (footnote): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 26815
diff changeset
323
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
324 ;;; Style utilities & functions
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
325 (defun Footnote-style-p (style)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
326 "Return non-nil if style is a valid style known to footnote-mode."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
327 (assq style footnote-style-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
328
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
329 (defun Footnote-index-to-string (index)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
330 "Convert a binary index into a string to display as a footnote.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
331 Conversion is done based upon the current selected style."
77225
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
332 (let ((alist (if (Footnote-style-p footnote-style)
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
333 (assq footnote-style footnote-style-alist)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
334 (nth 0 footnote-style-alist))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
335 (funcall (nth 1 alist) index)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
336
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
337 (defun Footnote-current-regexp ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
338 "Return the regexp of the index of the current style."
77225
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
339 (concat (nth 2 (or (assq footnote-style footnote-style-alist)
79632
145a45ea4769 Whitespace change.
Richard M. Stallman <rms@gnu.org>
parents: 79299
diff changeset
340 (nth 0 footnote-style-alist)))
145a45ea4769 Whitespace change.
Richard M. Stallman <rms@gnu.org>
parents: 79299
diff changeset
341 "*"))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
342
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
343 (defun Footnote-refresh-footnotes (&optional index-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
344 "Redraw all footnotes.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
345 You must call this or arrange to have this called after changing footnote
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
346 styles."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
347 (unless index-regexp
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
348 (setq index-regexp (Footnote-current-regexp)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
349 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
350 ;; Take care of the pointers first
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
351 (let ((i 0) locn alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
352 (while (setq alist (nth i footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
353 (setq locn (cdr alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
354 (while locn
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
355 (goto-char (car locn))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
356 ;; Try to handle the case where `footnote-start-tag' and
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
357 ;; `footnote-end-tag' are the same string.
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
358 (when (looking-back (concat
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
359 (regexp-quote footnote-start-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
360 "\\(" index-regexp "+\\)"
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
361 (regexp-quote footnote-end-tag))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
362 (line-beginning-position))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
363 (replace-match
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
364 (propertize
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
365 (concat
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
366 footnote-start-tag
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
367 (Footnote-index-to-string (1+ i))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
368 footnote-end-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
369 'footnote-number (1+ i) footnote-mouse-highlight t)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
370 nil "\\1"))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
371 (setq locn (cdr locn)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
372 (setq i (1+ i))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
373
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
374 ;; Now take care of the text section
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
375 (let ((i 0) alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
376 (while (setq alist (nth i footnote-text-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
377 (goto-char (cdr alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
378 (when (looking-at (concat
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
379 (regexp-quote footnote-start-tag)
79632
145a45ea4769 Whitespace change.
Richard M. Stallman <rms@gnu.org>
parents: 79299
diff changeset
380 "\\(" index-regexp "+\\)"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
381 (regexp-quote footnote-end-tag)))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
382 (replace-match
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
383 (propertize
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
384 (concat
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
385 footnote-start-tag
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
386 (Footnote-index-to-string (1+ i))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
387 footnote-end-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
388 'footnote-number (1+ i))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
389 nil "\\1"))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
390 (setq i (1+ i))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
391
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
392 (defun Footnote-assoc-index (key alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
393 "Give index of key in alist."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
394 (let ((i 0) (max (length alist)) rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
395 (while (and (null rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
396 (< i max))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
397 (when (eq key (car (nth i alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
398 (setq rc i))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
399 (setq i (1+ i)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
400 rc))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
401
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
402 (defun Footnote-cycle-style ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
403 "Select next defined footnote style."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
404 (interactive)
77225
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
405 (let ((old (Footnote-assoc-index footnote-style footnote-style-alist))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
406 (max (length footnote-style-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
407 idx)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
408 (setq idx (1+ old))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
409 (when (>= idx max)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
410 (setq idx 0))
77225
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
411 (setq footnote-style (car (nth idx footnote-style-alist)))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
412 (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
413
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
414 (defun Footnote-set-style (&optional style)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
415 "Select a specific style."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
416 (interactive
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
417 (list (intern (completing-read
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
418 "Footnote Style: "
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
419 obarray #'Footnote-style-p 'require-match))))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
420 (let ((old (Footnote-assoc-index footnote-style footnote-style-alist)))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
421 (setq footnote-style style)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
422 (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
423
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
424 ;; Internal functions
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
425 (defun Footnote-insert-numbered-footnote (arg &optional mousable)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
426 "Insert numbered footnote at (point)."
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
427 (let ((string (concat footnote-start-tag
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
428 (Footnote-index-to-string arg)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
429 footnote-end-tag)))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
430 (insert-before-markers
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
431 (if mousable
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
432 (propertize
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
433 string 'footnote-number arg footnote-mouse-highlight t)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
434 (propertize string 'footnote-number arg)))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
435
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
436 (defun Footnote-renumber (from to pointer-alist text-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
437 "Renumber a single footnote."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
438 (let* ((posn-list (cdr pointer-alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
439 (setcar pointer-alist to)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
440 (setcar text-alist to)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
441 (while posn-list
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
442 (goto-char (car posn-list))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
443 (when (looking-back (concat (regexp-quote footnote-start-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
444 (Footnote-current-regexp)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
445 (regexp-quote footnote-end-tag))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
446 (line-beginning-position))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
447 (replace-match
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
448 (propertize
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
449 (concat footnote-start-tag
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
450 (Footnote-index-to-string to)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
451 footnote-end-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
452 'footnote-number to footnote-mouse-highlight t)))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
453 (setq posn-list (cdr posn-list)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
454 (goto-char (cdr text-alist))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
455 (when (looking-at (concat (regexp-quote footnote-start-tag)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
456 (Footnote-current-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
457 (regexp-quote footnote-end-tag)))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
458 (replace-match
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
459 (propertize
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
460 (concat footnote-start-tag
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
461 (Footnote-index-to-string to)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
462 footnote-end-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
463 'footnote-number to)))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
464
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
465 ;; Not needed?
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
466 (defun Footnote-narrow-to-footnotes ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
467 "Restrict text in buffer to show only text of footnotes."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
468 (interactive) ; testing
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
469 (goto-char (point-max))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
470 (when (re-search-backward footnote-signature-separator nil t)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
471 (let ((end (point)))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
472 (cond
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
473 ((and (not (string-equal footnote-section-tag ""))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
474 (re-search-backward
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
475 (concat "^" footnote-section-tag-regexp) nil t))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
476 (narrow-to-region (point) end))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
477 (footnote-text-marker-alist
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
478 (narrow-to-region (cdar footnote-text-marker-alist) end))))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
479
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
480 (defun Footnote-goto-char-point-max ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
481 "Move to end of buffer or prior to start of .signature."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
482 (goto-char (point-max))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
483 (or (re-search-backward footnote-signature-separator nil t)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
484 (point)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
485
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
486 (defun Footnote-insert-text-marker (arg locn)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
487 "Insert a marker pointing to footnote ARG, at buffer location LOCN."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
488 (let ((marker (make-marker)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
489 (unless (assq arg footnote-text-marker-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
490 (set-marker marker locn)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
491 (setq footnote-text-marker-alist
26815
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
492 (cons (cons arg marker) footnote-text-marker-alist))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
493 (setq footnote-text-marker-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
494 (Footnote-sort footnote-text-marker-alist)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
495
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
496 (defun Footnote-insert-pointer-marker (arg locn)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
497 "Insert a marker pointing to footnote ARG, at buffer location LOCN."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
498 (let ((marker (make-marker))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
499 alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
500 (set-marker marker locn)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
501 (if (setq alist (assq arg footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
502 (setf alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
503 (cons marker (cdr alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
504 (setq footnote-pointer-marker-alist
26815
9fa9fd18d083 Require cl when compiling. Don't autoload kemap and minor-mode-alist
Dave Love <fx@gnu.org>
parents: 26784
diff changeset
505 (cons (cons arg (list marker)) footnote-pointer-marker-alist))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
506 (setq footnote-pointer-marker-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
507 (Footnote-sort footnote-pointer-marker-alist)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
508
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
509 (defun Footnote-insert-footnote (arg)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
510 "Insert a footnote numbered ARG, at (point)."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
511 (push-mark)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
512 (Footnote-insert-pointer-marker arg (point))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
513 (Footnote-insert-numbered-footnote arg t)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
514 (Footnote-goto-char-point-max)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
515 (if (cond
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
516 ((not (string-equal footnote-section-tag ""))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
517 (re-search-backward (concat "^" footnote-section-tag-regexp) nil t))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
518 (footnote-text-marker-alist
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
519 (goto-char (cdar footnote-text-marker-alist))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
520 (save-restriction
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
521 (when footnote-narrow-to-footnotes-when-editing
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
522 (Footnote-narrow-to-footnotes))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
523 (Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
524 ;; (message "Inserting footnote %d" arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
525 (unless
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
526 (or (eq arg 1)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
527 (when (re-search-forward
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
528 (if footnote-spaced-footnotes
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
529 "\n\n"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
530 (concat "\n"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
531 (regexp-quote footnote-start-tag)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
532 (Footnote-current-regexp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
533 (regexp-quote footnote-end-tag)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
534 nil t)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
535 (unless (beginning-of-line) t))
74919
c27a32ee3586 (Footnote-insert-footnote): Fix the search of the last footnote when
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents: 74509
diff changeset
536 (Footnote-goto-char-point-max)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
537 (cond
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
538 ((not (string-equal footnote-section-tag ""))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
539 (re-search-backward
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
540 (concat "^" footnote-section-tag-regexp) nil t))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
541 (footnote-text-marker-alist
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
542 (goto-char (cdar footnote-text-marker-alist)))))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
543 (unless (looking-at "^$")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
544 (insert "\n"))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
545 (when (eobp)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
546 (insert "\n"))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
547 (unless (string-equal footnote-section-tag "")
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
548 (insert footnote-section-tag "\n")))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
549 (let ((old-point (point)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
550 (Footnote-insert-numbered-footnote arg nil)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
551 (Footnote-insert-text-marker arg old-point)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
552
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
553 (defun Footnote-sort (list)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
554 (sort list (lambda (e1 e2)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
555 (< (car e1) (car e2)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
556
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
557 (defun Footnote-text-under-cursor ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
558 "Return the number of footnote if in footnote text.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38436
diff changeset
559 Return nil if the cursor is not positioned over the text of
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
560 a footnote."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
561 (when (and (let ((old-point (point)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
562 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
563 (save-restriction
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
564 (Footnote-narrow-to-footnotes)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
565 (and (>= old-point (point-min))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
566 (<= old-point (point-max))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
567 (>= (point) (cdar footnote-text-marker-alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
568 (let ((i 1)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
569 alist-txt rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
570 (while (and (setq alist-txt (nth i footnote-text-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
571 (null rc))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
572 (when (< (point) (cdr alist-txt))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
573 (setq rc (car (nth (1- i) footnote-text-marker-alist))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
574 (setq i (1+ i)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
575 (when (and (null rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
576 (null alist-txt))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
577 (setq rc (car (nth (1- i) footnote-text-marker-alist))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
578 rc)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
579
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
580 (defun Footnote-under-cursor ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
581 "Return the number of the footnote underneath the cursor.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38436
diff changeset
582 Return nil if the cursor is not over a footnote."
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
583 (or (get-text-property (point) 'footnote-number)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
584 (Footnote-text-under-cursor)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
585
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
586 ;;; User functions
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
587
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
588 (defun Footnote-make-hole ()
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
589 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
590 (let ((i 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
591 (notes (length footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
592 alist-ptr alist-txt rc)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
593 (while (< i notes)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
594 (setq alist-ptr (nth i footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
595 (setq alist-txt (nth i footnote-text-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
596 (when (< (point) (- (cadr alist-ptr) 3))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
597 (unless rc
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
598 (setq rc (car alist-ptr)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
599 (save-excursion
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
600 (message "Renumbering from %s to %s"
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
601 (Footnote-index-to-string (car alist-ptr))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
602 (Footnote-index-to-string
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
603 (1+ (car alist-ptr))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
604 (Footnote-renumber (car alist-ptr)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
605 (1+ (car alist-ptr))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
606 alist-ptr
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
607 alist-txt)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
608 (setq i (1+ i)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
609 rc)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
610
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
611 (defun Footnote-add-footnote (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
612 "Add a numbered footnote.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
613 The number the footnote receives is dependent upon the relative location
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
614 of any other previously existing footnotes.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
615 If the variable `footnote-narrow-to-footnotes-when-editing' is set,
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
616 the buffer is narrowed to the footnote body. The restriction is removed
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
617 by using `Footnote-back-to-message'."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
618 (interactive "*P")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
619 (let (num)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
620 (if footnote-text-marker-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
621 (if (< (point) (cadar (last footnote-pointer-marker-alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
622 (setq num (Footnote-make-hole))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
623 (setq num (1+ (caar (last footnote-text-marker-alist)))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
624 (setq num 1))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
625 (message "Adding footnote %d" num)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
626 (Footnote-insert-footnote num)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
627 (insert-before-markers (make-string footnote-body-tag-spacing ? ))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
628 (let ((opoint (point)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
629 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
630 (insert-before-markers
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
631 (if footnote-spaced-footnotes
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
632 "\n\n"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
633 "\n"))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
634 (when footnote-narrow-to-footnotes-when-editing
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
635 (Footnote-narrow-to-footnotes)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
636 ;; Emacs/XEmacs bug? save-excursion doesn't restore point when using
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
637 ;; insert-before-markers.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
638 (goto-char opoint))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
639
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
640 (defun Footnote-delete-footnote (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
641 "Delete a numbered footnote.
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
642 With no parameter, delete the footnote under (point). With ARG specified,
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
643 delete the footnote with that number."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
644 (interactive "*P")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
645 (unless arg
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
646 (setq arg (Footnote-under-cursor)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
647 (when (and arg
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
648 (or (not footnote-prompt-before-deletion)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
649 (y-or-n-p (format "Really delete footnote %d?" arg))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
650 (let (alist-ptr alist-txt locn)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
651 (setq alist-ptr (assq arg footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
652 (setq alist-txt (assq arg footnote-text-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
653 (unless (and alist-ptr alist-txt)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
654 (error "Can't delete footnote %d" arg))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
655 (setq locn (cdr alist-ptr))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
656 (while (car locn)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
657 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
658 (goto-char (car locn))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
659 (when (looking-back (concat (regexp-quote footnote-start-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
660 (Footnote-current-regexp)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
661 (regexp-quote footnote-end-tag))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
662 (line-beginning-position))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
663 (delete-region (match-beginning 0) (match-end 0))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
664 (setq locn (cdr locn)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
665 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
666 (goto-char (cdr alist-txt))
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
667 (delete-region
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
668 (point)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
669 (if footnote-spaced-footnotes
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
670 (search-forward "\n\n" nil t)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
671 (save-restriction
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
672 (end-of-line)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
673 (next-single-char-property-change
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
674 (point) 'footnote-number nil (Footnote-goto-char-point-max))))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
675 (setq footnote-pointer-marker-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
676 (delq alist-ptr footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
677 (setq footnote-text-marker-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
678 (delq alist-txt footnote-text-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
679 (Footnote-renumber-footnotes)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
680 (when (and (null footnote-text-marker-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
681 (null footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
682 (save-excursion
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
683 (if (not (string-equal footnote-section-tag ""))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
684 (let* ((end (Footnote-goto-char-point-max))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
685 (start (1- (re-search-backward
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
686 (concat "^" footnote-section-tag-regexp)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
687 nil t))))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
688 (forward-line -1)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
689 (when (looking-at "\n")
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
690 (kill-line))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
691 (delete-region start (if (< end (point-max))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
692 end
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
693 (point-max))))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
694 (Footnote-goto-char-point-max)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
695 (when (looking-back "\n\n")
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
696 (kill-line -1))))))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
697
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
698 (defun Footnote-renumber-footnotes (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
699 "Renumber footnotes, starting from 1."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
700 (interactive "*P")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
701 (save-excursion
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
702 (let ((i 0)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
703 (notes (length footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
704 alist-ptr alist-txt)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
705 (while (< i notes)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
706 (setq alist-ptr (nth i footnote-pointer-marker-alist))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
707 (setq alist-txt (nth i footnote-text-marker-alist))
77164
0d019d25db47 (footnote-latin-string): New variable.
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
708 (unless (= (1+ i) (car alist-ptr))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
709 (Footnote-renumber (car alist-ptr) (1+ i) alist-ptr alist-txt))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
710 (setq i (1+ i))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
711
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
712 (defun Footnote-goto-footnote (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
713 "Jump to the text of a footnote.
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
714 With no parameter, jump to the text of the footnote under (point). With ARG
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
715 specified, jump to the text of that footnote."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
716 (interactive "P")
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
717 (unless arg
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
718 (setq arg (Footnote-under-cursor)))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
719 (let ((footnote (assq arg footnote-text-marker-alist)))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
720 (cond
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
721 (footnote
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
722 (goto-char (cdr footnote)))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
723 ((eq arg 0)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
724 (goto-char (point-max))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
725 (cond
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
726 ((not (string-equal footnote-section-tag ""))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
727 (re-search-backward (concat "^" footnote-section-tag-regexp))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
728 (forward-line 1))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
729 (footnote-text-marker-alist
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
730 (goto-char (cdar footnote-text-marker-alist)))))
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
731 (t
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
732 (error "I don't see a footnote here")))))
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
733
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
734 (defun Footnote-back-to-message (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
735 "Move cursor back to footnote referent.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
736 If the cursor is not over the text of a footnote, point is not changed.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
737 If the buffer was narrowed due to `footnote-narrow-to-footnotes-when-editing'
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
738 being set it is automatically widened."
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
739 (interactive "P")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
740 (let ((note (Footnote-text-under-cursor)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
741 (when note
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
742 (when footnote-narrow-to-footnotes-when-editing
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
743 (widen))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
744 (goto-char (cadr (assq note footnote-pointer-marker-alist))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
745
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
746 (defvar footnote-mode-map nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
747 "Keymap used for footnote minor mode.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
748
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
749 ;; Set up our keys
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
750 (unless footnote-mode-map
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
751 (setq footnote-mode-map (make-sparse-keymap))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
752 (define-key footnote-mode-map "a" 'Footnote-add-footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
753 (define-key footnote-mode-map "b" 'Footnote-back-to-message)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
754 (define-key footnote-mode-map "c" 'Footnote-cycle-style)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
755 (define-key footnote-mode-map "d" 'Footnote-delete-footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
756 (define-key footnote-mode-map "g" 'Footnote-goto-footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
757 (define-key footnote-mode-map "r" 'Footnote-renumber-footnotes)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
758 (define-key footnote-mode-map "s" 'Footnote-set-style))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
759
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
760 (defvar footnote-minor-mode-map nil
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
761 "Keymap used for binding footnote minor mode.")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
762
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
763 (unless footnote-minor-mode-map
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
764 (define-key global-map footnote-prefix footnote-mode-map))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
765
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
766 ;;;###autoload
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
767 (defun footnote-mode (&optional arg)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
768 "Toggle footnote minor mode.
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
769 \\<message-mode-map>
99487
647e1c7496bf (footnote-mode): Improve doc-string.
Martin Rudalics <rudalics@gmx.at>
parents: 98534
diff changeset
770 This minor mode provides footnote support for `message-mode'. To get
647e1c7496bf (footnote-mode): Improve doc-string.
Martin Rudalics <rudalics@gmx.at>
parents: 98534
diff changeset
771 started, play around with the following keys:
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
772 key binding
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
773 --- -------
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
774 \\[Footnote-add-footnote] Footnote-add-footnote
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
775 \\[Footnote-back-to-message] Footnote-back-to-message
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
776 \\[Footnote-delete-footnote] Footnote-delete-footnote
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
777 \\[Footnote-goto-footnote] Footnote-goto-footnote
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
778 \\[Footnote-renumber-footnotes] Footnote-renumber-footnotes
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
779 \\[Footnote-cycle-style] Footnote-cycle-style
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
780 \\[Footnote-set-style] Footnote-set-style
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
781 "
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
782 (interactive "*P")
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
783 ;; (filladapt-mode t)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
784 (setq footnote-mode
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
785 (if (null arg) (not footnote-mode)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
786 (> (prefix-numeric-value arg) 0)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
787 (when footnote-mode
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
788 ;; (Footnote-setup-keybindings)
77225
1110109db29c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 77223
diff changeset
789 (make-local-variable 'footnote-style)
98534
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
790 (make-local-variable 'footnote-body-tag-spacing)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
791 (make-local-variable 'footnote-spaced-footnotes)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
792 (make-local-variable 'footnote-section-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
793 (make-local-variable 'footnote-section-tag-regexp)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
794 (make-local-variable 'footnote-start-tag)
3eb71995f60b Remove * in defcustom docstrings and tell
Martin Rudalics <rudalics@gmx.at>
parents: 94674
diff changeset
795 (make-local-variable 'footnote-end-tag)
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
796 (if (fboundp 'force-mode-line-update)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
797 (force-mode-line-update)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
798 (set-buffer-modified-p (buffer-modified-p)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
799
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
800 (when (boundp 'filladapt-token-table)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
801 ;; add tokens to filladapt to match footnotes
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
802 ;; 1] xxxxxxxxxxx x x x or [1] x x x x x x x
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
803 ;; xxx x xx xxx xxxx x x x xxxxxxxxxx
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
804 (let ((bullet-regexp (concat (regexp-quote footnote-start-tag)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
805 "?[0-9a-zA-Z]+"
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
806 (regexp-quote footnote-end-tag)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
807 "[ \t]")))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
808 (unless (assoc bullet-regexp filladapt-token-table)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
809 (setq filladapt-token-table
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
810 (append filladapt-token-table
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
811 (list (list bullet-regexp 'bullet)))))))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
812
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
813 (run-hooks 'footnote-mode-hook)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
814
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
815 (unless (assq 'footnote-mode minor-mode-alist)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
816 (setq minor-mode-alist
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
817 (cons '(footnote-mode footnote-mode-line-string)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
818 minor-mode-alist)))
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
819
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
820 (provide 'footnote)
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
821
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79712
diff changeset
822 ;; arch-tag: 9bcfb6d7-2161-4caf-8793-700f62400398
26784
4d1698b6a3bb Current XEmacs version.
Dave Love <fx@gnu.org>
parents:
diff changeset
823 ;;; footnote.el ends here