Mercurial > emacs
annotate lisp/mail/supercite.el @ 63092:80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Mon, 06 Jun 2005 19:47:05 +0000 |
| parents | 095901aead41 |
| children | eb399d132bf4 173dee4e2611 |
| rev | line source |
|---|---|
| 4850 | 1 ;;; supercite.el --- minor mode for citing mail and news replies |
| 2 | |
|
60916
480134f8cd16
* mail/supercite.el: Replace `illegal' with `invalid'.
Werner LEMBERG <wl@gnu.org>
parents:
58952
diff
changeset
|
3 ;; Copyright (C) 1993, 1997, 2003, 2004, 2005 Free Software Foundation, Inc. |
|
12859
90c22a02c12b
(sc-attribs-extract-namestring): If name has <...>,
Richard M. Stallman <rms@gnu.org>
parents:
12425
diff
changeset
|
4 |
| 57160 | 5 ;; Author: 1993 Barry A. Warsaw <bwarsaw@python.org> |
| 62924 | 6 ;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk> |
| 4850 | 7 ;; Created: February 1993 |
| 8 ;; Last Modified: 1993/09/22 18:58:46 | |
| 5140 | 9 ;; Keywords: mail, news |
| 4850 | 10 |
| 11 ;; supercite.el revision: 3.54 | |
| 12 | |
| 13 ;; This file is part of GNU Emacs. | |
| 14 | |
| 15 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 16 ;; it under the terms of the GNU General Public License as published by | |
| 17 ;; the Free Software Foundation; either version 2, or (at your option) | |
| 18 ;; any later version. | |
| 19 | |
| 20 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 23 ;; GNU General Public License for more details. | |
| 24 | |
| 25 ;; You should have received a copy of the GNU General Public License | |
| 14169 | 26 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 28 ;; Boston, MA 02111-1307, USA. | |
| 4850 | 29 |
| 30 ;; LCD Archive Entry | |
|
24612
8f10db1e779a
(sc-attrib-selection-list): Fix custom type
Dave Love <fx@gnu.org>
parents:
24426
diff
changeset
|
31 ;; supercite|Barry A. Warsaw|supercite-help@python.org |
| 4850 | 32 ;; |Mail and news reply citation package |
| 33 ;; |1993/09/22 18:58:46|3.1| | |
| 34 | |
|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
28437
diff
changeset
|
35 ;;; Commentary: |
|
b174db545cfd
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
28437
diff
changeset
|
36 |
|
b174db545cfd
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
28437
diff
changeset
|
37 ;;; Code: |
| 4850 | 38 |
| 39 | |
| 40 (require 'regi) | |
| 21861 | 41 (require 'sendmail) ;; For mail-header-end. |
| 4850 | 42 |
| 43 ;; start user configuration variables | |
| 44 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | |
| 45 | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 (defgroup supercite nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 "Supercite package" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 :prefix "sc-" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 :group 'mail |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 :group 'news) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
51 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 (defgroup supercite-frames nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
53 "Supercite (regi) frames" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 :prefix "sc-" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 :group 'supercite) |
| 4850 | 56 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 (defgroup supercite-attr nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 "Supercite attributions" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 :prefix "sc-" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 :group 'supercite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 (defgroup supercite-cite nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 "Supercite citings" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
64 :prefix "sc-" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
65 :group 'supercite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
67 (defgroup supercite-hooks nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 "Hooking into supercite" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
69 :prefix "sc-" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
70 :group 'supercite) |
| 4850 | 71 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
72 (defcustom sc-auto-fill-region-p t |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
73 "*If non-nil, automatically fill each paragraph after it has been cited." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
74 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
75 :group 'supercite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
76 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
77 (defcustom sc-blank-lines-after-headers 1 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
78 "*Number of blank lines to leave after mail headers have been nuked. |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
79 Set to nil, to use whatever blank lines happen to occur naturally." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
80 :type '(choice (const :tag "leave" nil) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
81 integer) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
82 :group 'supercite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
83 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
84 (defcustom sc-citation-leader " " |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
85 "*String comprising first part of a citation." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
86 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
87 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
88 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
89 (defcustom sc-citation-delimiter ">" |
| 4850 | 90 "*String comprising third part of a citation. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
91 This string is used in both nested and non-nested citations." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
92 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
93 :group 'supercite-cite) |
| 4850 | 94 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
95 (defcustom sc-citation-separator " " |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
96 "*String comprising fourth and last part of a citation." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
97 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
98 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
99 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
100 (defcustom sc-citation-leader-regexp "[ \t]*" |
| 4850 | 101 "*Regexp describing citation leader for a cited line. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
102 This should NOT have a leading `^' character." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
103 :type 'regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
104 :group 'supercite-cite) |
| 4850 | 105 |
| 106 ;; Nemacs and Mule users note: please see the texinfo manual for | |
| 107 ;; suggestions on setting these variables. | |
| 28437 | 108 (defcustom sc-citation-root-regexp "[-._[:alnum:]]*" |
| 4850 | 109 "*Regexp describing variable root part of a citation for a cited line. |
| 110 This should NOT have a leading `^' character. See also | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
111 `sc-citation-nonnested-root-regexp'." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
112 :type 'regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
113 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
114 |
| 28437 | 115 (defcustom sc-citation-nonnested-root-regexp "[-._[:alnum:]]+" |
| 4850 | 116 "*Regexp describing the variable root part of a nested citation. |
| 117 This should NOT have a leading `^' character. This variable is | |
|
14007
c6476f4bb121
(sc-citation-nonnested-root-regexp,
Karl Heuer <kwzh@gnu.org>
parents:
13813
diff
changeset
|
118 related to `sc-citation-root-regexp' but whereas that variable |
| 4850 | 119 describes both nested and non-nested citation roots, this variable |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
120 describes only nested citation roots." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
121 :type 'regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
122 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
123 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
124 (defcustom sc-citation-delimiter-regexp "[>]+" |
| 4850 | 125 "*Regexp describing citation delimiter for a cited line. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
126 This should NOT have a leading `^' character." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
127 :type 'regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
128 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
129 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
130 (defcustom sc-citation-separator-regexp "[ \t]*" |
| 4850 | 131 "*Regexp describing citation separator for a cited line. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
132 This should NOT have a leading `^' character." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
133 :type 'regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
134 :group 'supercite-cite) |
| 4850 | 135 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
136 (defcustom sc-cite-blank-lines-p nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
137 "*If non-nil, put a citation on blank lines." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
138 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
139 :group 'supercite-cite) |
| 4850 | 140 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
141 (defcustom sc-cite-frame-alist '() |
| 4850 | 142 "*Alist for frame selection during citing. |
| 143 Each element of this list has the following form: | |
| 144 (INFOKEY ((REGEXP . FRAME) | |
| 145 (REGEXP . FRAME) | |
| 146 (...))) | |
| 147 | |
| 148 Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular | |
|
58952
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
149 expression to match against the INFOKEY's value. FRAME is |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
150 a citation frame, or a symbol that represents the name of |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
151 a variable whose value is a citation frame." |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
152 :type '(repeat (list symbol (repeat (cons regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
153 (choice (repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
154 symbol))))) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
155 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
156 (put 'sc-cite-frame-alist 'risky-local-variable t) |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
157 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
158 (defcustom sc-uncite-frame-alist '() |
| 4850 | 159 "*Alist for frame selection during unciting. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
160 See the variable `sc-cite-frame-alist' for details." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
161 :type '(repeat (list symbol (repeat (cons regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
162 (choice (repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
163 symbol))))) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
164 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
165 (put 'sc-uncite-frame-alist 'risky-local-variable t) |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
166 |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
167 (defcustom sc-recite-frame-alist '() |
| 4850 | 168 "*Alist for frame selection during reciting. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
169 See the variable `sc-cite-frame-alist' for details." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
170 :type '(repeat (list symbol (repeat (cons regexp |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 (choice (repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
172 symbol))))) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
173 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
174 (put 'sc-recite-frame-alist 'risky-local-variable t) |
| 4850 | 175 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
176 (defcustom sc-default-cite-frame |
| 4850 | 177 '(;; initialize fill state and temporary variables when entering |
| 178 ;; frame. this makes things run much faster | |
| 179 (begin (progn | |
| 180 (sc-fill-if-different) | |
| 181 (setq sc-tmp-nested-regexp (sc-cite-regexp "") | |
| 182 sc-tmp-nonnested-regexp (sc-cite-regexp) | |
| 183 sc-tmp-dumb-regexp | |
| 184 (concat "\\(" | |
| 185 (sc-cite-regexp "") | |
| 186 "\\)" | |
| 187 (sc-cite-regexp sc-citation-nonnested-root-regexp)) | |
| 188 ))) | |
| 189 ;; blank lines mean paragraph separators, so fill the last cited | |
| 190 ;; paragraph, unless sc-cite-blank-lines-p is non-nil, in which | |
| 191 ;; case we treat blank lines just like any other line. | |
| 192 ("^[ \t]*$" (if sc-cite-blank-lines-p | |
| 193 (sc-cite-line) | |
| 194 (sc-fill-if-different ""))) | |
| 195 ;; do nothing if looking at a reference tag. make sure that the | |
| 196 ;; tag string isn't the empty string since this will match every | |
| 197 ;; line. it cannot be nil. | |
| 198 (sc-reference-tag-string (if (string= sc-reference-tag-string "") | |
| 199 (list 'continue) | |
| 200 nil)) | |
| 201 ;; this regexp catches nested citations in which the author cited | |
| 202 ;; a non-nested citation with a dumb citer. | |
| 203 (sc-tmp-dumb-regexp (sc-cite-coerce-dumb-citer)) | |
| 204 ;; if we are looking at a nested citation then add a citation level | |
| 205 (sc-tmp-nested-regexp (sc-add-citation-level)) | |
| 206 ;; if we're looking at a non-nested citation, coerce it to our style | |
| 207 (sc-tmp-nonnested-regexp (sc-cite-coerce-cited-line)) | |
| 208 ;; we must be looking at an uncited line. if we are in nested | |
| 209 ;; citations, just add a citation level | |
| 210 (sc-nested-citation-p (sc-add-citation-level)) | |
| 211 ;; we're looking at an uncited line and we are in non-nested | |
| 212 ;; citations, so cite it with a non-nested citation | |
| 213 (t (sc-cite-line)) | |
| 214 ;; be sure when we're done that we fill the last cited paragraph. | |
| 215 (end (sc-fill-if-different "")) | |
| 216 ) | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
217 "*Default REGI frame for citing a region." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
218 :type '(repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
219 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
220 (put 'sc-default-cite-frame 'risky-local-variable t) |
| 4850 | 221 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
222 (defcustom sc-default-uncite-frame |
| 4850 | 223 '(;; do nothing on a blank line |
| 224 ("^[ \t]*$" nil) | |
| 225 ;; if the line is cited, uncite it | |
| 226 ((sc-cite-regexp) (sc-uncite-line)) | |
| 227 ) | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
228 "*Default REGI frame for unciting a region." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
229 :type '(repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
230 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
231 (put 'sc-default-uncite-frame 'risky-local-variable t) |
| 4850 | 232 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
233 (defcustom sc-default-recite-frame |
| 4850 | 234 '(;; initialize fill state when entering frame |
| 235 (begin (sc-fill-if-different)) | |
| 236 ;; do nothing on a blank line | |
| 237 ("^[ \t]*$" nil) | |
| 238 ;; if we're looking at a cited line, recite it | |
| 239 ((sc-cite-regexp) (sc-recite-line (sc-cite-regexp))) | |
| 240 ;; otherwise, the line is uncited, so just cite it | |
| 241 (t (sc-cite-line)) | |
| 242 ;; be sure when we're done that we fill the last cited paragraph. | |
| 243 (end (sc-fill-if-different "")) | |
| 244 ) | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
245 "*Default REGI frame for reciting a region." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
246 :type '(repeat (repeat sexp)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
247 :group 'supercite-frames) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
248 (put 'sc-default-recite-frame 'risky-local-variable t) |
| 4850 | 249 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
250 (defcustom sc-cite-region-limit t |
| 4850 | 251 "*This variable controls automatic citation of yanked text. |
|
60924
fb2b49a3a4e0
* mail/supercite.el: Replace `legal' with `valid'.
Werner LEMBERG <wl@gnu.org>
parents:
60916
diff
changeset
|
252 Valid values are: |
| 4850 | 253 |
| 254 non-nil -- cite the entire region, regardless of its size | |
| 255 nil -- do not cite the region at all | |
| 256 <integer> -- a number indicating the threshold for citation. When | |
| 257 the number of lines in the region is greater than this | |
| 258 value, a warning message will be printed and the region | |
| 259 will not be cited. Lines in region are counted with | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
260 `count-lines'. |
| 4850 | 261 |
| 262 The gathering of attribution information is not affected by the value | |
| 263 of this variable. The number of lines in the region is calculated | |
| 264 *after* all mail headers are removed. This variable is only consulted | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
265 during the initial citing via `sc-cite-original'." |
|
22592
17e17690ab4e
(sc-cite-region-limit): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
21861
diff
changeset
|
266 :type '(choice (const :tag "do not cite" nil) |
|
17e17690ab4e
(sc-cite-region-limit): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
21861
diff
changeset
|
267 (integer :tag "citation threshold") |
|
17e17690ab4e
(sc-cite-region-limit): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
21861
diff
changeset
|
268 (other :tag "always cite" t)) |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
269 :group 'supercite-cite) |
| 4850 | 270 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
271 (defcustom sc-confirm-always-p t |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
272 "*If non-nil, always confirm attribution string before citing text body." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
273 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
274 :group 'supercite-attr) |
| 4850 | 275 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
276 (defcustom sc-default-attribution "Anon" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
277 "*String used when author's attribution cannot be determined." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
278 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
279 :group 'supercite-attr) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
280 (defcustom sc-default-author-name "Anonymous" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
281 "*String used when author's name cannot be determined." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
282 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
283 :group 'supercite-attr) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
284 (defcustom sc-downcase-p nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
285 "*Non-nil means downcase the attribution and citation strings." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
286 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
287 :group 'supercite-attr |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
288 :group 'supercite-cite) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
289 (defcustom sc-electric-circular-p t |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
290 "*If non-nil, treat electric references as circular." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
291 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
292 :group 'supercite-attr) |
| 4850 | 293 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
294 (defcustom sc-electric-mode-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
295 "*Hook for `sc-electric-mode' electric references mode." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
296 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
297 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
298 (defcustom sc-electric-references-p nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
299 "*Use electric references if non-nil." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
300 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
301 :group 'supercite) |
| 4850 | 302 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
303 (defcustom sc-fixup-whitespace-p nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
304 "*If non-nil, delete all leading white space before citing." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
305 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
306 :group 'supercite) |
| 4850 | 307 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
308 (defcustom sc-load-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
309 "*Hook which gets run once after Supercite loads." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
310 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
311 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
312 (defcustom sc-pre-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
313 "*Hook which gets run before each invocation of `sc-cite-original'." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
314 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
315 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
316 (defcustom sc-post-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
317 "*Hook which gets run after each invocation of `sc-cite-original'." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
318 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
319 :group 'supercite-hooks) |
| 4850 | 320 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
321 (defcustom sc-mail-warn-if-non-rfc822-p t |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
322 "*Warn if mail headers don't conform to RFC822." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
323 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
324 :group 'supercite-attr) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
325 (defcustom sc-mumble "" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
326 "*Value returned by `sc-mail-field' if field isn't in mail headers." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
327 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
328 :group 'supercite-attr) |
| 4850 | 329 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
330 (defcustom sc-name-filter-alist |
| 4850 | 331 '(("^\\(Mr\\|Mrs\\|Ms\\|Dr\\)[.]?$" . 0) |
| 332 ("^\\(Jr\\|Sr\\)[.]?$" . last) | |
| 333 ("^ASTS$" . 0) | |
| 334 ("^[I]+$" . last)) | |
| 335 "*Name list components which are filtered out as noise. | |
| 336 This variable contains an association list where each element is of | |
| 337 the form: (REGEXP . POSITION). | |
| 338 | |
| 339 REGEXP is a regular expression which matches the name list component. | |
| 340 Match is performed using `string-match'. POSITION is the position in | |
| 341 the name list which can match the regular expression, starting at zero | |
| 342 for the first element. Use `last' to match the last element in the | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
343 list and `any' to match all elements." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
344 :type '(repeat (cons regexp (choice (const last) (const any) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
345 (integer :tag "position")))) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
346 :group 'supercite-attr) |
| 4850 | 347 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
348 (defcustom sc-nested-citation-p nil |
| 4850 | 349 "*Controls whether to use nested or non-nested citation style. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
350 Non-nil uses nested citations, nil uses non-nested citations." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
351 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
352 :group 'supercite) |
| 4850 | 353 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
354 (defcustom sc-nuke-mail-headers 'all |
| 4850 | 355 "*Controls mail header nuking. |
|
60924
fb2b49a3a4e0
* mail/supercite.el: Replace `legal' with `valid'.
Werner LEMBERG <wl@gnu.org>
parents:
60916
diff
changeset
|
356 Used in conjunction with `sc-nuke-mail-header-list'. Valid values are: |
| 4850 | 357 |
| 358 `all' -- nuke all mail headers | |
| 359 `none' -- don't nuke any mail headers | |
| 360 `specified' -- nuke headers specified in `sc-nuke-mail-header-list' | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
361 `keep' -- keep headers specified in `sc-nuke-mail-header-list'" |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
362 :type '(choice (const all) (const none) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
363 (const specified) (const keep)) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
364 :group 'supercite) |
| 4850 | 365 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
366 (defcustom sc-nuke-mail-header-list nil |
| 4850 | 367 "*List of mail header regexps to remove or keep in body of reply. |
| 368 This list contains regular expressions describing the mail headers to | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
369 keep or nuke, depending on the value of `sc-nuke-mail-headers'." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
370 :type '(repeat regexp) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
371 :group 'supercite) |
| 4850 | 372 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
373 (defcustom sc-preferred-attribution-list |
| 4850 | 374 '("sc-lastchoice" "x-attribution" "firstname" "initials" "lastname") |
| 375 "*Specifies what to use as the attribution string. | |
| 376 Supercite creates a list of possible attributions when it scans the | |
| 377 mail headers from the original message. Each attribution choice is | |
| 378 associated with a key in an attribution alist. Supercite tries to | |
| 379 pick a \"preferred\" attribution by matching the attribution alist | |
| 380 keys against the elements in `sc-preferred-attribution-list' in order. | |
| 381 The first non-empty string value found is used as the preferred | |
| 382 attribution. | |
| 383 | |
| 384 Note that Supercite now honors the X-Attribution: mail field. If | |
| 385 present in the original message, the value of this field should always | |
| 386 be used to select the most preferred attribution since it reflects how | |
| 387 the original author would like to be distinguished. It should be | |
| 388 considered bad taste to put any attribution preference key before | |
| 389 \"x-attribution\" in this list, except perhaps for \"sc-lastchoice\" | |
| 7639 | 390 \(see below). |
| 4850 | 391 |
| 392 Supercite remembers the last attribution used when reciting an already | |
| 393 cited paragraph. This attribution will always be saved with the | |
| 394 \"sc-lastchoice\" key, which can be used in this list. Note that the | |
| 395 last choice is always reset after every call of `sc-cite-original'. | |
| 396 | |
| 397 Barring error conditions, the following preferences are always present | |
| 398 in the attribution alist: | |
| 399 | |
| 400 \"emailname\" -- email terminus name | |
| 401 \"initials\" -- initials of author | |
| 402 \"firstname\" -- first name of author | |
| 403 \"lastname\" -- last name of author | |
| 404 \"middlename-1\" -- first middle name of author | |
| 405 \"middlename-2\" -- second middle name of author | |
| 406 ... | |
| 407 | |
| 408 Middle name indexes can be any positive integer greater than 0, | |
| 409 although it is unlikely that many authors will supply more than one | |
| 410 middle name, if that many. The string of all middle names is | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
411 associated with the key \"middlenames\"." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
412 :type '(repeat string) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
413 :group 'supercite-attr) |
| 4850 | 414 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
415 (defcustom sc-attrib-selection-list nil |
| 4850 | 416 "*An alist for selecting preferred attribution based on mail headers. |
| 417 Each element of this list has the following form: | |
| 418 | |
| 419 (INFOKEY ((REGEXP . ATTRIBUTION) | |
| 420 (REGEXP . ATTRIBUTION) | |
| 421 (...))) | |
| 422 | |
| 423 Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular | |
| 424 expression to match against the INFOKEY's value. ATTRIBUTION can be a | |
| 425 string or a list. If its a string, then it is the attribution that is | |
| 426 selected by `sc-select-attribution'. If it is a list, it is `eval'd | |
| 427 and the return value must be a string, which is used as the selected | |
| 428 attribution. Note that the variable `sc-preferred-attribution-list' | |
| 429 must contain an element of the string \"sc-consult\" for this variable | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
430 to be consulted during attribution selection." |
|
24613
83a507b08fe1
(sc-scan-info-alist): Revert last change.
Dave Love <fx@gnu.org>
parents:
24612
diff
changeset
|
431 :type '(repeat (list string |
|
83a507b08fe1
(sc-scan-info-alist): Revert last change.
Dave Love <fx@gnu.org>
parents:
24612
diff
changeset
|
432 (repeat (cons regexp |
|
83a507b08fe1
(sc-scan-info-alist): Revert last change.
Dave Love <fx@gnu.org>
parents:
24612
diff
changeset
|
433 (choice (sexp :tag "List to eval") |
|
83a507b08fe1
(sc-scan-info-alist): Revert last change.
Dave Love <fx@gnu.org>
parents:
24612
diff
changeset
|
434 string))))) |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
435 :group 'supercite-attr) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
436 (put 'sc-attrib-selection-list 'risky-local-variable t) |
| 4850 | 437 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
438 (defcustom sc-attribs-preselect-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
439 "*Hook to run before selecting an attribution." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
440 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
441 :group 'supercite-attr |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
442 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
443 (defcustom sc-attribs-postselect-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
444 "*Hook to run after selecting an attribution, but before confirmation." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
445 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
446 :group 'supercite-attr |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
447 :group 'supercite-hooks) |
| 4850 | 448 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
449 (defcustom sc-pre-cite-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
450 "*Hook to run before citing a region of text." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
451 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
452 :group 'supercite-cite |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
453 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
454 (defcustom sc-pre-uncite-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
455 "*Hook to run before unciting a region of text." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
456 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
457 :group 'supercite-cite |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
458 :group 'supercite-hooks) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
459 (defcustom sc-pre-recite-hook nil |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
460 "*Hook to run before reciting a region of text." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
461 :type 'hook |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
462 :group 'supercite-cite |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
463 :group 'supercite-hooks) |
| 4850 | 464 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
465 (defcustom sc-preferred-header-style 4 |
| 4850 | 466 "*Index into `sc-rewrite-header-list' specifying preferred header style. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
467 Index zero accesses the first function in the list." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
468 :type 'integer |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
469 :group 'supercite) |
| 4850 | 470 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
471 (defcustom sc-reference-tag-string ">>>>> " |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
472 "*String used at the beginning of built-in reference headers." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
473 :type 'string |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
474 :group 'supercite) |
| 4850 | 475 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
476 (defcustom sc-rewrite-header-list |
| 4850 | 477 '((sc-no-header) |
| 478 (sc-header-on-said) | |
| 479 (sc-header-inarticle-writes) | |
| 480 (sc-header-regarding-adds) | |
| 481 (sc-header-attributed-writes) | |
| 482 (sc-header-author-writes) | |
| 483 (sc-header-verbose) | |
| 484 (sc-no-blank-line-or-header) | |
| 485 ) | |
| 486 "*List of reference header rewrite functions. | |
| 487 The variable `sc-preferred-header-style' controls which function in | |
| 488 this list is chosen for automatic reference header insertions. | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
489 Electric reference mode will cycle through this list of functions." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
490 :type '(repeat sexp) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
491 :group 'supercite) |
|
62315
c37dfc8054d6
(sc-cite-frame-alist, sc-uncite-frame-alist)
Richard M. Stallman <rms@gnu.org>
parents:
61282
diff
changeset
|
492 (put 'sc-rewrite-header-list 'risky-local-variable t) |
| 4850 | 493 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
494 (defcustom sc-titlecue-regexp "\\s +-+\\s +" |
| 4850 | 495 "*Regular expression describing the separator between names and titles. |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
496 Set to nil to treat entire field as a name." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
497 :type '(choice (const :tag "entire field as name" nil) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
498 regexp) |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
499 :group 'supercite-attr) |
| 4850 | 500 |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
501 (defcustom sc-use-only-preference-p nil |
| 4850 | 502 "*Controls what happens when the preferred attribution cannot be found. |
| 503 If non-nil, then `sc-default-attribution' will be used. If nil, then | |
| 504 some secondary scheme will be employed to find a suitable attribution | |
|
17489
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
505 string." |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
506 :type 'boolean |
|
cb41a5b41836
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
507 :group 'supercite-attr) |
| 4850 | 508 |
| 509 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 510 ;; end user configuration variables | |
| 511 | |
| 512 (defconst sc-version "3.1" | |
| 513 "Supercite version number.") | |
|
22646
d5b24acb8f9b
(sc-help-address): Use an alias at gnu.org.
Richard M. Stallman <rms@gnu.org>
parents:
22592
diff
changeset
|
514 (defconst sc-help-address "bug-supercite@gnu.org" |
| 4850 | 515 "Address accepting submissions of bug reports.") |
| 516 | |
| 517 (defvar sc-mail-info nil | |
| 518 "Alist of mail header information gleaned from reply buffer.") | |
| 519 (defvar sc-attributions nil | |
| 520 "Alist of attributions for use when citing.") | |
| 521 | |
| 522 (defvar sc-tmp-nested-regexp nil | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
523 "Temporary regexp describing nested citations.") |
| 4850 | 524 (defvar sc-tmp-nonnested-regexp nil |
| 525 "Temporary regexp describing non-nested citations.") | |
| 526 (defvar sc-tmp-dumb-regexp nil | |
| 527 "Temp regexp describing non-nested citation cited with a nesting citer.") | |
| 528 | |
| 529 (make-variable-buffer-local 'sc-mail-info) | |
| 530 (make-variable-buffer-local 'sc-attributions) | |
| 531 | |
| 532 | |
| 533 ;; ====================================================================== | |
| 534 ;; supercite keymaps | |
| 535 | |
| 536 (defvar sc-mode-map-prefix "\C-c\C-p" | |
| 537 "*Key binding to install Supercite keymap. | |
| 538 If this is nil, Supercite keymap is not installed.") | |
| 539 | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
540 (defvar sc-T-keymap |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
541 (let ((map (make-sparse-keymap))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
542 (define-key map "a" 'sc-S-preferred-attribution-list) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
543 (define-key map "b" 'sc-T-mail-nuke-blank-lines) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
544 (define-key map "c" 'sc-T-confirm-always) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
545 (define-key map "d" 'sc-T-downcase) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
546 (define-key map "e" 'sc-T-electric-references) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
547 (define-key map "f" 'sc-T-auto-fill-region) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
548 (define-key map "h" 'sc-T-describe) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
549 (define-key map "l" 'sc-S-cite-region-limit) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
550 (define-key map "n" 'sc-S-mail-nuke-mail-headers) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
551 (define-key map "N" 'sc-S-mail-header-nuke-list) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
552 (define-key map "o" 'sc-T-electric-circular) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
553 (define-key map "p" 'sc-S-preferred-header-style) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
554 (define-key map "s" 'sc-T-nested-citation) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
555 (define-key map "u" 'sc-T-use-only-preferences) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
556 (define-key map "w" 'sc-T-fixup-whitespace) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
557 (define-key map "?" 'sc-T-describe) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
558 map) |
| 4850 | 559 "Keymap for sub-keymap of setting and toggling functions.") |
| 560 | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
561 (defvar sc-mode-map |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
562 (let ((map (make-sparse-keymap))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
563 (define-key map "c" 'sc-cite-region) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
564 (define-key map "f" 'sc-mail-field-query) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
565 (define-key map "g" 'sc-mail-process-headers) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
566 (define-key map "h" 'sc-describe) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
567 (define-key map "i" 'sc-insert-citation) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
568 (define-key map "o" 'sc-open-line) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
569 (define-key map "r" 'sc-recite-region) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
570 (define-key map "\C-p" 'sc-raw-mode-toggle) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
571 (define-key map "u" 'sc-uncite-region) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
572 (define-key map "v" 'sc-version) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
573 (define-key map "w" 'sc-insert-reference) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
574 (define-key map "\C-t" sc-T-keymap) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
575 (define-key map "\C-b" 'sc-submit-bug-report) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
576 (define-key map "?" 'sc-describe) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
577 map) |
| 4850 | 578 "Keymap for Supercite quasi-mode.") |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
579 |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
580 (defvar sc-electric-mode-map |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
581 (let ((map (make-sparse-keymap))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
582 (define-key map "p" 'sc-eref-prev) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
583 (define-key map "n" 'sc-eref-next) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
584 (define-key map "s" 'sc-eref-setn) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
585 (define-key map "j" 'sc-eref-jump) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
586 (define-key map "x" 'sc-eref-abort) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
587 (define-key map "q" 'sc-eref-abort) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
588 (define-key map "\r" 'sc-eref-exit) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
589 (define-key map "\n" 'sc-eref-exit) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
590 (define-key map "g" 'sc-eref-goto) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
591 (define-key map "?" 'describe-mode) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
592 (define-key map "\C-h" 'describe-mode) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
593 (define-key map [f1] 'describe-mode) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
594 (define-key map [help] 'describe-mode) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
595 map) |
| 4850 | 596 "Keymap for `sc-electric-mode' electric references mode.") |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
597 |
| 4850 | 598 |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
599 (defvar sc-minibuffer-local-completion-map |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
600 (let ((map (copy-keymap minibuffer-local-completion-map))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
601 (define-key map "\C-t" 'sc-toggle-fn) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
602 (define-key map " " 'self-insert-command) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
603 map) |
| 4850 | 604 "Keymap for minibuffer confirmation of attribution strings.") |
| 605 | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
606 (defvar sc-minibuffer-local-map |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
607 (let ((map (copy-keymap minibuffer-local-map))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
608 (define-key map "\C-t" 'sc-toggle-fn) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
609 map) |
| 4850 | 610 "Keymap for minibuffer confirmation of attribution strings.") |
| 611 | |
| 612 | |
| 613 ;; ====================================================================== | |
| 614 ;; utility functions | |
| 615 | |
| 616 (defun sc-ask (alist) | |
| 617 "Ask a question in the minibuffer requiring a single character answer. | |
| 618 This function is kind of an extension of `y-or-n-p' where a single | |
| 619 letter is used to answer a question. Question is formed from ALIST | |
| 620 which has members of the form: (WORD . LETTER). WORD is the long | |
| 621 word form, while LETTER is the letter for selecting that answer. The | |
| 622 selected letter is returned, or nil if the question was not answered. | |
| 623 Note that WORD is a string and LETTER is a character. All LETTERs in | |
| 624 the list should be unique." | |
| 625 (let* ((prompt (concat | |
| 626 (mapconcat (function (lambda (elt) (car elt))) alist ", ") | |
| 627 "? (" | |
| 628 (mapconcat | |
| 629 (function | |
| 630 (lambda (elt) (char-to-string (cdr elt)))) alist "/") | |
| 631 ") ")) | |
| 632 (p prompt) | |
| 633 (event | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
634 (if (fboundp 'allocate-event) |
| 4850 | 635 (allocate-event) |
| 636 nil))) | |
| 637 (while (stringp p) | |
| 638 (if (let ((cursor-in-echo-area t) | |
| 639 (inhibit-quit t)) | |
| 640 (message "%s" p) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
641 (setq event (read-event)) |
| 4850 | 642 (prog1 quit-flag (setq quit-flag nil))) |
| 643 (progn | |
| 644 (message "%s%s" p (single-key-description event)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
645 (and (fboundp 'deallocate-event) |
| 4850 | 646 (deallocate-event event)) |
| 647 (setq quit-flag nil) | |
| 648 (signal 'quit '()))) | |
| 649 (let ((char | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
650 (if (featurep 'xemacs) |
| 4850 | 651 (let* ((key (and (key-press-event-p event) (event-key event))) |
| 652 (char (and key (event-to-character event)))) | |
| 653 char) | |
| 654 event)) | |
| 655 elt) | |
| 656 (if char (setq char (downcase char))) | |
| 657 (cond | |
| 658 ((setq elt (rassq char alist)) | |
| 659 (message "%s%s" p (car elt)) | |
| 660 (setq p (cdr elt))) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
661 ((and (fboundp 'button-release-event-p) |
| 4850 | 662 (button-release-event-p event)) ; ignore them |
| 663 nil) | |
| 664 (t | |
| 665 (message "%s%s" p (single-key-description event)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
666 (if (featurep 'xemacs) |
| 4850 | 667 (ding nil 'y-or-n-p) |
| 668 (ding)) | |
| 669 (discard-input) | |
| 670 (if (eq p prompt) | |
| 671 (setq p (concat "Try again. " prompt))))))) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
672 (and (fboundp 'deallocate-event) |
| 4850 | 673 (deallocate-event event)) |
| 674 p)) | |
| 675 | |
| 676 (defun sc-scan-info-alist (alist) | |
| 677 "Find a match in the info alist that matches a regexp in ALIST." | |
| 678 (let ((sc-mumble "") | |
| 679 rtnvalue) | |
| 680 (while alist | |
| 681 (let* ((elem (car alist)) | |
| 682 (infokey (car elem)) | |
| 683 (infoval (sc-mail-field infokey)) | |
| 684 (mlist (car (cdr elem)))) | |
| 685 (while mlist | |
| 686 (let* ((ml-elem (car mlist)) | |
| 687 (regexp (car ml-elem)) | |
| 688 (thing (cdr ml-elem))) | |
| 689 (if (string-match regexp infoval) | |
| 690 ;; we found a match, time to return | |
|
24613
83a507b08fe1
(sc-scan-info-alist): Revert last change.
Dave Love <fx@gnu.org>
parents:
24612
diff
changeset
|
691 (setq rtnvalue thing |
| 4850 | 692 mlist nil |
| 693 alist nil) | |
| 694 ;; else we didn't find a match | |
| 695 (setq mlist (cdr mlist)) | |
| 696 ))) ;end of mlist loop | |
| 697 (setq alist (cdr alist)) | |
| 698 )) ;end of alist loop | |
| 699 rtnvalue)) | |
| 700 | |
| 701 | |
| 702 ;; ====================================================================== | |
| 703 ;; extract mail field information from headers in reply buffer | |
| 704 | |
| 705 ;; holder variables for bc happiness | |
| 706 (defvar sc-mail-headers-start nil | |
| 707 "Start of header fields.") | |
| 708 (defvar sc-mail-headers-end nil | |
| 709 "End of header fields.") | |
| 710 (defvar sc-mail-field-history nil | |
| 711 "For minibuffer completion on mail field queries.") | |
| 712 (defvar sc-mail-field-modification-history nil | |
| 713 "For minibuffer completion on mail field modifications.") | |
| 714 (defvar sc-mail-glom-frame | |
| 715 '((begin (setq sc-mail-headers-start (point))) | |
| 716 ("^x-attribution:[ \t]+.*$" (sc-mail-fetch-field t) nil t) | |
| 717 ("^\\S +:.*$" (sc-mail-fetch-field) nil t) | |
| 718 ("^$" (list 'abort '(step . 0))) | |
| 719 ("^[ \t]+" (sc-mail-append-field)) | |
| 720 (sc-mail-warn-if-non-rfc822-p (sc-mail-error-in-mail-field)) | |
| 721 (end (setq sc-mail-headers-end (point)))) | |
| 722 "Regi frame for glomming mail header information.") | |
|
63056
095901aead41
(sc-mail-glom-frame): Mark as risky.
Richard M. Stallman <rms@gnu.org>
parents:
62924
diff
changeset
|
723 (put 'sc-mail-glom-frame 'risky-local-variable t) |
| 4850 | 724 |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
725 (defvar curline) ; dynamic bondage |
| 28437 | 726 |
| 4850 | 727 ;; regi functions |
| 728 (defun sc-mail-fetch-field (&optional attribs-p) | |
| 729 "Insert a key and value into `sc-mail-info' alist. | |
| 730 If optional ATTRIBS-P is non-nil, the key/value pair is placed in | |
| 731 `sc-attributions' too." | |
| 732 (if (string-match "^\\(\\S *\\)\\s *:\\s +\\(.*\\)$" curline) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
733 (let* ((key (downcase (match-string-no-properties 1 curline))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
734 (val (match-string-no-properties 2 curline)) |
| 4850 | 735 (keyval (cons key val))) |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
736 (push keyval sc-mail-info) |
| 4850 | 737 (if attribs-p |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
738 (push keyval sc-attributions)))) |
| 4850 | 739 nil) |
| 740 | |
| 741 (defun sc-mail-append-field () | |
| 742 "Append a continuation line onto the last fetched mail field's info." | |
| 743 (let ((keyval (car sc-mail-info))) | |
| 744 (if (and keyval (string-match "^\\s *\\(.*\\)$" curline)) | |
|
11556
a83ee7a1e0fd
Made sc-string-text to strip of text properties of buffer text, so string
Simon Marshall <simon@gnu.org>
parents:
9845
diff
changeset
|
745 (setcdr keyval (concat (cdr keyval) " " |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
746 (match-string-no-properties 1 curline))))) |
| 4850 | 747 nil) |
| 748 | |
| 749 (defun sc-mail-error-in-mail-field () | |
| 750 "Issue warning that mail headers don't conform to RFC 822." | |
| 751 (let* ((len (min (length curline) 10)) | |
| 752 (ellipsis (if (< len (length curline)) "..." "")) | |
| 753 (msg "Mail header \"%s%s\" doesn't conform to RFC 822. skipping...")) | |
| 754 (message msg (substring curline 0 len) ellipsis)) | |
| 755 (beep) | |
| 756 (sit-for 2) | |
| 757 nil) | |
| 758 | |
| 759 ;; mail header nuking | |
| 760 (defvar sc-mail-last-header-nuked-p nil | |
| 761 "True if the last header was nuked.") | |
| 762 | |
| 763 (defun sc-mail-nuke-line () | |
| 764 "Nuke the current mail header line." | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
765 (delete-region (line-beginning-position) (line-beginning-position 2)) |
| 4850 | 766 '((step . -1))) |
| 767 | |
| 768 (defun sc-mail-nuke-header-line () | |
| 769 "Delete current-line and set up for possible continuation." | |
| 770 (setq sc-mail-last-header-nuked-p t) | |
| 771 (sc-mail-nuke-line)) | |
| 772 | |
| 773 (defun sc-mail-nuke-continuation-line () | |
| 774 "Delete a continuation line if the last header line was deleted." | |
| 775 (if sc-mail-last-header-nuked-p | |
| 776 (sc-mail-nuke-line))) | |
| 777 | |
| 778 (defun sc-mail-cleanup-blank-lines () | |
| 779 "Leave some blank lines after original mail headers are nuked. | |
| 780 The number of lines left is specified by `sc-blank-lines-after-headers'." | |
| 781 (if sc-blank-lines-after-headers | |
| 782 (save-restriction | |
| 783 (widen) | |
| 784 (skip-chars-backward " \t\n") | |
| 785 (forward-line 1) | |
| 786 (delete-blank-lines) | |
| 787 (beginning-of-line) | |
| 788 (if (looking-at "[ \t]*$") | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
789 (delete-region (line-beginning-position) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
790 (line-beginning-position 2))) |
| 4850 | 791 (insert-char ?\n sc-blank-lines-after-headers))) |
| 792 nil) | |
| 793 | |
| 794 (defun sc-mail-build-nuke-frame () | |
| 795 "Build the regiframe for nuking mail headers." | |
| 796 (let (every-func entry-func nonentry-func) | |
| 797 (cond | |
| 798 ((eq sc-nuke-mail-headers 'all) | |
| 799 (setq every-func '(progn (forward-line -1) (sc-mail-nuke-line)))) | |
| 800 ((eq sc-nuke-mail-headers 'specified) | |
| 801 (setq entry-func '(sc-mail-nuke-header-line) | |
| 802 nonentry-func '(setq sc-mail-last-header-nuked-p nil))) | |
| 803 ((eq sc-nuke-mail-headers 'keep) | |
| 804 (setq entry-func '(setq sc-mail-last-header-nuked-p nil) | |
| 805 nonentry-func '(sc-mail-nuke-header-line))) | |
| 806 ;; we never get far enough to interpret a frame if s-n-m-h == 'none | |
| 807 ((eq sc-nuke-mail-headers 'none)) | |
|
60916
480134f8cd16
* mail/supercite.el: Replace `illegal' with `invalid'.
Werner LEMBERG <wl@gnu.org>
parents:
58952
diff
changeset
|
808 (t (error "Invalid value for sc-nuke-mail-headers: %s" |
| 4850 | 809 sc-nuke-mail-headers)) |
| 810 ) ; end-cond | |
| 811 (append | |
| 812 (and entry-func | |
| 813 (regi-mapcar sc-nuke-mail-header-list entry-func nil t)) | |
| 814 (and nonentry-func (list (list "^\\S +:.*$" nonentry-func))) | |
| 815 (and (not every-func) | |
| 816 '(("^[ \t]+" (sc-mail-nuke-continuation-line)))) | |
| 817 '((begin (setq sc-mail-last-header-zapped-p nil))) | |
| 818 '((end (sc-mail-cleanup-blank-lines))) | |
| 819 (and every-func (list (list 'every every-func))) | |
| 820 ))) | |
| 821 | |
| 822 ;; mail processing and zapping. this is the top level entry defun to | |
| 823 ;; all header processing. | |
| 824 (defun sc-mail-process-headers (start end) | |
| 825 "Process original mail message's mail headers. | |
| 826 After processing, mail headers may be nuked. Header information is | |
| 827 stored in `sc-mail-info', and any old information is lost unless an | |
| 828 error occurs." | |
| 829 (interactive "r") | |
| 830 (let ((info (copy-alist sc-mail-info)) | |
| 831 (attribs (copy-alist sc-attributions))) | |
| 832 (setq sc-mail-info nil | |
| 833 sc-attributions nil) | |
| 834 (regi-interpret sc-mail-glom-frame start end) | |
| 835 (if (null sc-mail-info) | |
| 836 (progn | |
| 837 (message "No mail headers found! Restoring old information.") | |
| 838 (setq sc-mail-info info | |
| 839 sc-attributions attribs)) | |
| 840 (regi-interpret (sc-mail-build-nuke-frame) | |
| 841 sc-mail-headers-start sc-mail-headers-end) | |
| 842 ))) | |
| 843 | |
| 844 | |
| 845 ;; let the user change mail field information | |
| 846 (defun sc-mail-field (field) | |
| 847 "Return the mail header field value associated with FIELD. | |
| 848 If there was no mail header with FIELD as its key, return the value of | |
| 849 `sc-mumble'. FIELD is case insensitive." | |
|
61044
17207b620cf3
(sc-mail-field): Use assoc-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60924
diff
changeset
|
850 (or (cdr (assoc-string field sc-mail-info 'case-fold)) sc-mumble)) |
| 4850 | 851 |
| 852 (defun sc-mail-field-query (arg) | |
| 853 "View the value of a mail field. | |
| 854 With `\\[universal-argument]', prompts for action on mail field. | |
| 855 Action can be one of: View, Modify, Add, or Delete." | |
| 856 (interactive "P") | |
| 857 (let* ((alist '(("view" . ?v) ("modify" . ?m) ("add" . ?a) ("delete" . ?d))) | |
| 858 (action (if (not arg) ?v (sc-ask alist))) | |
| 859 key) | |
| 860 (if (not action) | |
| 861 () | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
862 (setq key (completing-read |
| 4850 | 863 (concat (car (rassq action alist)) |
| 864 " information key: ") | |
| 865 sc-mail-info nil | |
| 866 (if (eq action ?a) nil 'noexit) | |
| 867 nil 'sc-mail-field-history)) | |
| 868 (cond | |
| 869 ((eq action ?v) | |
| 870 (message "%s: %s" key (cdr (assoc key sc-mail-info)))) | |
| 871 ((eq action ?d) | |
| 872 (setq sc-mail-info (delq (assoc key sc-mail-info) sc-mail-info))) | |
| 873 ((eq action ?m) | |
| 874 (let ((keyval (assoc key sc-mail-info))) | |
| 875 ;; first put initial value onto list if not already there | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
876 (if (not (member (cdr keyval) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
877 sc-mail-field-modification-history)) |
| 4850 | 878 (setq sc-mail-field-modification-history |
| 879 (cons (cdr keyval) sc-mail-field-modification-history))) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
880 (setcdr keyval (read-string |
| 4850 | 881 (concat key ": ") (cdr keyval) |
| 882 'sc-mail-field-modification-history)))) | |
| 883 ((eq action ?a) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
884 (push (cons key (read-string (concat key ": "))) sc-mail-info)) |
| 4850 | 885 )))) |
| 886 | |
| 887 | |
| 888 ;; ====================================================================== | |
| 889 ;; attributions | |
| 890 | |
| 891 (defvar sc-attribution-confirmation-history nil | |
| 892 "History for confirmation of attribution strings.") | |
| 893 (defvar sc-citation-confirmation-history nil | |
| 894 "History for confirmation of attribution prefixes.") | |
| 895 | |
| 896 (defun sc-attribs-%@-addresses (from &optional delim) | |
| 897 "Extract the author's email terminus from email address FROM. | |
| 898 Match addresses of the style ``name%[stuff].'' when called with DELIM | |
| 899 of \"%\" and addresses of the style ``[stuff]name@[stuff]'' when | |
| 900 called with DELIM \"@\". If DELIM is nil or not provided, matches | |
| 901 addresses of the style ``name''." | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
902 (and (string-match (concat "[-[:alnum:]_.]+" delim) from 0) |
| 4850 | 903 (substring from |
| 904 (match-beginning 0) | |
| 905 (- (match-end 0) (if (null delim) 0 1))))) | |
| 906 | |
| 907 (defun sc-attribs-!-addresses (from) | |
| 908 "Extract the author's email terminus from email address FROM. | |
| 909 Match addresses of the style ``[stuff]![stuff]...!name[stuff].''" | |
| 910 (let ((eos (length from)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
911 (mstart (string-match "![-[:alnum:]_.]+\\([^-![:alnum:]_.]\\|$\\)" |
| 4850 | 912 from 0)) |
| 913 (mend (match-end 0))) | |
| 914 (and mstart | |
| 915 (substring from (1+ mstart) (- mend (if (= mend eos) 0 1))) | |
| 916 ))) | |
| 917 | |
| 918 (defun sc-attribs-<>-addresses (from) | |
| 919 "Extract the author's email terminus from email address FROM. | |
| 920 Match addresses of the style ``<name[stuff]>.''" | |
| 921 (and (string-match "<\\(.*\\)>" from) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
922 (match-string 1 from))) |
| 4850 | 923 |
| 924 (defun sc-get-address (from author) | |
| 925 "Get the full email address path from FROM. | |
| 926 AUTHOR is the author's name (which is removed from the address)." | |
| 927 (let ((eos (length from))) | |
|
61044
17207b620cf3
(sc-mail-field): Use assoc-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60924
diff
changeset
|
928 (if (string-match (concat "\\`\"?" (regexp-quote author) |
|
17207b620cf3
(sc-mail-field): Use assoc-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60924
diff
changeset
|
929 "\"?\\s +") from 0) |
| 4850 | 930 (let ((address (substring from (match-end 0) eos))) |
| 931 (if (and (= (aref address 0) ?<) | |
| 932 (= (aref address (1- (length address))) ?>)) | |
| 933 (substring address 1 (1- (length address))) | |
| 934 address)) | |
| 28437 | 935 (if (string-match "[-[:alnum:]!@%._]+" from 0) |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
936 (match-string 0 from) |
| 4850 | 937 "") |
| 938 ))) | |
| 939 | |
| 940 (defun sc-attribs-emailname (from) | |
| 941 "Get the email terminus name from FROM." | |
| 942 (or | |
| 943 (sc-attribs-%@-addresses from "%") | |
| 944 (sc-attribs-%@-addresses from "@") | |
| 945 (sc-attribs-!-addresses from) | |
| 946 (sc-attribs-<>-addresses from) | |
| 947 (sc-attribs-%@-addresses from) | |
| 948 (substring from 0 10))) | |
| 949 | |
| 950 (defun sc-name-substring (string start end extend) | |
| 951 "Extract the specified substring of STRING from START to END. | |
| 952 EXTEND is the number of characters on each side to extend the | |
| 953 substring." | |
| 954 (and start | |
| 955 (let ((sos (+ start extend)) | |
| 956 (eos (- end extend))) | |
| 957 (substring string sos | |
| 958 (or (string-match sc-titlecue-regexp string sos) eos) | |
| 959 )))) | |
| 960 | |
| 961 (defun sc-attribs-extract-namestring (from) | |
| 962 "Extract the name string from FROM. | |
| 963 This should be the author's full name minus an optional title." | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
964 ;; FIXME: we probably should use mail-extract-address-components. |
| 4850 | 965 (let ((namestring |
| 966 (or | |
|
12859
90c22a02c12b
(sc-attribs-extract-namestring): If name has <...>,
Richard M. Stallman <rms@gnu.org>
parents:
12425
diff
changeset
|
967 ;; If there is a <...> in the name, |
|
90c22a02c12b
(sc-attribs-extract-namestring): If name has <...>,
Richard M. Stallman <rms@gnu.org>
parents:
12425
diff
changeset
|
968 ;; treat everything before that as the full name. |
|
90c22a02c12b
(sc-attribs-extract-namestring): If name has <...>,
Richard M. Stallman <rms@gnu.org>
parents:
12425
diff
changeset
|
969 ;; Even if it contains parens, use the whole thing. |
|
13813
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
970 ;; On the other hand, we do look for quotes in the usual way. |
|
12859
90c22a02c12b
(sc-attribs-extract-namestring): If name has <...>,
Richard M. Stallman <rms@gnu.org>
parents:
12425
diff
changeset
|
971 (and (string-match " *<.*>" from 0) |
|
13813
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
972 (let ((before-angles |
|
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
973 (sc-name-substring from 0 (match-beginning 0) 0))) |
|
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
974 (if (string-match "\".*\"" before-angles 0) |
|
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
975 (sc-name-substring |
|
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
976 before-angles (match-beginning 0) (match-end 0) 1) |
|
7d18fdd1acf4
(sc-attribs-extract-namestring): Do look for
Karl Heuer <kwzh@gnu.org>
parents:
12859
diff
changeset
|
977 before-angles))) |
| 4850 | 978 (sc-name-substring |
| 979 from (string-match "(.*)" from 0) (match-end 0) 1) | |
| 980 (sc-name-substring | |
| 981 from (string-match "\".*\"" from 0) (match-end 0) 1) | |
| 982 (sc-name-substring | |
| 28437 | 983 from (string-match "\\([-.[:alnum:]_]+\\s +\\)+<" from 0) |
| 4850 | 984 (match-end 1) 0) |
| 985 (sc-attribs-emailname from)))) | |
| 986 ;; strip off any leading or trailing whitespace | |
| 987 (if namestring | |
| 988 (let ((bos 0) | |
| 989 (eos (1- (length namestring)))) | |
| 990 (while (and (<= bos eos) | |
| 991 (memq (aref namestring bos) '(32 ?\t))) | |
| 992 (setq bos (1+ bos))) | |
| 993 (while (and (> eos bos) | |
| 994 (memq (aref namestring eos) '(32 ?\t))) | |
| 995 (setq eos (1- eos))) | |
| 996 (substring namestring bos (1+ eos)))))) | |
| 997 | |
| 998 (defun sc-attribs-chop-namestring (namestring) | |
| 999 "Convert NAMESTRING to a list of names. | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1000 example: (sc-attribs-chop-namestring \"John Xavier Doe\") |
| 4850 | 1001 => (\"John\" \"Xavier\" \"Doe\")" |
| 1002 (if (string-match "\\([ \t]*\\)\\([^ \t._]+\\)\\([ \t]*\\)" namestring) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1003 (cons (match-string 2 namestring) |
| 4850 | 1004 (sc-attribs-chop-namestring (substring namestring (match-end 3))) |
| 1005 ))) | |
| 1006 | |
| 1007 (defun sc-attribs-strip-initials (namelist) | |
| 1008 "Extract the author's initials from the NAMELIST." | |
| 1009 (mapconcat | |
| 1010 (function | |
| 1011 (lambda (name) | |
| 1012 (if (< 0 (length name)) | |
| 1013 (substring name 0 1)))) | |
| 1014 namelist "")) | |
| 1015 | |
| 1016 (defun sc-guess-attribution (&optional string) | |
| 1017 "Guess attribution string on current line. | |
| 1018 If attribution cannot be guessed, nil is returned. Optional STRING if | |
| 1019 supplied, is used instead of the line point is on in the current buffer." | |
| 1020 (let ((start 0) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1021 (string (or string (buffer-substring (line-beginning-position) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1022 (line-end-position)))) |
| 4850 | 1023 attribution) |
| 1024 (and | |
| 1025 (= start (or (string-match sc-citation-leader-regexp string start) -1)) | |
| 1026 (setq start (match-end 0)) | |
| 1027 (= start (or (string-match sc-citation-root-regexp string start) 1)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1028 (setq attribution (match-string 0 string) |
| 4850 | 1029 start (match-end 0)) |
| 1030 (= start (or (string-match sc-citation-delimiter-regexp string start) -1)) | |
| 1031 (setq start (match-end 0)) | |
| 1032 (= start (or (string-match sc-citation-separator-regexp string start) -1)) | |
| 1033 attribution))) | |
| 1034 | |
| 1035 (defun sc-attribs-filter-namelist (namelist) | |
| 1036 "Filter out noise in NAMELIST according to `sc-name-filter-alist'." | |
| 1037 (let ((elements (length namelist)) | |
| 1038 (position -1) | |
| 1039 keepers filtered-list) | |
| 1040 (mapcar | |
| 1041 (function | |
| 1042 (lambda (name) | |
| 1043 (setq position (1+ position)) | |
| 1044 (let ((keep-p t)) | |
| 1045 (mapcar | |
| 1046 (function | |
| 1047 (lambda (filter) | |
| 1048 (let ((regexp (car filter)) | |
| 1049 (pos (cdr filter))) | |
| 1050 (if (and (string-match regexp name) | |
| 1051 (or (and (numberp pos) | |
| 1052 (= pos position)) | |
| 1053 (and (eq pos 'last) | |
| 1054 (= position (1- elements))) | |
| 1055 (eq pos 'any))) | |
| 1056 (setq keep-p nil)) | |
| 1057 ))) | |
| 1058 sc-name-filter-alist) | |
| 1059 (if keep-p | |
| 1060 (setq keepers (cons position keepers))) | |
| 1061 ))) | |
| 1062 namelist) | |
| 1063 (mapcar | |
| 1064 (function | |
| 1065 (lambda (position) | |
| 1066 (setq filtered-list (cons (nth position namelist) filtered-list)) | |
| 1067 )) | |
| 1068 keepers) | |
| 1069 filtered-list)) | |
| 1070 | |
| 1071 (defun sc-attribs-chop-address (from) | |
| 1072 "Extract attribution information from FROM. | |
| 1073 This populates the `sc-attributions' with the list of possible attributions." | |
| 1074 (if (and (stringp from) | |
| 1075 (< 0 (length from))) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1076 (let* ((sc-mumble "") |
| 4850 | 1077 (namestring (sc-attribs-extract-namestring from)) |
| 1078 (namelist (sc-attribs-filter-namelist | |
| 1079 (sc-attribs-chop-namestring namestring))) | |
| 1080 (revnames (reverse (cdr namelist))) | |
| 1081 (firstname (car namelist)) | |
| 1082 (midnames (reverse (cdr revnames))) | |
| 1083 (lastname (car revnames)) | |
| 1084 (initials (sc-attribs-strip-initials namelist)) | |
| 1085 (emailname (sc-attribs-emailname from)) | |
| 1086 (n 1) | |
| 1087 author middlenames) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1088 |
| 4850 | 1089 ;; put basic information |
| 1090 (setq | |
| 1091 ;; put middle names and build sc-author entry | |
| 1092 middlenames (mapconcat | |
| 1093 (function | |
| 1094 (lambda (midname) | |
| 1095 (let ((key-attribs (format "middlename-%d" n)) | |
| 1096 (key-mail (format "sc-middlename-%d" n))) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1097 (push (cons key-attribs midname) sc-attributions) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1098 (push (cons key-mail midname) sc-mail-info) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1099 (setq n (1+ n)) |
| 4850 | 1100 midname))) |
| 1101 midnames " ") | |
| 1102 | |
| 1103 author (concat firstname " " middlenames (and midnames " ") lastname) | |
| 1104 | |
| 1105 sc-attributions (append | |
| 1106 (list | |
| 1107 (cons "firstname" firstname) | |
| 1108 (cons "lastname" lastname) | |
| 1109 (cons "emailname" emailname) | |
| 1110 (cons "initials" initials)) | |
| 1111 sc-attributions) | |
| 1112 sc-mail-info (append | |
| 1113 (list | |
| 1114 (cons "sc-firstname" firstname) | |
| 1115 (cons "sc-middlenames" middlenames) | |
| 1116 (cons "sc-lastname" lastname) | |
| 1117 (cons "sc-emailname" emailname) | |
| 1118 (cons "sc-initials" initials) | |
| 1119 (cons "sc-author" author) | |
| 1120 (cons "sc-from-address" (sc-get-address | |
| 1121 (sc-mail-field "from") | |
| 1122 namestring)) | |
| 1123 (cons "sc-reply-address" (sc-get-address | |
| 1124 (sc-mail-field "reply-to") | |
| 1125 namestring)) | |
| 1126 (cons "sc-sender-address" (sc-get-address | |
| 1127 (sc-mail-field "sender") | |
| 1128 namestring)) | |
| 1129 ) | |
| 1130 sc-mail-info) | |
| 1131 )) | |
| 1132 ;; from string is empty | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1133 (push (cons "sc-author" sc-default-author-name) sc-mail-info))) |
| 4850 | 1134 |
| 1135 (defvar sc-attrib-or-cite nil | |
| 1136 "Used to toggle between attribution input or citation input.") | |
| 1137 | |
| 1138 (defun sc-toggle-fn () | |
| 1139 "Toggle between attribution selection and citation selection. | |
| 1140 Only used during confirmation." | |
| 1141 (interactive) | |
| 1142 (setq sc-attrib-or-cite (not sc-attrib-or-cite)) | |
| 1143 (throw 'sc-reconfirm t)) | |
| 1144 | |
| 1145 (defun sc-select-attribution () | |
| 1146 "Select an attribution from `sc-attributions'. | |
| 1147 | |
| 1148 Variables involved in selection process include: | |
| 1149 `sc-preferred-attribution-list' | |
| 1150 `sc-use-only-preference-p' | |
| 1151 `sc-confirm-always-p' | |
| 1152 `sc-default-attribution' | |
| 1153 `sc-attrib-selection-list'. | |
| 1154 | |
| 1155 Runs the hook `sc-attribs-preselect-hook' before selecting an | |
| 1156 attribution and the hook `sc-attribs-postselect-hook' after making the | |
| 1157 selection but before querying is performed. During | |
| 1158 `sc-attribs-postselect-hook' the variable `citation' is bound to the | |
| 1159 auto-selected citation string and the variable `attribution' is bound | |
| 1160 to the auto-selected attribution string." | |
| 1161 (run-hooks 'sc-attribs-preselect-hook) | |
| 1162 (let ((query-p sc-confirm-always-p) | |
| 1163 attribution citation | |
| 1164 (attriblist sc-preferred-attribution-list)) | |
| 1165 | |
| 1166 ;; first cruise through sc-preferred-attribution-list looking for | |
| 1167 ;; a match in either sc-attributions or sc-mail-info. if the | |
| 1168 ;; element is "sc-consult", then we have to do the alist | |
| 1169 ;; consultation phase | |
| 1170 (while attriblist | |
| 1171 (let* ((preferred (car attriblist))) | |
| 1172 (cond | |
| 1173 ((string= preferred "sc-consult") | |
| 1174 ;; we've been told to consult the attribution vs. mail | |
| 1175 ;; header key alist. we do this until we find a match in | |
| 1176 ;; the sc-attrib-selection-list. if we do not find a match, | |
| 1177 ;; we continue scanning attriblist | |
| 1178 (let ((attrib (sc-scan-info-alist sc-attrib-selection-list))) | |
| 1179 (cond | |
| 1180 ((not attrib) | |
| 1181 (setq attriblist (cdr attriblist))) | |
| 1182 ((stringp attrib) | |
| 1183 (setq attribution attrib | |
| 1184 attriblist nil)) | |
| 1185 ((listp attrib) | |
|
62903
9cca67e822b5
(sc-select-attribution): Only use a list element from
Glenn Morris <rgm@gnu.org>
parents:
62765
diff
changeset
|
1186 (setq attribution (eval attrib)) |
|
9cca67e822b5
(sc-select-attribution): Only use a list element from
Glenn Morris <rgm@gnu.org>
parents:
62765
diff
changeset
|
1187 (if (stringp attribution) |
|
9cca67e822b5
(sc-select-attribution): Only use a list element from
Glenn Morris <rgm@gnu.org>
parents:
62765
diff
changeset
|
1188 (setq attriblist nil) |
|
9cca67e822b5
(sc-select-attribution): Only use a list element from
Glenn Morris <rgm@gnu.org>
parents:
62765
diff
changeset
|
1189 (setq attribution nil |
|
9cca67e822b5
(sc-select-attribution): Only use a list element from
Glenn Morris <rgm@gnu.org>
parents:
62765
diff
changeset
|
1190 attriblist (cdr attriblist)))) |
| 4850 | 1191 (t (error "%s did not evaluate to a string or list!" |
| 1192 "sc-attrib-selection-list")) | |
| 1193 ))) | |
| 1194 ((setq attribution (cdr (assoc preferred sc-attributions))) | |
| 1195 (setq attriblist nil)) | |
| 1196 (t | |
| 1197 (setq attriblist (cdr attriblist))) | |
| 1198 ))) | |
| 1199 | |
| 1200 ;; if preference was not found, we may use a secondary method to | |
| 1201 ;; find a valid attribution | |
| 1202 (if (and (not attribution) | |
| 1203 (not sc-use-only-preference-p)) | |
| 1204 ;; secondary method tries to find a preference in this order | |
| 1205 ;; 1. sc-lastchoice | |
| 1206 ;; 2. x-attribution | |
| 1207 ;; 3. firstname | |
| 1208 ;; 4. lastname | |
| 1209 ;; 5. initials | |
| 1210 ;; 6. first non-empty attribution in alist | |
| 1211 (setq attribution | |
| 1212 (or (cdr (assoc "sc-lastchoice" sc-attributions)) | |
| 1213 (cdr (assoc "x-attribution" sc-attributions)) | |
| 1214 (cdr (assoc "firstname" sc-attributions)) | |
| 1215 (cdr (assoc "lastname" sc-attributions)) | |
| 1216 (cdr (assoc "initials" sc-attributions)) | |
| 1217 (cdr (car sc-attributions))))) | |
| 1218 | |
| 1219 ;; still couldn't find an attribution. we're now limited to using | |
| 1220 ;; the default attribution, but we'll force a query when this happens | |
| 1221 (if (not attribution) | |
| 1222 (setq attribution sc-default-attribution | |
| 1223 query-p t)) | |
| 1224 | |
| 1225 ;; create the attribution prefix | |
| 1226 (setq citation (sc-make-citation attribution)) | |
| 1227 | |
| 1228 ;; run the post selection hook before querying the user | |
| 1229 (run-hooks 'sc-attribs-postselect-hook) | |
| 1230 | |
| 1231 ;; query for confirmation | |
| 1232 (if query-p | |
| 1233 (let* ((query-alist (mapcar (function (lambda (entry) | |
| 1234 (list (cdr entry)))) | |
| 1235 sc-attributions)) | |
| 1236 (minibuffer-local-completion-map | |
| 1237 sc-minibuffer-local-completion-map) | |
| 1238 (minibuffer-local-map sc-minibuffer-local-map) | |
| 1239 (initial attribution) | |
| 1240 (completer-disable t) ; in case completer.el is used | |
| 1241 choice) | |
| 1242 (setq sc-attrib-or-cite nil) ; nil==attribution, t==citation | |
| 1243 (while | |
| 1244 (catch 'sc-reconfirm | |
|
43791
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1245 (progn |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1246 (setq choice |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1247 (if sc-attrib-or-cite |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1248 (read-string |
|
43791
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1249 "Enter citation prefix: " |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1250 citation |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1251 'sc-citation-confirmation-history) |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1252 (completing-read |
|
43791
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1253 "Complete attribution name: " |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1254 query-alist nil nil |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1255 (cons initial 0) |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1256 'sc-attribution-confirmation-history) |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1257 )) |
|
2e05b93ba14a
(sc-select-attribution): Accept whatever value we get in CHOICE; there
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
1258 nil))) |
| 4850 | 1259 (if sc-attrib-or-cite |
| 1260 ;; since the citation was chosen, we have to guess at | |
| 1261 ;; the attribution | |
| 1262 (setq citation choice | |
| 1263 attribution (or (sc-guess-attribution citation) | |
| 1264 citation)) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1265 |
| 4850 | 1266 (setq citation (sc-make-citation choice) |
| 1267 attribution choice)) | |
| 1268 )) | |
| 1269 | |
| 1270 ;; its possible that the user wants to downcase the citation and | |
| 1271 ;; attribution | |
| 1272 (if sc-downcase-p | |
| 1273 (setq citation (downcase citation) | |
| 1274 attribution (downcase attribution))) | |
| 1275 | |
| 1276 ;; set up mail info alist | |
| 1277 (let* ((ckey "sc-citation") | |
| 1278 (akey "sc-attribution") | |
| 1279 (ckeyval (assoc ckey sc-mail-info)) | |
| 1280 (akeyval (assoc akey sc-mail-info))) | |
| 1281 (if ckeyval | |
| 1282 (setcdr ckeyval citation) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1283 (push (cons ckey citation) sc-mail-info)) |
| 4850 | 1284 (if akeyval |
| 1285 (setcdr akeyval attribution) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1286 (push (cons akey attribution) sc-mail-info))) |
| 4850 | 1287 |
| 1288 ;; set the sc-lastchoice attribution | |
| 1289 (let* ((lkey "sc-lastchoice") | |
| 1290 (lastchoice (assoc lkey sc-attributions))) | |
| 1291 (if lastchoice | |
| 1292 (setcdr lastchoice attribution) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1293 (push (cons lkey attribution) sc-attributions))) |
| 4850 | 1294 )) |
| 1295 | |
| 1296 | |
| 1297 ;; ====================================================================== | |
| 1298 ;; filladapt hooks for supercite 3.1. you shouldn't need anything | |
| 1299 ;; extra to make gin-mode understand supercited lines. Even this | |
| 1300 ;; stuff might not be entirely necessary... | |
| 1301 | |
| 1302 (defun sc-cite-regexp (&optional root-regexp) | |
| 1303 "Return a regexp describing a Supercited line. | |
| 1304 The regexp is the concatenation of `sc-citation-leader-regexp', | |
| 1305 `sc-citation-root-regexp', `sc-citation-delimiter-regexp', and | |
| 1306 `sc-citation-separator-regexp'. If optional ROOT-REGEXP is supplied, | |
| 1307 use it instead of `sc-citation-root-regexp'." | |
| 1308 (concat sc-citation-leader-regexp | |
| 1309 (or root-regexp sc-citation-root-regexp) | |
| 1310 sc-citation-delimiter-regexp | |
| 1311 sc-citation-separator-regexp)) | |
| 1312 | |
| 1313 (defun sc-make-citation (attribution) | |
| 1314 "Make a non-nested citation from ATTRIBUTION." | |
| 1315 (concat sc-citation-leader | |
| 1316 attribution | |
| 1317 sc-citation-delimiter | |
| 1318 sc-citation-separator)) | |
| 1319 | |
| 1320 (defun sc-setup-filladapt () | |
| 1321 "Setup `filladapt-prefix-table' to handle Supercited paragraphs." | |
| 1322 (let* ((fa-sc-elt 'filladapt-supercite-included-text) | |
| 1323 (elt (rassq fa-sc-elt filladapt-prefix-table))) | |
| 1324 (if elt (setcar elt (sc-cite-regexp)) | |
| 1325 (message "Filladapt doesn't seem to know about Supercite.") | |
| 1326 (beep)))) | |
| 1327 | |
| 1328 | |
| 1329 ;; ====================================================================== | |
| 1330 ;; citing and unciting regions of text | |
| 1331 | |
| 1332 (defvar sc-fill-begin 1 | |
| 1333 "Buffer position to begin filling.") | |
| 1334 (defvar sc-fill-line-prefix "" | |
| 1335 "Fill prefix of previous line") | |
| 1336 | |
| 1337 ;; filling | |
| 1338 (defun sc-fill-if-different (&optional prefix) | |
| 1339 "Fill the region bounded by `sc-fill-begin' and point. | |
| 1340 Only fill if optional PREFIX is different than `sc-fill-line-prefix'. | |
| 1341 If `sc-auto-fill-region-p' is nil, do not fill region. If PREFIX is | |
| 1342 not supplied, initialize fill variables. This is useful for a regi | |
| 1343 `begin' frame-entry." | |
| 1344 (if (not prefix) | |
| 1345 (setq sc-fill-line-prefix "" | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1346 sc-fill-begin (line-beginning-position)) |
| 4850 | 1347 (if (and sc-auto-fill-region-p |
| 1348 (not (string= prefix sc-fill-line-prefix))) | |
| 1349 (let ((fill-prefix sc-fill-line-prefix)) | |
| 1350 (if (not (string= fill-prefix "")) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1351 (fill-region sc-fill-begin (line-beginning-position))) |
| 4850 | 1352 (setq sc-fill-line-prefix prefix |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1353 sc-fill-begin (line-beginning-position)))) |
| 4850 | 1354 ) |
| 1355 nil) | |
| 1356 | |
| 1357 (defun sc-cite-coerce-cited-line () | |
| 1358 "Coerce a Supercited line to look like our style." | |
| 1359 (let* ((attribution (sc-guess-attribution)) | |
| 1360 (regexp (sc-cite-regexp attribution)) | |
| 1361 (prefix (sc-make-citation attribution))) | |
| 1362 (if (and attribution | |
| 1363 (looking-at regexp)) | |
| 1364 (progn | |
| 1365 (delete-region | |
| 1366 (match-beginning 0) | |
| 1367 (save-excursion | |
| 1368 (goto-char (match-end 0)) | |
| 1369 (if (bolp) (forward-char -1)) | |
| 1370 (point))) | |
| 1371 (insert prefix) | |
| 1372 (sc-fill-if-different prefix))) | |
| 1373 nil)) | |
| 1374 | |
| 1375 (defun sc-cite-coerce-dumb-citer () | |
| 1376 "Coerce a non-nested citation that's been cited with a dumb nesting citer." | |
| 1377 (delete-region (match-beginning 1) (match-end 1)) | |
| 1378 (beginning-of-line) | |
| 1379 (sc-cite-coerce-cited-line)) | |
| 1380 | |
| 1381 (defun sc-guess-nesting (&optional string) | |
| 1382 "Guess the citation nesting on the current line. | |
| 1383 If nesting cannot be guessed, nil is returned. Optional STRING if | |
| 1384 supplied, is used instead of the line point is on in the current | |
| 1385 buffer." | |
| 1386 (let ((start 0) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1387 (string (or string (buffer-substring (line-beginning-position) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1388 (line-end-position)))) |
| 4850 | 1389 nesting) |
| 1390 (and | |
| 1391 (= start (or (string-match sc-citation-leader-regexp string start) -1)) | |
| 1392 (setq start (match-end 0)) | |
| 1393 (= start (or (string-match sc-citation-delimiter-regexp string start) -1)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1394 (setq nesting (match-string 0 string) |
| 4850 | 1395 start (match-end 0)) |
| 1396 (= start (or (string-match sc-citation-separator-regexp string start) -1)) | |
| 1397 nesting))) | |
| 1398 | |
| 1399 (defun sc-add-citation-level () | |
|
14007
c6476f4bb121
(sc-citation-nonnested-root-regexp,
Karl Heuer <kwzh@gnu.org>
parents:
13813
diff
changeset
|
1400 "Add a citation level for nested citation style w/ coercion." |
| 4850 | 1401 (let* ((nesting (sc-guess-nesting)) |
| 1402 (citation (make-string (1+ (length nesting)) | |
| 1403 (string-to-char sc-citation-delimiter))) | |
| 1404 (prefix (concat sc-citation-leader citation sc-citation-separator))) | |
| 1405 (if (looking-at (sc-cite-regexp "")) | |
| 1406 (delete-region (match-beginning 0) (match-end 0))) | |
| 1407 (insert prefix) | |
| 1408 (sc-fill-if-different prefix))) | |
| 1409 | |
| 1410 (defun sc-cite-line (&optional citation) | |
| 1411 "Cite a single line of uncited text. | |
| 1412 Optional CITATION overrides any citation automatically selected." | |
| 1413 (if sc-fixup-whitespace-p | |
| 1414 (fixup-whitespace)) | |
| 1415 (let ((prefix (or citation | |
| 1416 (cdr (assoc "sc-citation" sc-mail-info)) | |
| 1417 sc-default-attribution))) | |
| 1418 (insert prefix) | |
| 1419 (sc-fill-if-different prefix)) | |
| 1420 nil) | |
| 1421 | |
| 1422 (defun sc-uncite-line () | |
| 1423 "Remove citation from current line." | |
| 1424 (let ((cited (looking-at (sc-cite-regexp)))) | |
| 1425 (if cited | |
| 1426 (delete-region (match-beginning 0) (match-end 0)))) | |
| 1427 nil) | |
| 1428 | |
| 1429 (defun sc-recite-line (regexp) | |
| 1430 "Remove citation matching REGEXP from current line and recite line." | |
| 1431 (let ((cited (looking-at (concat "^" regexp))) | |
| 1432 (prefix (cdr (assoc "sc-citation" sc-mail-info)))) | |
| 1433 (if cited | |
| 1434 (delete-region (match-beginning 0) (match-end 0))) | |
| 1435 (insert (or prefix sc-default-attribution)) | |
| 1436 (sc-fill-if-different prefix)) | |
| 1437 nil) | |
| 1438 | |
| 1439 ;; interactive functions | |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1440 (defun sc-cite-region (start end &optional confirm-p interactive) |
| 4850 | 1441 "Cite a region delineated by START and END. |
| 1442 If optional CONFIRM-P is non-nil, the attribution is confirmed before | |
| 1443 its use in the citation string. This function first runs | |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1444 `sc-pre-cite-hook'. |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1445 |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1446 When called interactively, the optional arg INTERACTIVE is non-nil, |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1447 and that means call `sc-select-attribution' too." |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1448 (interactive "r\nP\np") |
| 4850 | 1449 (undo-boundary) |
|
58952
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1450 (let ((frame (sc-scan-info-alist sc-cite-frame-alist)) |
| 4850 | 1451 (sc-confirm-always-p (if confirm-p t sc-confirm-always-p))) |
|
58952
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1452 (if (and frame (symbolp frame)) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1453 (setq frame (symbol-value frame))) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1454 (or frame (setq frame sc-default-cite-frame)) |
| 4850 | 1455 (run-hooks 'sc-pre-cite-hook) |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
1456 (if interactive |
| 4850 | 1457 (sc-select-attribution)) |
| 1458 (regi-interpret frame start end))) | |
| 1459 | |
| 1460 (defun sc-uncite-region (start end) | |
| 1461 "Uncite a region delineated by START and END. | |
| 1462 First runs `sc-pre-uncite-hook'." | |
| 1463 (interactive "r") | |
| 1464 (undo-boundary) | |
|
58952
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1465 (let ((frame (sc-scan-info-alist sc-uncite-frame-alist))) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1466 (if (and frame (symbolp frame)) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1467 (setq frame (symbol-value frame))) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1468 (or frame (setq frame sc-default-uncite-frame)) |
| 4850 | 1469 (run-hooks 'sc-pre-uncite-hook) |
| 1470 (regi-interpret frame start end))) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1471 |
| 4850 | 1472 (defun sc-recite-region (start end) |
| 1473 "Recite a region delineated by START and END. | |
| 1474 First runs `sc-pre-recite-hook'." | |
| 1475 (interactive "r") | |
| 1476 (let ((sc-confirm-always-p t)) | |
| 1477 (sc-select-attribution)) | |
| 1478 (undo-boundary) | |
|
58952
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1479 (let ((frame (sc-scan-info-alist sc-recite-frame-alist))) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1480 (if (and frame (symbolp frame)) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1481 (setq frame (symbol-value frame))) |
|
5c34e026a96e
(sc-cite-frame-alist): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
58583
diff
changeset
|
1482 (or frame (setq frame sc-default-recite-frame)) |
| 4850 | 1483 (run-hooks 'sc-pre-recite-hook) |
| 1484 (regi-interpret frame start end))) | |
| 1485 | |
| 1486 | |
| 1487 ;; ====================================================================== | |
| 1488 ;; building headers | |
| 1489 | |
| 1490 (defun sc-hdr (prefix field &optional sep return-nil-p) | |
| 1491 "Returns a concatenation of PREFIX and FIELD. | |
| 1492 If FIELD is not a string or is the empty string, the empty string will | |
| 1493 be returned. Optional third argument SEP is concatenated on the end if | |
| 1494 it is a string. Returns empty string, unless optional RETURN-NIL-P is | |
| 1495 non-nil." | |
| 1496 (if (and (stringp field) | |
| 1497 (not (string= field ""))) | |
| 1498 (concat prefix field (or sep "")) | |
| 1499 (and (not return-nil-p) ""))) | |
| 1500 | |
| 1501 (defun sc-whofrom () | |
| 1502 "Return the value of (sc-mail-field \"from\") or nil." | |
| 1503 (let ((sc-mumble nil)) | |
| 1504 (sc-mail-field "from"))) | |
| 1505 | |
| 1506 (defun sc-no-header () | |
| 1507 "Does nothing. Use this instead of nil to get a blank header." | |
| 1508 ()) | |
| 1509 | |
| 1510 (defun sc-no-blank-line-or-header() | |
|
14007
c6476f4bb121
(sc-citation-nonnested-root-regexp,
Karl Heuer <kwzh@gnu.org>
parents:
13813
diff
changeset
|
1511 "Similar to `sc-no-header' except it removes the preceding blank line." |
| 4850 | 1512 (if (not (bobp)) |
| 1513 (if (and (eolp) | |
| 1514 (progn (forward-line -1) | |
| 21861 | 1515 (or (= (point) (mail-header-end)) |
| 4850 | 1516 (and (eq major-mode 'mh-letter-mode) |
| 1517 (mh-in-header-p))))) | |
| 1518 (progn (forward-line) | |
| 1519 (let ((kill-lines-magic t)) | |
| 1520 (kill-line)))))) | |
| 1521 | |
| 1522 (defun sc-header-on-said () | |
| 1523 "\"On <date>, <from> said:\" unless: | |
| 1524 1. the \"from\" field cannot be found, in which case nothing is inserted; | |
| 1525 2. the \"date\" field is missing in which case only the from part is printed." | |
| 1526 (let ((sc-mumble "") | |
| 1527 (whofrom (sc-whofrom))) | |
| 1528 (if whofrom | |
| 1529 (insert sc-reference-tag-string | |
| 1530 (sc-hdr "On " (sc-mail-field "date") ", ") | |
| 1531 whofrom " said:\n")))) | |
| 1532 | |
| 1533 (defun sc-header-inarticle-writes () | |
| 1534 "\"In article <message-id>, <from> writes:\" | |
| 1535 Treats \"message-id\" and \"from\" fields similar to `sc-header-on-said'." | |
| 1536 (let ((sc-mumble "") | |
| 1537 (whofrom (sc-mail-field "from"))) | |
| 1538 (if whofrom | |
| 1539 (insert sc-reference-tag-string | |
| 1540 (sc-hdr "In article " (sc-mail-field "message-id") ", ") | |
| 1541 whofrom " writes:\n")))) | |
| 1542 | |
| 1543 (defun sc-header-regarding-adds () | |
| 1544 "\"Regarding <subject>; <from> adds:\" | |
| 1545 Treats \"subject\" and \"from\" fields similar to `sc-header-on-said'." | |
| 1546 (let ((sc-mumble "") | |
| 1547 (whofrom (sc-whofrom))) | |
| 1548 (if whofrom | |
| 1549 (insert sc-reference-tag-string | |
| 1550 (sc-hdr "Regarding " (sc-mail-field "subject") "; ") | |
| 1551 whofrom " adds:\n")))) | |
| 1552 | |
| 1553 (defun sc-header-attributed-writes () | |
| 1554 "\"<sc-attribution>\" == <sc-author> <address> writes: | |
| 1555 Treats these fields in a similar manner to `sc-header-on-said'." | |
| 1556 (let ((sc-mumble "") | |
| 1557 (whofrom (sc-whofrom))) | |
| 1558 (if whofrom | |
| 1559 (insert sc-reference-tag-string | |
| 1560 (sc-hdr "\"" (sc-mail-field "sc-attribution") "\" == ") | |
| 1561 (sc-hdr "" (sc-mail-field "sc-author") " ") | |
| 1562 (or (sc-hdr "<" (sc-mail-field "sc-from-address") ">" t) | |
| 1563 (sc-hdr "<" (sc-mail-field "sc-reply-address") ">" t) | |
| 1564 "") | |
| 1565 " writes:\n")))) | |
| 1566 | |
| 1567 (defun sc-header-author-writes () | |
| 1568 "<sc-author> writes:" | |
| 1569 (let ((sc-mumble "") | |
| 1570 (whofrom (sc-whofrom))) | |
| 1571 (if whofrom | |
| 1572 (insert sc-reference-tag-string | |
| 1573 (sc-hdr "" (sc-mail-field "sc-author")) | |
| 1574 " writes:\n")))) | |
| 1575 | |
| 1576 (defun sc-header-verbose () | |
| 1577 "Very verbose, some say gross." | |
| 1578 (let ((sc-mumble "") | |
| 1579 (whofrom (sc-whofrom)) | |
| 1580 (tag sc-reference-tag-string)) | |
| 1581 (if whofrom | |
| 1582 (insert (sc-hdr (concat tag "On ") (sc-mail-field "date") ",\n") | |
| 1583 (or (sc-hdr tag (sc-mail-field "sc-author") "\n" t) | |
| 1584 (concat tag whofrom "\n")) | |
| 1585 (sc-hdr (concat tag "from the organization of ") | |
| 1586 (sc-mail-field "organization") "\n") | |
| 1587 (let ((rtag (concat tag "who can be reached at: "))) | |
| 1588 (or (sc-hdr rtag (sc-mail-field "sc-from-address") "\n" t) | |
| 1589 (sc-hdr rtag (sc-mail-field "sc-reply-address") "\n" t) | |
| 1590 "")) | |
| 1591 (sc-hdr | |
| 1592 (concat tag "(whose comments are cited below with \"") | |
| 1593 (sc-mail-field "sc-citation") "\"),\n") | |
| 1594 (sc-hdr (concat tag "had this to say in article ") | |
| 1595 (sc-mail-field "message-id") "\n") | |
| 1596 (sc-hdr (concat tag "in newsgroups ") | |
| 1597 (sc-mail-field "newsgroups") "\n") | |
| 1598 (sc-hdr (concat tag "concerning the subject of ") | |
| 1599 (sc-mail-field "subject") "\n") | |
| 1600 (sc-hdr (concat tag "(see ") | |
| 1601 (sc-mail-field "references") | |
| 1602 " for more details)\n") | |
| 1603 )))) | |
| 1604 | |
| 1605 | |
| 1606 ;; ====================================================================== | |
| 1607 ;; header rewrites | |
| 1608 | |
| 1609 (defconst sc-electric-bufname " *sc-erefs* " | |
| 1610 "Supercite electric reference mode's buffer name.") | |
| 1611 (defvar sc-eref-style 0 | |
| 1612 "Current electric reference style.") | |
| 1613 | |
| 1614 (defun sc-valid-index-p (index) | |
| 1615 "Returns INDEX if it is a valid index into `sc-rewrite-header-list'. | |
| 1616 Otherwise returns nil." | |
| 1617 ;; a number, and greater than or equal to zero | |
| 1618 ;; less than or equal to the last index | |
| 1619 (and (natnump index) | |
| 1620 (< index (length sc-rewrite-header-list)) | |
| 1621 index)) | |
| 1622 | |
| 1623 (defun sc-eref-insert-selected (&optional nomsg) | |
| 1624 "Insert the selected reference header in the current buffer. | |
| 1625 Optional NOMSG, if non-nil, inhibits printing messages, unless an | |
| 1626 error occurs." | |
| 1627 (let ((ref (nth sc-eref-style sc-rewrite-header-list))) | |
| 1628 (condition-case err | |
| 1629 (progn | |
| 1630 (eval ref) | |
| 1631 (let ((lines (count-lines (point-min) (point-max)))) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1632 (or nomsg (message "Ref header %d [%d line%s]: %s" |
| 4850 | 1633 sc-eref-style lines |
| 1634 (if (= lines 1) "" "s") | |
| 1635 ref)))) | |
| 1636 (void-function | |
| 1637 (progn (message | |
| 1638 "Symbol's function definition is void: %s (Header %d)" | |
| 1639 (car (cdr err)) sc-eref-style) | |
| 1640 (beep) | |
| 1641 )) | |
| 1642 ))) | |
| 1643 | |
| 1644 (defun sc-electric-mode (&optional arg) | |
| 1645 " | |
| 1646 Mode for viewing Supercite reference headers. Commands are: | |
| 1647 \n\\{sc-electric-mode-map} | |
| 1648 | |
| 1649 `sc-electric-mode' is not intended to be run interactively, but rather | |
| 1650 accessed through Supercite's electric reference feature. See | |
| 1651 `sc-insert-reference' for more details. Optional ARG is the initial | |
| 1652 header style to use, unless not supplied or invalid, in which case | |
| 1653 `sc-preferred-header-style' is used." | |
| 1654 | |
| 1655 (let ((info sc-mail-info)) | |
| 1656 | |
| 1657 (setq sc-eref-style | |
| 1658 (or (sc-valid-index-p arg) | |
| 1659 (sc-valid-index-p sc-preferred-header-style) | |
| 1660 0)) | |
| 1661 | |
| 1662 (get-buffer-create sc-electric-bufname) | |
| 1663 ;; set up buffer and enter command loop | |
| 1664 (save-excursion | |
| 1665 (save-window-excursion | |
| 1666 (pop-to-buffer sc-electric-bufname) | |
| 1667 (kill-all-local-variables) | |
| 1668 (let ((sc-mail-info info) | |
| 1669 (buffer-read-only t) | |
| 1670 (mode-name "SC Electric Refs") | |
| 1671 (major-mode 'sc-electric-mode)) | |
| 1672 (use-local-map sc-electric-mode-map) | |
| 1673 (sc-eref-show sc-eref-style) | |
|
62765
db1434c1a2f5
(sc-electric-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
62315
diff
changeset
|
1674 (run-mode-hooks 'sc-electric-mode-hook) |
| 4850 | 1675 (recursive-edit) |
| 1676 ))) | |
| 1677 | |
| 1678 (and sc-eref-style | |
| 1679 (sc-eref-insert-selected)) | |
| 1680 (kill-buffer sc-electric-bufname) | |
| 1681 )) | |
| 1682 | |
| 1683 ;; functions for electric reference mode | |
| 1684 (defun sc-eref-show (index) | |
| 1685 "Show reference INDEX in `sc-rewrite-header-list'." | |
| 1686 (let ((msg "No %ing reference headers in list.") | |
| 1687 (last (length sc-rewrite-header-list))) | |
| 1688 (setq sc-eref-style | |
| 1689 (cond | |
| 1690 ((sc-valid-index-p index) index) | |
| 1691 ((< index 0) | |
| 1692 (if sc-electric-circular-p | |
| 1693 (1- last) | |
| 1694 (progn (error msg "preced") 0))) | |
| 1695 ((>= index last) | |
| 1696 (if sc-electric-circular-p | |
| 1697 0 | |
| 1698 (progn (error msg "follow") (1- last)))) | |
| 1699 )) | |
| 1700 (save-excursion | |
| 1701 (set-buffer sc-electric-bufname) | |
| 1702 (let ((buffer-read-only nil)) | |
| 1703 (erase-buffer) | |
| 1704 (goto-char (point-min)) | |
| 1705 (sc-eref-insert-selected) | |
| 1706 ;; now shrink the window to just contain the electric reference | |
| 1707 ;; header. | |
| 1708 (let ((hdrlines (count-lines (point-min) (point-max))) | |
| 1709 (winlines (1- (window-height)))) | |
| 1710 (if (/= hdrlines winlines) | |
| 1711 (if (> hdrlines winlines) | |
| 1712 ;; we have to enlarge the window | |
| 1713 (enlarge-window (- hdrlines winlines)) | |
| 1714 ;; we have to shrink the window | |
| 1715 (shrink-window (- winlines (max hdrlines window-min-height))) | |
| 1716 ))) | |
| 1717 )))) | |
| 1718 | |
| 1719 (defun sc-eref-next () | |
| 1720 "Display next reference in other buffer." | |
| 1721 (interactive) | |
| 1722 (sc-eref-show (1+ sc-eref-style))) | |
| 1723 | |
| 1724 (defun sc-eref-prev () | |
| 1725 "Display previous reference in other buffer." | |
| 1726 (interactive) | |
| 1727 (sc-eref-show (1- sc-eref-style))) | |
| 1728 | |
| 1729 (defun sc-eref-setn () | |
| 1730 "Set reference header selected as preferred." | |
| 1731 (interactive) | |
| 1732 (setq sc-preferred-header-style sc-eref-style) | |
| 1733 (message "Preferred reference style set to header %d." sc-eref-style)) | |
| 1734 | |
| 1735 (defun sc-eref-goto (refnum) | |
| 1736 "Show reference style indexed by REFNUM. | |
| 1737 If REFNUM is an invalid index, don't go to that reference and return | |
| 1738 nil." | |
| 1739 (interactive "NGoto Reference: ") | |
| 1740 (if (sc-valid-index-p refnum) | |
| 1741 (sc-eref-show refnum) | |
| 1742 (error "Invalid reference: %d. (Range: [%d .. %d])" | |
| 1743 refnum 0 (1- (length sc-rewrite-header-list))) | |
| 1744 )) | |
| 1745 | |
| 1746 (defun sc-eref-jump () | |
| 1747 "Set reference header to preferred header." | |
| 1748 (interactive) | |
| 1749 (sc-eref-show sc-preferred-header-style)) | |
| 1750 | |
| 1751 (defun sc-eref-abort () | |
| 1752 "Exit from electric reference mode without inserting reference." | |
| 1753 (interactive) | |
| 1754 (setq sc-eref-style nil) | |
| 1755 (exit-recursive-edit)) | |
| 1756 | |
| 1757 (defun sc-eref-exit () | |
| 1758 "Exit from electric reference mode and insert selected reference." | |
| 1759 (interactive) | |
| 1760 (exit-recursive-edit)) | |
| 1761 | |
| 1762 (defun sc-insert-reference (arg) | |
| 1763 "Insert, at point, a reference header in the body of the reply. | |
| 1764 Numeric ARG indicates which header style from `sc-rewrite-header-list' | |
| 1765 to use when rewriting the header. No supplied ARG indicates use of | |
| 1766 `sc-preferred-header-style'. | |
| 1767 | |
| 1768 With just `\\[universal-argument]', electric reference insert mode is | |
| 1769 entered, regardless of the value of `sc-electric-references-p'. See | |
| 1770 `sc-electric-mode' for more information." | |
| 1771 (interactive "P") | |
| 1772 (if (consp arg) | |
| 1773 (sc-electric-mode) | |
| 1774 (let ((preference (or (sc-valid-index-p arg) | |
| 1775 (sc-valid-index-p sc-preferred-header-style) | |
| 1776 sc-preferred-header-style | |
| 1777 0))) | |
| 1778 (if sc-electric-references-p | |
| 1779 (sc-electric-mode preference) | |
| 1780 (sc-eref-insert-selected t) | |
| 1781 )))) | |
| 1782 | |
| 1783 | |
| 1784 ;; ====================================================================== | |
| 1785 ;; variable toggling | |
| 1786 | |
| 1787 (defun sc-raw-mode-toggle () | |
| 1788 "Toggle, in one fell swoop, two important SC variables: | |
| 1789 `sc-fixup-whitespace-p' and `sc-auto-fill-region-p'" | |
| 1790 (interactive) | |
| 1791 (setq sc-fixup-whitespace-p (not sc-fixup-whitespace-p) | |
| 1792 sc-auto-fill-region-p (not sc-auto-fill-region-p)) | |
|
11571
771bd7ddd4cc
(sc-raw-mode-toggle): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11556
diff
changeset
|
1793 (force-mode-line-update)) |
| 4850 | 1794 |
| 1795 (defun sc-toggle-var (variable) | |
| 1796 "Boolean toggle VARIABLE's value. | |
| 42206 | 1797 VARIABLE must be a bound symbol. nil values change to t, non-nil |
| 4850 | 1798 values are changed to nil." |
| 1799 (message "%s changed from %s to %s" | |
| 1800 variable (symbol-value variable) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1801 (set variable (not (symbol-value variable))))) |
| 4850 | 1802 |
| 1803 (defun sc-set-variable (var) | |
| 1804 "Set the Supercite VARIABLE. | |
| 1805 This function mimics `set-variable', except that the variable to set | |
| 1806 is determined non-interactively. The value is queried for in the | |
| 1807 minibuffer exactly the same way that `set-variable' does it. | |
| 1808 | |
| 1809 You can see the current value of the variable when the minibuffer is | |
| 1810 querying you by typing `C-h'. Note that the format is changed | |
| 1811 slightly from that used by `set-variable' -- the current value is | |
| 1812 printed just after the variable's name instead of at the bottom of the | |
| 1813 help window." | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1814 (let* ((minibuffer-help-form '(funcall myhelp)) |
| 4850 | 1815 (myhelp |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1816 (lambda () |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1817 (with-output-to-temp-buffer "*Help*" |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1818 (prin1 var) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1819 (if (boundp var) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1820 (let ((print-length 20)) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1821 (princ "\t(Current value: ") |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1822 (prin1 (symbol-value var)) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1823 (princ ")"))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1824 (princ "\n\nDocumentation:\n") |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1825 (princ (substring (documentation-property |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1826 var |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1827 'variable-documentation) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1828 1)) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1829 (with-current-buffer standard-output |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1830 (help-mode)) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1831 nil)))) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1832 (set var (eval-minibuffer (format "Set %s to value: " var))))) |
| 4850 | 1833 |
| 1834 (defmacro sc-toggle-symbol (rootname) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1835 `(defun ,(intern (concat "sc-T-" rootname)) () |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1836 (interactive) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1837 (sc-toggle-var ',(intern (concat "sc-" rootname "-p"))))) |
| 4850 | 1838 |
| 1839 (defmacro sc-setvar-symbol (rootname) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1840 `(defun ,(intern (concat "sc-S-" rootname)) () |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1841 (interactive) |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1842 (sc-set-variable ',(intern (concat "sc-" rootname))))) |
| 4850 | 1843 |
| 1844 (sc-toggle-symbol "confirm-always") | |
| 1845 (sc-toggle-symbol "downcase") | |
| 1846 (sc-toggle-symbol "electric-references") | |
| 1847 (sc-toggle-symbol "auto-fill-region") | |
| 1848 (sc-toggle-symbol "mail-nuke-blank-lines") | |
| 1849 (sc-toggle-symbol "nested-citation") | |
| 1850 (sc-toggle-symbol "electric-circular") | |
| 1851 (sc-toggle-symbol "use-only-preferences") | |
| 1852 (sc-toggle-symbol "fixup-whitespace") | |
| 1853 | |
| 1854 (sc-setvar-symbol "preferred-attribution-list") | |
| 1855 (sc-setvar-symbol "preferred-header-style") | |
| 1856 (sc-setvar-symbol "mail-nuke-mail-headers") | |
| 1857 (sc-setvar-symbol "mail-header-nuke-list") | |
| 1858 (sc-setvar-symbol "cite-region-limit") | |
| 1859 | |
| 1860 (defun sc-T-describe () | |
| 1861 " | |
| 1862 | |
| 1863 Supercite provides a number of key bindings which simplify the process | |
| 1864 of setting or toggling certain variables controlling its operation. | |
| 1865 | |
| 1866 Note on function names in this list: all functions of the form | |
| 1867 `sc-S-<name>' actually call `sc-set-variable' on the corresponding | |
| 1868 `sc-<name>' variable. All functions of the form `sc-T-<name>' call | |
| 1869 `sc-toggle-var' on the corresponding `sc-<name>-p' variable. | |
| 1870 | |
| 1871 \\{sc-T-keymap}" | |
| 1872 (interactive) | |
| 1873 (describe-function 'sc-T-describe)) | |
| 1874 | |
| 1875 | |
| 1876 ;; ====================================================================== | |
| 1877 ;; published interface to mail and news readers | |
| 1878 | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1879 (define-minor-mode sc-minor-mode |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1880 "Supercite minor mode." |
|
61282
73d56a93d9fd
(sc-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61044
diff
changeset
|
1881 :group 'supercite |
|
73d56a93d9fd
(sc-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61044
diff
changeset
|
1882 :lighter (" SC" (sc-auto-fill-region-p |
|
73d56a93d9fd
(sc-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61044
diff
changeset
|
1883 (":f" (sc-fixup-whitespace-p "w")) |
|
73d56a93d9fd
(sc-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61044
diff
changeset
|
1884 (sc-fixup-whitespace-p ":w"))) |
|
73d56a93d9fd
(sc-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61044
diff
changeset
|
1885 :keymap `((,sc-mode-map-prefix . ,sc-mode-map))) |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1886 |
|
7370
ecb09a00d330
(sc-cite-original): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
5286
diff
changeset
|
1887 ;;;###autoload |
| 4850 | 1888 (defun sc-cite-original () |
| 1889 "Workhorse citing function which performs the initial citation. | |
| 1890 This is callable from the various mail and news readers' reply | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1891 function according to the agreed upon standard. See the associated |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1892 info node `(SC)Top' for more details. |
|
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1893 `sc-cite-original' does not do any yanking of the |
| 4850 | 1894 original message but it does require a few things: |
| 1895 | |
| 1896 1) The reply buffer is the current buffer. | |
| 1897 | |
| 1898 2) The original message has been yanked and inserted into the | |
| 1899 reply buffer. | |
| 1900 | |
| 1901 3) Verbose mail headers from the original message have been | |
| 1902 inserted into the reply buffer directly before the text of the | |
| 1903 original message. | |
| 1904 | |
| 1905 4) Point is at the beginning of the verbose headers. | |
| 1906 | |
| 1907 5) Mark is at the end of the body of text to be cited. | |
| 1908 | |
| 1909 For Emacs 19's, the region need not be active (and typically isn't | |
| 1910 when this function is called. Also, the hook `sc-pre-hook' is run | |
| 1911 before, and `sc-post-hook' is run after the guts of this function." | |
| 1912 (run-hooks 'sc-pre-hook) | |
| 1913 | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1914 (sc-minor-mode 1) |
| 4850 | 1915 |
| 1916 (undo-boundary) | |
| 1917 | |
| 1918 ;; grab point and mark since the region is probably not active when | |
| 1919 ;; this function gets automatically called. we want point to be a | |
| 1920 ;; mark so any deleting before point works properly | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1921 (let* ((zmacs-regions nil) ; for XEemacs |
| 24876 | 1922 (mark-active t) ; for Emacs |
| 4850 | 1923 (point (point-marker)) |
| 1924 (mark (copy-marker (mark-marker)))) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43791
diff
changeset
|
1925 |
| 4850 | 1926 ;; make sure point comes before mark, not all functions are |
| 1927 ;; interactive "r" | |
| 1928 (if (< mark point) | |
| 1929 (let ((tmp point)) | |
| 1930 (setq point mark | |
| 1931 mark tmp))) | |
| 1932 | |
| 1933 ;; first process mail headers, and populate sc-mail-info | |
| 1934 (sc-mail-process-headers point mark) | |
| 1935 | |
| 1936 ;; now get possible attributions | |
| 1937 (sc-attribs-chop-address (or (sc-mail-field "from") | |
| 1938 (sc-mail-field "reply") | |
| 1939 (sc-mail-field "reply-to") | |
| 1940 (sc-mail-field "sender"))) | |
| 1941 ;; select the attribution | |
| 1942 (sc-select-attribution) | |
| 1943 | |
| 1944 ;; cite the region, but first check the value of sc-cite-region-limit | |
| 1945 (let ((linecnt (count-lines point mark))) | |
| 1946 (and sc-cite-region-limit | |
| 1947 (if (or (not (numberp sc-cite-region-limit)) | |
| 1948 (<= linecnt sc-cite-region-limit)) | |
| 1949 (progn | |
| 1950 ;; cite the region and insert the header rewrite | |
| 1951 (sc-cite-region point mark) | |
| 1952 (goto-char point) | |
| 1953 (let ((sc-eref-style (or sc-preferred-header-style 0))) | |
| 1954 (if sc-electric-references-p | |
| 1955 (sc-electric-mode sc-eref-style) | |
| 1956 (sc-eref-insert-selected t)))) | |
| 1957 (beep) | |
| 1958 (message | |
| 1959 "Region not cited. %d lines exceeds sc-cite-region-limit: %d" | |
| 1960 linecnt sc-cite-region-limit)))) | |
| 1961 | |
| 1962 ;; finally, free the point-marker | |
| 1963 (set-marker point nil) | |
| 1964 (set-marker mark nil) | |
| 1965 ) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1966 (run-hooks 'sc-post-hook)) |
| 4850 | 1967 |
| 1968 | |
| 1969 ;; ====================================================================== | |
| 1970 ;; bug reporting and miscellaneous commands | |
| 1971 | |
| 1972 (defun sc-open-line (arg) | |
| 1973 "Like `open-line', but insert the citation prefix at the front of the line. | |
| 1974 With numeric ARG, inserts that many new lines." | |
| 1975 (interactive "p") | |
| 1976 (save-excursion | |
| 1977 (let ((start (point)) | |
| 1978 (prefix (or (progn (beginning-of-line) | |
| 1979 (if (looking-at (sc-cite-regexp)) | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
1980 (match-string 0))) |
| 4850 | 1981 ""))) |
| 1982 (goto-char start) | |
| 1983 (open-line arg) | |
| 1984 (forward-line 1) | |
| 1985 (while (< 0 arg) | |
| 1986 (insert prefix) | |
| 1987 (forward-line 1) | |
| 1988 (setq arg (1- arg)) | |
| 1989 )))) | |
| 1990 | |
| 1991 (defun sc-insert-citation (arg) | |
| 1992 "Insert citation string at beginning of current line if not already cited. | |
| 1993 With `\\[universal-argument]' insert citation even if line is already | |
| 1994 cited." | |
| 1995 (interactive "P") | |
| 1996 (save-excursion | |
| 1997 (beginning-of-line) | |
| 1998 (if (or (not (looking-at (sc-cite-regexp))) | |
| 1999 (looking-at "^[ \t]*$") | |
| 2000 (consp arg)) | |
| 2001 (insert (sc-mail-field "sc-citation")) | |
|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
28437
diff
changeset
|
2002 (error "Line is already cited")))) |
| 4850 | 2003 |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2004 (defun sc-version (message) |
| 4850 | 2005 "Echo the current version of Supercite in the minibuffer. |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2006 If MESSAGE is non-nil (interactively, with no prefix argument), |
| 4850 | 2007 inserts the version string in the current buffer instead." |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2008 (interactive (not current-prefix-arg)) |
| 4850 | 2009 (let ((verstr (format "Using Supercite.el %s" sc-version))) |
|
57933
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2010 (if message |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2011 (message verstr) |
|
59c9a776a021
(sc-cite-region): Don't use interactive-p. Add arg INTERACTIVE.
Richard M. Stallman <rms@gnu.org>
parents:
57160
diff
changeset
|
2012 (insert "`sc-version' says: " verstr)))) |
| 4850 | 2013 |
| 2014 (defun sc-describe () | |
| 2015 " | |
| 2016 Supercite is a package which provides a flexible mechanism for citing | |
| 2017 email and news replies. Please see the associated texinfo file for | |
|
51174
26b66dee5902
Use `push' and replace `regi-pos' by equivalents.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50759
diff
changeset
|
2018 more information. Info node `(SC)Top'." |
| 4850 | 2019 (interactive) |
| 2020 (describe-function 'sc-describe)) | |
| 2021 | |
| 2022 (defun sc-submit-bug-report () | |
| 2023 "Submit a bug report on Supercite via mail." | |
| 2024 (interactive) | |
| 2025 (require 'reporter) | |
| 2026 (and | |
| 2027 (y-or-n-p "Do you want to submit a report on Supercite? ") | |
| 2028 (reporter-submit-bug-report | |
| 2029 sc-help-address | |
| 2030 (concat "Supercite version " sc-version) | |
| 2031 (list | |
| 2032 'sc-attrib-selection-list | |
| 2033 'sc-auto-fill-region-p | |
| 2034 'sc-blank-lines-after-headers | |
| 2035 'sc-citation-leader | |
| 2036 'sc-citation-delimiter | |
| 2037 'sc-citation-separator | |
| 2038 'sc-citation-leader-regexp | |
| 2039 'sc-citation-root-regexp | |
| 2040 'sc-citation-nonnested-root-regexp | |
| 2041 'sc-citation-delimiter-regexp | |
| 2042 'sc-citation-separator-regexp | |
| 2043 'sc-cite-region-limit | |
| 2044 'sc-confirm-always-p | |
| 2045 'sc-default-attribution | |
| 2046 'sc-default-author-name | |
| 2047 'sc-downcase-p | |
| 2048 'sc-electric-circular-p | |
| 2049 'sc-electric-references-p | |
| 2050 'sc-fixup-whitespace-p | |
| 2051 'sc-mail-warn-if-non-rfc822-p | |
| 2052 'sc-mumble | |
| 2053 'sc-name-filter-alist | |
| 2054 'sc-nested-citation-p | |
| 2055 'sc-nuke-mail-headers | |
| 2056 'sc-nuke-mail-header-list | |
| 2057 'sc-preferred-attribution-list | |
| 2058 'sc-preferred-header-style | |
| 2059 'sc-reference-tag-string | |
| 2060 'sc-rewrite-header-list | |
| 2061 'sc-titlecue-regexp | |
| 2062 'sc-use-only-preference-p | |
| 2063 )))) | |
| 2064 | |
| 2065 | |
| 2066 ;; useful stuff | |
| 2067 (provide 'supercite) | |
| 2068 (run-hooks 'sc-load-hook) | |
| 2069 | |
|
61044
17207b620cf3
(sc-mail-field): Use assoc-string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60924
diff
changeset
|
2070 ;; arch-tag: a5d5bfa6-3bd5-4414-8c65-0afc83e45cd3 |
| 4850 | 2071 ;;; supercite.el ends here |
