annotate lisp/=sc.el @ 1938:1045deef809f

(C_entries): Don't reset definedef when a newline inside a comment is met.
author Richard M. Stallman <rms@gnu.org>
date Tue, 23 Feb 1993 07:27:39 +0000
parents 341d551a3411
children b21d11dec171
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1745
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; -*- Mode: Emacs-Lisp -*-
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; sc.el -- Version 2.3 (used to be supercite.el)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; ========== Introduction ==========
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Citation and attribution package for various GNU emacs news and
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; electronic mail reading subsystems. This version of supercite will
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; interface to VM 4.40+ and MH-E 3.7 (shipped w/ emacs 18.57) as is.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; It will also interface with GNUS 3.12+, RMAIL 18.55+, GNEWS, and
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; probably most other news/mail subsystems by using the overloading
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; functions provided in sc-oloads.el (see that file or the README for
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; more information on interfacing supercite with your reader subsystem).
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; This version should now be compatible with Lucid Emacs 19.x emacses.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; This package does not do any yanking of messages, but instead
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; massages raw reply buffers set up by the reply/forward functions in
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; the news/mail subsystems. Therefore, such useful operations as
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; yanking and citing portions of the original article (instead of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; whole article) are not within the ability or responsiblity of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; supercite.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; ========== Disclaimer ==========
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; This software is distributed in the hope that it will be useful,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; but WITHOUT ANY WARRANTY. No author or distributor, nor any
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; author's past, present, or future employers accepts responsibility
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; to anyone for the consequences of using it or for whether it serves
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; any particular purpose or works at all, unless he says so in
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; writing.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Some of this software was written as part of the supercite author's
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; official duty as an employee of the United States Government and is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; thus not subject to copyright. You are free to use that particular
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; software as you wish, but WITHOUT ANY WARRANTY WHATSOEVER. It
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; would be nice, though if when you use any of this or other freely
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; available code, you give due credit to the author.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; Other parts of this code were written by other people. Wherever
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; possible, credit to that author, and the copy* notice supplied by
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; the author are included with that code. The supercite author is no
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; longer an employee of the U.S. Government so the GNU Public Licence
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; should be considered in effect for all enhancements and bug fixes
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; performed by the author.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; ========== Author (unless otherwise stated) ========================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; NAME: Barry A. Warsaw USMAIL: Century Computing, Inc.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; TELE: (301) 593-3330 1014 West Street
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; INET: bwarsaw@cen.com Laurel, Md 20707
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; UUCP: uunet!cen.com!bwarsaw
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; Want to be on the Supercite mailing list?
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Send articles to:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; Internet: supercite@anthem.nlm.nih.gov
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; UUCP: uunet!anthem.nlm.nih.gov!supercite
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; Send administrivia (additions/deletions to list, etc) to:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; Internet: supercite-request@anthem.nlm.nih.gov
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; UUCP: uunet!anthem.nlm.nih.gov!supercite-request
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; ========== Credits and Thanks ==========
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; This package was derived from the Superyank 1.11 package as posted
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; to the net. Superyank 1.11 was inspired by code and ideas from
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; Martin Neitzel and Ashwin Ram. Supercite version 2.3 has evolved
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; through the comments and suggestions of the supercite mailing list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; which consists of many authors and users of the various mail and
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; news reading subsystems.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; Many folks on the supercite mailing list have contributed their
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; help in debugging, making suggestions and supplying support code or
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; bug fixes for the previous versions of supercite. I want to thank
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; everyone who helped, especially (in no particular order):
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; Mark D. Baushke, Khalid Sattar, David Lawrence, Chris Davis, Kyle
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; Jones, Kayvan Sylvan, Masanobu Umeda, Dan Jacobson, Piet van
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; Oostrum, Hamish (H.I.) Macdonald, and Joe Wells.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; I don't mean to leave anyone out. All who have helped have been
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; appreciated.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; ========== Getting Started ==========
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; Here is a quick guide to getting started with supercite. The
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; information contained here is mostly excerpted from the more
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; detailed explanations given in the accompanying README file.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; Naturally, there are many customizations you can do to give your
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; replies that personalized flair, but the instructions in this
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; section should be sufficient for getting started.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; With this release of supercite overloading is the only supported
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; way to get supercite hooked into your favorite news/mail reading
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; subsystems. Overloading will be necessary for RMAIL, GNUS, GNEWS,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; RNEWS and PCMAIL. Overloading will not be needed for VM 4.37+ or
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; MH-E 3.7+. MH-E comes with emacs 18.57 but if you have an earlier
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; version of emacs, you should be able to ftp MH-E 3.7 separately. Or
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; you can extract the MH-E overloading stuff from version 2.1's
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; sc-oloads.el.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; First, to connect supercite to any mail/news reading subsystem, put
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; this in your .emacs file:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; (setq mail-yank-hooks 'sc-cite-original) ; for all but MH-E
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; (setq mh-yank-hooks 'sc-cite-original) ; for MH-E only
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; If supercite is not pre-loaded into your emacs session, you should
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; add the following autoload:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; (autoload 'sc-cite-original "sc" "Supercite 2.3" t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; Then, if you need to overload, put the following in your .emacs file:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; (defun my-sc-overload-hook ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; (require 'sc-oloads) ; be sure this file is on your load-path
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; (sc-overload-functions))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; (setq news-reply-mode-hook 'my-sc-overload-hook) ; for RNEWS,GNUS,GNEWS
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; (setq mail-setup-hook 'my-sc-overload-hook) ; for RMAIL, PCMAIL
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; Finally, if you want to customize supercite, you should do it in a
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; function called my-supercite-hook and:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; (setq sc-load-hook 'my-supercite-hook)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (require 'sc-alist)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; start of user defined variables
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defvar sc-nested-citation-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "*Controls whether to use nested or non-nested citation style.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 Non-nil uses nested citations, nil uses non-nested citations. Type
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 \\[sc-describe] for more information.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defvar sc-citation-leader " "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "*String comprising first part of a citation.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defvar sc-citation-delimiter ">"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "*String comprising third part of a citation.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 This string is used in both nested and non-nested citations.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (defvar sc-citation-separator " "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "*String comprising fourth and last part of a citation.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (defvar sc-default-author-name "Anonymous"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "*String used when author's name cannot be determined.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar sc-default-attribution "Anon"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "*String used when author's attribution cannot be determined.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; Noriya KOBAYASHI (nk@ics.osaka-u.ac.jp) writes to the supercite
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; mailing list:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; I use supercite in Nemacs-3.3.2. In order to handle citation using
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; Kanji, [...set sc-cite-regexp to...]
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; "\\s *\\([a-zA-Z0-9]\\|\\cc\\|\\cC\\|\\ch\\|\\cH\\|\\ck\\|\\cK\\)*\\s *>+"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (defvar sc-cite-regexp "\\s *[-a-zA-Z0-9_.]*>+\\s *"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 "*Regular expression describing how a already cited line begins.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 The regexp is only used at the beginning of a line, so it doesn't need
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 to start with a '^'.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (defvar sc-titlecue-regexp "\\s +-+\\s +"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 "*Regular expression describing the separator between names and titles.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 Set to nil to treat entire field as a name.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (defvar sc-spacify-name-chars '(?_ ?* ?+ ?=)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 "*List of characters to convert to spaces if found in an author's name.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (defvar sc-nicknames-alist
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 '(("Michael" "Mike")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ("Daniel" "Dan")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ("David" "Dave")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ("Jonathan" "John")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ("William" "Bill")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ("Elizabeth" "Beth")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ("Elizabeth" "Betsy")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ("Kathleen" "Kathy")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ("Smith" "Smitty"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 "*Association list of names and their common nicknames.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 Entries are of the form (NAME NICKNAME), and NAMEs can have more than
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 one nickname. Nicknames will not be automatically used as an
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 attribution string, since I'm not sure this is really polite, but if a
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 name is glommed from the author name and presented in the attribution
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 string completion list, the matching nicknames will also be presented.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 Set this variable to nil to defeat nickname expansions. Also note that
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 nicknames are not put in the supercite information alist.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (defvar sc-confirm-always-p t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 "*If non-nil, always confirm attribution string before citing text body.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (defvar sc-preferred-attribution 'firstname
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 "*Specifies which part of the author's name becomes the attribution.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 The value of this variable must be one of the following quoted symbols:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 emailname -- email terminus name
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 initials -- initials of author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 firstname -- first name of author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 lastname -- last name of author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 middlename1 -- first middle name of author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 middlename2 -- second middle name of author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ...
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 Middle name indexes can be any positive integer greater than 0, though
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 it is unlikely that many authors will supply more than one middle
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 name, if that many.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defvar sc-use-only-preference-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 "*Controls what happens when the preferred attribution cannot be found.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 If non-nil, then sc-default-attribution will be used. If nil, then
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 some secondary scheme will be employed to find a suitable attribution
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 string.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (defvar sc-downcase-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 "*Non-nil means downcase the attribution and citation strings.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (defvar sc-rewrite-header-list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 '((sc-no-header)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (sc-header-on-said)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (sc-header-inarticle-writes)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (sc-header-regarding-adds)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (sc-header-attributed-writes)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (sc-header-verbose)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (sc-no-blank-line-or-header)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 "*List of reference header rewrite functions.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 The variable sc-preferred-header-style controls which function in this
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 list is chosen for automatic reference header insertions. Electric
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 reference mode will cycle through this list of functions. For more
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 information, type \\[sc-describe].")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (defvar sc-preferred-header-style 1
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 "*Index into sc-rewrite-header-list specifying preferred header style.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 Index zero accesses the first function in the list.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (defvar sc-electric-references-p t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 "*Use electric references if non-nil.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defvar sc-electric-circular-p t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 "*Treat electric references as circular if non-nil.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (defvar sc-mail-fields-list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 '("date" "message-id" "subject" "newsgroups" "references"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 "from" "return-path" "path" "reply-to" "organization"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 "reply" )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 "*List of mail header whose values will be saved by supercite.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 These values can be used in header rewrite functions by accessing them
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 with the sc-field function. Mail headers in this list are case
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 insensitive and do not require a trailing colon.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (defvar sc-mumble-string ""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 "*Value returned by sc-field if chosen field cannot be found.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (defvar sc-nuke-mail-headers-p t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 "*Nuke or don't nuke mail headers.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 If non-nil, nuke mail headers after gleaning useful information from
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 them.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (defvar sc-reference-tag-string ">>>>> "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 "*String used at the beginning of built-in reference headers.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (defvar sc-fill-paragraph-hook 'sc-fill-paragraph
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 "*Hook for filling a paragraph.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 This hook gets executed when you fill a paragraph either manually or
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 automagically. It expects point to be within the extent of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 paragraph that is going to be filled. This hook allows you to use a
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 different paragraph filling package than the one supplied with
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 supercite.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (defvar sc-auto-fill-region-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 "*If non-nil, automatically fill each paragraph after it has been cited.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (defvar sc-auto-fill-query-each-paragraph-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 "*If non-nil, query before filling each paragraph.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 No querying and no filling will be performed if sc-auto-fill-region-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 is set to nil.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (defvar sc-fixup-whitespace-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 "*If non-nil, delete all leading white space before citing.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defvar sc-all-but-cite-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 "*If non-nil, sc-cite-original does everything but cite the text.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 This is useful for manually citing large messages, or portions of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 large messages. When non-nil, sc-cite-original will still set up all
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 necessary variables and databases, but will skip the citing routine
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 which modify the reply buffer's text.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (defvar sc-load-hook nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 "*User definable hook.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 Runs after supercite is loaded. Set your customizations here.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (defvar sc-pre-hook nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 "*User definable hook.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 Runs before sc-cite-original executes.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (defvar sc-post-hook nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 "*User definable hook.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 Runs after sc-cite-original executes.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (defvar sc-header-nuke-list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 '("via" "origin" "status" "received" "remailed" "cc" "sender" "replied"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 "organization" "keywords" "distribution" "xref" "references" "expires"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 "approved" "summary" "precedence" "subject" "newsgroup[s]?"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 "\\(followup\\|apparently\\|errors\\|\\(\\(in-\\)?reply\\)?-\\)?to"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 "x-[a-z0-9-]+" "[a-z-]*message-id" "\\(summary-\\)?line[s]"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 "\\(\\(return\\|reply\\)-\\)?path" "\\(posted-\\)?date"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 "\\(mail-\\)?from")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 "*List of mail headers to remove from body of reply.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ;; keymaps
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (defvar sc-default-keymap
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 '(lambda ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (local-set-key "\C-c\C-r" 'sc-insert-reference)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (local-set-key "\C-c\C-t" 'sc-cite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (local-set-key "\C-c\C-a" 'sc-recite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (local-set-key "\C-c\C-u" 'sc-uncite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (local-set-key "\C-c\C-i" 'sc-insert-citation)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (local-set-key "\C-c\C-o" 'sc-open-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (local-set-key "\C-c\C-q" 'sc-fill-paragraph-manually)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (local-set-key "\C-cq" 'sc-fill-paragraph-manually)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (local-set-key "\C-c\C-m" 'sc-modify-information)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (local-set-key "\C-cf" 'sc-view-field)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (local-set-key "\C-cg" 'sc-glom-headers)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (local-set-key "\C-c\C-v" 'sc-version)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (local-set-key "\C-c?" 'sc-describe)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 "*Default keymap if major-mode can't be found in `sc-local-keymaps'.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defvar sc-local-keymaps
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 '((mail-mode
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (lambda ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (local-set-key "\C-c\C-r" 'sc-insert-reference)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (local-set-key "\C-c\C-t" 'sc-cite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (local-set-key "\C-c\C-a" 'sc-recite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (local-set-key "\C-c\C-u" 'sc-uncite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (local-set-key "\C-c\C-i" 'sc-insert-citation)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (local-set-key "\C-c\C-o" 'sc-open-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (local-set-key "\C-c\C-q" 'sc-fill-paragraph-manually)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (local-set-key "\C-cq" 'sc-fill-paragraph-manually)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (local-set-key "\C-c\C-m" 'sc-modify-information)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (local-set-key "\C-cf" 'sc-view-field)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (local-set-key "\C-cg" 'sc-glom-headers)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (local-set-key "\C-c\C-v" 'sc-version)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (local-set-key "\C-c?" 'sc-describe)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 ))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (mh-letter-mode
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (lambda ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (local-set-key "\C-c\C-r" 'sc-insert-reference)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (local-set-key "\C-c\C-t" 'sc-cite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (local-set-key "\C-c\C-a" 'sc-recite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (local-set-key "\C-c\C-u" 'sc-uncite)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (local-set-key "\C-ci" 'sc-insert-citation)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (local-set-key "\C-c\C-o" 'sc-open-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (local-set-key "\C-cq" 'sc-fill-paragraph-manually)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (local-set-key "\C-c\C-m" 'sc-modify-information)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (local-set-key "\C-cf" 'sc-view-field)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (local-set-key "\C-cg" 'sc-glom-headers)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (local-set-key "\C-c\C-v" 'sc-version)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (local-set-key "\C-c?" 'sc-describe)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 ))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (news-reply-mode mail-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (vm-mail-mode mail-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (e-reply-mode mail-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (n-reply-mode mail-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 "*List of keymaps to use with the associated major-mode.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (defvar sc-electric-mode-map nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 "*Keymap for sc-electric-mode.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (if sc-electric-mode-map
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (setq sc-electric-mode-map (make-sparse-keymap))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (define-key sc-electric-mode-map "p" 'sc-eref-prev)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (define-key sc-electric-mode-map "n" 'sc-eref-next)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (define-key sc-electric-mode-map "s" 'sc-eref-setn)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (define-key sc-electric-mode-map "j" 'sc-eref-jump)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (define-key sc-electric-mode-map "x" 'sc-eref-abort)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (define-key sc-electric-mode-map "\r" 'sc-eref-exit)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (define-key sc-electric-mode-map "\n" 'sc-eref-exit)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (define-key sc-electric-mode-map "q" 'sc-eref-exit)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (define-key sc-electric-mode-map "g" 'sc-eref-goto)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ;; end of user defined variables
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;; global variables, not user accessable
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (defconst sc-version-number "2.3"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 "Supercite's version number.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 ;; when rnewspost.el patch is installed (or function is overloaded)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 ;; this should be nil since supercite now does this itself.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (setq news-reply-header-hook nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ;; autoload for sc-electric-mode
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (autoload 'sc-electric-mode "sc-elec"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 "Quasi-major mode for viewing supercite reference headers." nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;; global alists (gals), misc variables. make new bytecompiler happy
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (defvar sc-gal-information nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 "Internal global alist variable containing information.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (defvar sc-gal-attributions nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 "Internal global alist variable containing attributions.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (defvar sc-fill-arg nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 "Internal fill argument holder.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (defvar sc-cite-context nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 "Internal citation context holder.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (defvar sc-force-confirmation-p nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 "Internal variable.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (make-variable-buffer-local 'sc-gal-attributions)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (make-variable-buffer-local 'sc-gal-information)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (make-variable-buffer-local 'sc-leached-keymap)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (make-variable-buffer-local 'sc-fill-arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (make-variable-buffer-local 'sc-cite-context)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (setq-default sc-gal-attributions nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (setq-default sc-gal-information nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (setq-default sc-leached-keymap (current-local-map))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (setq-default sc-fill-arg nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (setq-default sc-cite-context nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 ;; miscellaneous support functions
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (defun sc-mark ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 "Mark compatibility between emacs v18 and v19."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (let ((zmacs-regions nil))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (mark)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (defun sc-update-gal (attribution)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 "Update the information alist.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 Add ATTRIBUTION and compose the nested and non-nested citation
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 strings."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (let ((attrib (if sc-downcase-p (downcase attribution) attribution)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (aput 'sc-gal-information "sc-attribution" attrib)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (aput 'sc-gal-information "sc-nested-citation"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (concat attrib sc-citation-delimiter))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (aput 'sc-gal-information "sc-citation"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (concat sc-citation-leader
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 attrib
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 sc-citation-delimiter
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 sc-citation-separator))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (defun sc-valid-index-p (index)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 "Returns t if INDEX is a valid index into sc-rewrite-header-list."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (let ((last (1- (length sc-rewrite-header-list))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (and (natnump index) ;; a number, and greater than or equal to zero
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (<= index last) ;; less than or equal to the last index
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 )))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (defun sc-string-car (namestring)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 "Return the string-equivalent \"car\" of NAMESTRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 example: (sc-string-car \"John Xavier Doe\")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 => \"John\""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (substring namestring
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (progn (string-match "\\s *" namestring) (match-end 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (progn (string-match "\\s *\\S +" namestring) (match-end 0))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (defun sc-string-cdr (namestring)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 "Return the string-equivalent \"cdr\" of NAMESTRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 example: (sc-string-cdr \"John Xavier Doe\")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 => \"Xavier Doe\""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (substring namestring
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (progn (string-match "\\s *\\S +\\s *" namestring)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (match-end 0))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (defun sc-linepos (&optional position col-p)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 "Return the character position at various line positions.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 Optional POSITION can be one of the following symbols:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 bol == beginning of line
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 boi == beginning of indentation
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 eol == end of line [default]
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 Optional COL-P non-nil returns current-column instead of character position."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (let ((tpnt (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 rval)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 ((eq position 'bol) (beginning-of-line))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 ((eq position 'boi) (back-to-indentation))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (t (end-of-line)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (setq rval (if col-p (current-column) (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (goto-char tpnt)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 rval))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 ;; this section snarfs mail fields and places them in the info alist
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (defun sc-build-header-zap-regexp ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 "Return a regexp for sc-mail-yank-clear-headers."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (let ((headers sc-header-nuke-list)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (regexp nil))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (while headers
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (setq regexp (concat regexp
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 "^" (car headers) ":"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (if (cdr headers) "\\|" nil)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (setq headers (cdr headers)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 regexp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (defun sc-mail-yank-clear-headers (start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 "Nuke mail headers between START and END."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (if (and sc-nuke-mail-headers-p sc-header-nuke-list)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (let ((regexp (sc-build-header-zap-regexp)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (if (search-forward "\n\n" end t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (save-restriction
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (narrow-to-region start (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (while (let ((case-fold-search t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (re-search-forward regexp nil t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (delete-region (point)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (progn (re-search-forward "\n[^ \t]")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (forward-char -1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 )))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (defun sc-mail-fetch-field (field)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 "Return the value of the header field FIELD.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 The buffer is expected to be narrowed to just the headers of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 message."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (goto-char (point-min))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (let ((case-fold-search t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (name (concat "^" (regexp-quote field) "[ \t]*:[ \t]*")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (goto-char (point-min))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (if (re-search-forward name nil t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (let ((opoint (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (while (progn (forward-line 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (looking-at "[ \t]")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (buffer-substring opoint (1- (point))))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (defun sc-fetch-fields (start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 "Fetch the mail fields in the region from START to END.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 These fields can be accessed in header rewrite functions with sc-field."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (save-restriction
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (narrow-to-region start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (let ((fields sc-mail-fields-list))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (while fields
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (let ((value (sc-mail-fetch-field (car fields)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (next (cdr fields)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (and value
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (aput 'sc-gal-information (car fields) value))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (setq fields next)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (if (sc-mail-fetch-field "from")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (aput 'sc-gal-information "from" (sc-mail-fetch-field "from")))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (defun sc-field (field)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 "Return the alist information associated with the FIELD.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 If FIELD is not a valid key, return sc-mumble-string."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (or (aget sc-gal-information field) sc-mumble-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 ;; built-in reference header rewrite functions
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (defun sc-no-header ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 "Does nothing. Use this instead of nil to get a blank header."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 ())
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (defun sc-no-blank-line-or-header()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 "Similar to sc-no-header except it removes the preceeding blank line."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (if (not (bobp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (if (and (eolp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (progn (forward-line -1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (or (looking-at mail-header-separator)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (and (eq major-mode 'mh-letter-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (mh-in-header-p)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (progn (forward-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (let ((kill-lines-magic t)) (kill-line))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (defun sc-header-on-said ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 "\"On <date>, <from> said:\", unless 1. the \"from\" field cannot be
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 found, in which case nothing is inserted; or 2. the \"date\" field is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 missing in which case only the from part is printed."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (let* ((sc-mumble-string "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (whofrom (sc-field "from"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (when (sc-field "date")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (if (not (string= whofrom ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (insert sc-reference-tag-string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (if (not (string= when ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 (concat "On " when ", ") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 whofrom " said:\n"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (defun sc-header-inarticle-writes ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 "\"In article <message-id>, <from> writes:\"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 Treats \"message-id\" and \"from\" fields similar to sc-header-on-said."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (let* ((sc-mumble-string "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (whofrom (sc-field "from"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (msgid (sc-field "message-id")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (if (not (string= whofrom ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (insert sc-reference-tag-string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (if (not (string= msgid ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (concat "In article " msgid ", ") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 whofrom " writes:\n"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (defun sc-header-regarding-adds ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 "\"Regarding <subject>; <from> adds:\"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 Treats \"subject\" and \"from\" fields similar to sc-header-on-said."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (let* ((sc-mumble-string "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (whofrom (sc-field "from"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (subj (sc-field "subject")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (if (not (string= whofrom ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (insert sc-reference-tag-string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (if (not (string= subj ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (concat "Regarding " subj "; ") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 whofrom " adds:\n"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (defun sc-header-attributed-writes ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 "\"<sc-attribution>\" == <sc-author> <address> writes:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 Treats these fields in a similar manner to sc-header-on-said."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (let* ((sc-mumble-string "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (whofrom (sc-field "from"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (reply (sc-field "sc-reply-address"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (from (sc-field "sc-from-address"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (attr (sc-field "sc-attribution"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (auth (sc-field "sc-author")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (if (not (string= whofrom ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (insert sc-reference-tag-string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (if (not (string= attr ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (concat "\"" attr "\" == " ) "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (if (not (string= auth ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (concat auth " ") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (if (not (string= reply ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (concat "<" reply ">")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (if (not (string= from ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (concat "<" from ">") ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 " writes:\n"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (defun sc-header-verbose ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 "Very verbose, some say gross."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (let* ((sc-mumble-string "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (whofrom (sc-field "from"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (reply (sc-field "sc-reply-address"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (from (sc-field "sc-from-address"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (author (sc-field "sc-author"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (date (sc-field "date"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (org (sc-field "organization"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (msgid (sc-field "message-id"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (ngrps (sc-field "newsgroups"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (subj (sc-field "subject"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (refs (sc-field "references"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (cite (sc-field "sc-citation"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (nl sc-reference-tag-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (if (not (string= whofrom ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (insert (if (not (string= date ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (concat nl "On " date ",\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (concat nl (if (not (string= author ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 whofrom) "\n")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (if (not (string= org ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (concat nl "from the organization of " org "\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (if (not (string= reply ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (concat nl "who can be reached at: " reply "\n")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (if (not (string= from ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (concat nl "who can be reached at: " from "\n") ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (if (not (string= cite ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (concat nl "(whose comments are cited below with \""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 cite "\"),\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (if (not (string= msgid ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (concat nl "had this to say in article " msgid "\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (if (not (string= ngrps ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (concat nl "in newsgroups " ngrps "\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (if (not (string= subj ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (concat nl "concerning the subject of " subj "\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (if (not (string= refs ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (concat nl "(see " refs " for more details)\n") "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 ;; this section queries the user for necessary information
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (defun sc-query (&optional default)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 "Query for an attribution string with the optional DEFAULT choice.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 Returns the string entered by the user, if non-empty and non-nil, or
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 DEFAULT otherwise. If DEFAULT is not supplied, sc-default-attribution
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 is used."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (if (not default) (setq default sc-default-attribution))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (let* ((prompt (concat "Enter attribution string: (default " default ") "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (query (read-string prompt)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (if (or (null query)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (string= query ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 default
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 query)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (defun sc-confirm ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 "Confirm the preferred attribution with the user."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (if (or sc-confirm-always-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 sc-force-confirmation-p)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (aput 'sc-gal-attributions
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (let* ((default (aheadsym sc-gal-attributions))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 chosen
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (prompt (concat "Complete "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 ((eq sc-cite-context 'citing) "cite")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 ((eq sc-cite-context 'reciting) "recite")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (t ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 " attribution string: (default "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 default ") "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (minibuffer-local-completion-map
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (copy-keymap minibuffer-local-completion-map)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (define-key minibuffer-local-completion-map "\C-g"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 '(lambda () (interactive) (beep) (throw 'select-abort nil)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (setq chosen (completing-read prompt sc-gal-attributions))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (if (or (not chosen)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (string= chosen ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 default
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 chosen)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 ;; this section contains primitive functions used in the email address
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 ;; parsing schemes. they extract name fields from various parts of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 ;; the "from:" field.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (defun sc-style1-addresses (from-string &optional delim)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "Extract the author's email terminus from email address FROM-STRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 Match addresses of the style \"name%[stuff].\" when called with DELIM
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 of \"%\" and addresses of the style \"[stuff]name@[stuff]\" when
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 called with DELIM \"@\". If DELIM is nil or not provided, matches
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 addresses of the style \"name\"."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (and (string-match (concat "[a-zA-Z0-9_-]+" delim) from-string 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (substring from-string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (match-beginning 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (- (match-end 0) (if (null delim) 0 1)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (defun sc-style2-addresses (from-string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 "Extract the author's email terminus from email address FROM-STRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 Match addresses of the style \"[stuff]![stuff]...!name[stuff].\""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (let ((eos (length from-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (mstart (string-match "![a-zA-Z0-9_-]+\\([^!a-zA-Z0-9_-]\\|$\\)"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 from-string 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (mend (match-end 0)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (and mstart
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (substring from-string (1+ mstart) (- mend (if (= mend eos) 0 1)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 )))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (defun sc-get-address (from-string author)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 "Get the full email address path from FROM-STRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 AUTHOR is the author's name (which is removed from the address)."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (let ((eos (length from-string)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (if (string-match (concat "\\(^\\|^\"\\)" author
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 "\\(\\s +\\|\"\\s +\\)") from-string 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (let ((addr (substring from-string (match-end 0) eos)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (if (and (= (aref addr 0) ?<)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (= (aref addr (1- (length addr))) ?>))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (substring addr 1 (1- (length addr)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 addr))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (if (string-match "[a-zA-Z0-9!@%._-]+" from-string 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (substring from-string (match-beginning 0) (match-end 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 )))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (defun sc-get-emailname (from-string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 "Get the email terminus name from FROM-STRING."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 ((sc-style1-addresses from-string "%"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 ((sc-style1-addresses from-string "@"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 ((sc-style2-addresses from-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ((sc-style1-addresses from-string nil))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (t (substring from-string 0 10))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 ;; this section contains functions that will extract a list of names
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 ;; from the name field string.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (defun sc-spacify-name-chars (name)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (let ((len (length name))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (s 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 (while (< s len)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (if (memq (aref name s) sc-spacify-name-chars)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (aset name s 32))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (setq s (1+ s)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 name))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 (defun sc-name-substring (string start end extend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 "Extract the specified substring of STRING from START to END.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 EXTEND is the number of characters on each side to extend the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 substring."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (and start
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (let ((sos (+ start extend))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (eos (- end extend)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (substring string sos
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 (or (string-match sc-titlecue-regexp string sos) eos)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (defun sc-extract-namestring (from-string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 "Extract the name string from FROM-STRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 This should be the author's full name minus an optional title."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (let ((pstart (string-match "(.*)" from-string 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (pend (match-end 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (qstart (string-match "\".*\"" from-string 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (qend (match-end 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (bstart (string-match "\\([.a-zA-Z0-9_-]+\\s *\\)+" from-string 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (bend (match-end 0)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (sc-spacify-name-chars
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 ((sc-name-substring from-string pstart pend 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ((sc-name-substring from-string qstart qend 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 ((sc-name-substring from-string bstart bend 0))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (defun sc-chop-namestring (namestring)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 "Convert NAMESTRING to a list of names.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 example: (sc-namestring-to-list \"John Xavier Doe\")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 => (\"John\" \"Xavier\" \"Doe\")"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (if (not (string= namestring ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (append (list (sc-string-car namestring))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (sc-chop-namestring (sc-string-cdr namestring)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 (defun sc-strip-initials (namelist)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 "Extract the author's initials from the NAMELIST."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (if (not namelist)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (concat (if (string= (car namelist) "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 ""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (substring (car namelist) 0 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (sc-strip-initials (cdr namelist)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;; this section handles selection of the attribution and citation strings
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (defun sc-populate-alists (from-string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 "Put important and useful information in the alists using FROM-STRING.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 Return the list of name symbols."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (let* ((namelist (sc-chop-namestring (sc-extract-namestring from-string)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (revnames (reverse (cdr namelist)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (midnames (reverse (cdr revnames)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (firstname (car namelist))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (midnames (reverse (cdr revnames)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (lastname (car revnames))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (initials (sc-strip-initials namelist))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (emailname (sc-get-emailname from-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (n 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (symlist (list 'emailname 'initials 'firstname 'lastname)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 ;; put basic information
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (aput 'sc-gal-attributions 'firstname firstname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (aput 'sc-gal-attributions 'lastname lastname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (aput 'sc-gal-attributions 'emailname emailname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 (aput 'sc-gal-attributions 'initials initials)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (aput 'sc-gal-information "sc-firstname" firstname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (aput 'sc-gal-information "sc-lastname" lastname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (aput 'sc-gal-information "sc-emailname" emailname)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (aput 'sc-gal-information "sc-initials" initials)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 ;; put middle names and build sc-author entry
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (let ((author (concat firstname " ")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (while midnames
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (let ((name (car midnames))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 (next (cdr midnames))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (symbol (intern (format "middlename%d" n)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (string (format "sc-middlename-%d" n)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 ;; first put new middlename
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (aput 'sc-gal-attributions symbol name)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (aput 'sc-gal-information string name)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (setq n (1+ n))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (nconc symlist (list symbol))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 ;; now build author name
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (setq author (concat author name " "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 ;; incr loop
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (setq midnames next)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 ))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (setq author (concat author lastname))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 ;; put author name and email address
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 (aput 'sc-gal-information "sc-author" author)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (aput 'sc-gal-information "sc-from-address"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 (sc-get-address from-string author))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (aput 'sc-gal-information "sc-reply-address"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (sc-get-address (sc-field "reply-to") author))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 ;; return value
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 symlist))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 (defun sc-sort-attribution-alist ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 "Put preferred attribution at head of attributions alist."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (asort 'sc-gal-attributions sc-preferred-attribution)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 ;; use backup scheme if preference is not legal
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (if (or (null sc-preferred-attribution)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 (anot-head-p sc-gal-attributions sc-preferred-attribution)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (let ((prefval (aget sc-gal-attributions
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 sc-preferred-attribution)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (or (null prefval)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (string= prefval ""))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 ;; no legal attribution
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (if sc-use-only-preference-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (aput 'sc-gal-attributions 'sc-user-query
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (sc-query sc-default-attribution))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 ;; else use secondary scheme
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 (asort 'sc-gal-attributions 'firstname))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (defun sc-build-attribution-alist (from-string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 "Extract attributions from FROM-STRING, applying preferences."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (let ((symlist (sc-populate-alists from-string))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (headval (progn (sc-sort-attribution-alist)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (aget sc-gal-attributions
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (aheadsym sc-gal-attributions) t))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 ;; for each element in the symlist, remove the corresponding
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ;; key-value pair in the alist, then insert just the value.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (while symlist
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (let ((value (aget sc-gal-attributions (car symlist) t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 (next (cdr symlist)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (if (not (or (null value)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (string= value "")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (aput 'sc-gal-attributions value))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (adelete 'sc-gal-attributions (car symlist))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (setq symlist next)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 ;; add nicknames to the completion list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (let ((gal sc-gal-attributions))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (while gal
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (let ((nns sc-nicknames-alist)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (galname (car (car gal))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (while nns
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (if (string= galname (car (car nns)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (aput 'sc-gal-attributions (car (cdr (car nns)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (setq nns (cdr nns)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (setq gal (cdr gal)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;; now reinsert the head (preferred) attribution unless it is nil,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 ;; this effectively just moves the head value to the front of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 ;; list.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (if headval
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (aput 'sc-gal-attributions headval))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 ;; check to be sure alist is not nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (if (null sc-gal-attributions)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (aput 'sc-gal-attributions sc-default-attribution))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (defun sc-select ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 "Select an attribution and create a citation string."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (sc-nested-citation-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 (sc-update-gal ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 ((null (aget sc-gal-information "from" t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 (aput 'sc-gal-information "sc-author" sc-default-author-name)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 (sc-update-gal (sc-query sc-default-attribution)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 ((null sc-gal-attributions)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 (sc-build-attribution-alist (aget sc-gal-information "from" t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 (sc-confirm)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (sc-update-gal (aheadsym sc-gal-attributions)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (sc-confirm)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (sc-update-gal (aheadsym sc-gal-attributions))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 ;; region citing and unciting
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (defun sc-cite-region (start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 "Cite a region delineated by START and END."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 ;; set real end-of-region
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 (goto-char end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (forward-line 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 (set-mark (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ;; goto real beginning-of-region
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 (let ((fstart (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 (fend (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 (while (< (point) (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 ;; remove leading whitespace if desired
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 (and sc-fixup-whitespace-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 (fixup-whitespace))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 ;; if end of line then perhaps autofill
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 (cond ((eolp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (or (= fstart fend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 (not sc-auto-fill-region-p)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 (and sc-auto-fill-query-each-paragraph-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (not (y-or-n-p "Fill this paragraph? ")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (save-excursion (set-mark fend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (goto-char (/ (+ fstart fend 1) 2))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 (run-hooks 'sc-fill-paragraph-hook)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 (setq fstart (point)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 fend (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 ;; not end of line so perhap cite it
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 ((not (looking-at sc-cite-regexp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (insert (aget sc-gal-information "sc-citation")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (sc-nested-citation-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (insert (aget sc-gal-information "sc-nested-citation"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (setq fend (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 (forward-line 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 (and sc-auto-fill-query-each-paragraph-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 (message " "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 )))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 (defun sc-uncite-region (start end cite-regexp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 "Uncite a previously cited region delineated by START and END.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 CITE-REGEXP describes how a cited line of texts starts. Unciting also
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 auto-fills paragraph if sc-auto-fill-region-p is non-nil."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 (set-mark end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (let ((fstart (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (fend (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (while (< (point) (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 ;; if end of line, then perhaps autofill
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (cond ((eolp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 (or (= fstart fend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 (not sc-auto-fill-region-p)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 (and sc-auto-fill-query-each-paragraph-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 (not (y-or-n-p "Fill this paragraph? ")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 (save-excursion (set-mark fend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 (goto-char (/ (+ fstart fend 1) 2))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 (run-hooks 'sc-fill-paragraph-hook)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (setq fstart (point)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 fend (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 ;; not end of line so perhaps uncite it
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 ((looking-at cite-regexp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 (save-restriction
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 (narrow-to-region (sc-linepos 'bol) (sc-linepos))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (delete-region (point-min)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 (progn (re-search-forward cite-regexp
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 (point-max)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 (match-end 0)))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 (setq fend (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 (forward-line 1)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 ;; this section contains paragraph filling support
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 (defun sc-guess-fill-prefix (&optional literalp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 "Guess the fill prefix used on the current line.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 Use various heuristics to find the fill prefix. Search begins on first
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 non-blank line after point.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 1) If fill-prefix is already bound to the empty string, return
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 nil.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 2) If fill-prefix is already bound, but not to the empty
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 string, return the value of fill-prefix.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 3) If the current line starts with the last chosen citation
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 string, then that string is returned.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 4) If the current line starts with a string matching the regular
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 expression sc-cite-regexp, return the match. Note that if
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 optional LITERALP is provided and non-nil, then the *string*
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 that matches the regexp is return. Otherwise, if LITERALP is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 not provided or is nil, the *regexp* sc-cite-regexp is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 returned.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 5) If the current line starts with any number of characters,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 followed by the sc-citation-delimiter and then white space,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 that match is returned. See comment #4 above for handling of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 LITERALP.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 6) Nil is returned."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 ;; scan for first non-blank line in the region
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 (skip-chars-forward "\n\t ")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 (let ((citation (aget sc-gal-information "sc-citation"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 (generic-citation
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 (concat "\\s *[^ \t\n" sc-citation-delimiter "]+>\\s +")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 ((string= fill-prefix "") nil) ;; heuristic #1
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 (fill-prefix) ;; heuristic #2
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 ((looking-at (regexp-quote citation)) citation) ;; heuristic #3
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 ((looking-at sc-cite-regexp) ;; heuristic #4
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 (if literalp
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 (buffer-substring
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (point)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 (progn (re-search-forward (concat sc-cite-regexp "\\s *")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 (point-max) nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 sc-cite-regexp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ((looking-at generic-citation) ;; heuristic #5
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 (if literalp
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 (buffer-substring
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 (point)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 (progn (re-search-forward generic-citation) (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 generic-citation))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 (t nil))))) ;; heuristic #6
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 (defun sc-consistant-cite-p (prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 "Check current paragraph for consistant citation.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 Scans to paragraph delineated by (forward|backward)-paragraph to see
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 if all lines start with PREFIX. Returns t if entire paragraph is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 consistantly cited, nil otherwise."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 (let ((end (progn (forward-paragraph)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 (or (not (eolp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (forward-char -1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (start (progn (backward-paragraph)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (or (not (eolp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 (forward-char 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 (badline t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 (while (and (< (point) end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 badline)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 (setq badline (looking-at prefix))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 (forward-line 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 badline)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 (defun sc-fill-start (fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 "Find buffer position of start of region which begins with FILL-PREFIX.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 Restrict scan to current paragraph."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 (let ((badline nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 (top (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (backward-paragraph)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (or (not (eolp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (forward-char 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (point))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 (while (and (not badline)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 (> (point) top))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 (forward-line -1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 (setq badline (not (looking-at fill-prefix)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (forward-line 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (defun sc-fill-end (fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 "Find the buffer position of end of region which begins with FILL-PREFIX.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 Restrict scan to current paragraph."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 (let ((badline nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 (bot (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 (forward-paragraph)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 (or (not (eolp))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 (forward-char -1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (point))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 (while (and (not badline)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (< (point) bot))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (setq badline (not (looking-at fill-prefix)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 (forward-line 1)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (forward-line -1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 (point)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (defun sc-fill-paragraph ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 "Supercite's paragraph fill function.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 Fill the paragraph containing or following point. Use
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 sc-guess-fill-prefix to find the fill-prefix for the paragraph.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 If the paragraph is inconsistantly cited (mixed fill-prefix), then the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 user is queried to restrict the the fill to only those lines around
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 point which begin with the fill prefix.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 The variable sc-fill-arg is passed to fill-paragraph and
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 fill-region-as-paragraph which controls justification of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 paragraph. sc-fill-arg is set by sc-fill-paragraph-manually."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 (let ((pnt (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (fill-prefix (sc-guess-fill-prefix t)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 ((not fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 (fill-paragraph sc-fill-arg))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 ((sc-consistant-cite-p fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 (fill-paragraph sc-fill-arg))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 ((y-or-n-p "Inconsistent citation found. Restrict? ")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (message "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (fill-region-as-paragraph (progn (goto-char pnt)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 (sc-fill-start fill-prefix))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 (progn (goto-char pnt)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 (sc-fill-end fill-prefix))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 sc-fill-arg))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 (message "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 (progn
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 (setq fill-prefix (aget sc-gal-information "sc-citation"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 (fill-paragraph sc-fill-arg)))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 ;; the following functions are the top level, interactive commands that
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 ;; can be bound to key strokes
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 (defun sc-insert-reference (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 "Insert, at point, a reference header in the body of the reply.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 Numeric ARG indicates which header style from sc-rewrite-header-list
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 to use when rewriting the header. No supplied ARG indicates use of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 sc-preferred-header-style.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 With just \\[universal-argument], electric reference insert mode is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 entered, regardless of the value of sc-electric-references-p. See
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 sc-electric-mode for more information."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (if (consp arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 (sc-electric-mode)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 (let ((pref (cond ((sc-valid-index-p arg) arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 ((sc-valid-index-p sc-preferred-header-style)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 sc-preferred-header-style)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (t 0))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 (if sc-electric-references-p (sc-electric-mode pref)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (condition-case err
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 (eval (nth pref sc-rewrite-header-list))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 (void-function
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 (progn (message
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 "Symbol's function definition is void: %s. (Header %d)."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 (symbol-name (car (cdr err)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 pref)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (beep)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (error
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (progn (message "Error evaluating rewrite header function %d."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 pref)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 (beep)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 )))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 (defun sc-cite (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 "Cite the region of text between point and mark.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 Numeric ARG, if supplied, is passed unaltered to sc-insert-reference."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 (if (not (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 (error "Please designate a region to cite (i.e. set the mark)."))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (catch 'select-abort
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (let ((sc-cite-context 'citing)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 (sc-force-confirmation-p (interactive-p)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (sc-select)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 (undo-boundary)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (let ((xchange (if (> (sc-mark) (point)) nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 (exchange-point-and-mark)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 t)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (sc-insert-reference arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (sc-cite-region (point) (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 ;; leave point on first cited line
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 (while (and (< (point) (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (not (looking-at (aget sc-gal-information
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (if sc-nested-citation-p
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 "sc-nested-citation"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 "sc-citation")))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (forward-line 1))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (and xchange
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (exchange-point-and-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (defun sc-uncite ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 "Uncite the region between point and mark."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (interactive)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 (if (not (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (error "Please designate a region to uncite (i.e. set the mark)."))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (undo-boundary)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 (let ((xchange (if (> (sc-mark) (point)) nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 (exchange-point-and-mark)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 (fp (or (sc-guess-fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 "")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (sc-uncite-region (point) (sc-mark) fp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (and xchange
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (exchange-point-and-mark))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 (defun sc-recite ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 "Recite the region by first unciting then citing the text."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (interactive)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 (if (not (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 (error "Please designate a region to recite (i.e. set the mark)."))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (catch 'select-abort
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 (let ((sc-cite-context 'reciting)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 (sc-force-confirmation-p t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (sc-select)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 (undo-boundary)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (let ((xchange (if (> (sc-mark) (point)) nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 (exchange-point-and-mark)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 (fp (or (sc-guess-fill-prefix)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 "")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (sc-uncite-region (point) (sc-mark) fp)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (sc-cite-region (point) (sc-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 (and xchange
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 (exchange-point-and-mark))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (defun sc-insert-citation ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 "Insert citation string at beginning of current line."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (interactive)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (beginning-of-line)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (insert (aget sc-gal-information "sc-citation"))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 (defun sc-open-line (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 "Insert a newline and leave point before it.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 Also inserts the guessed prefix at the beginning of the new line. With
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 numeric ARG, inserts that many new lines."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (interactive "p")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 (save-excursion
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (let ((start (point))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (string (or (sc-guess-fill-prefix t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 "")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (open-line arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 (goto-char start)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 (forward-line 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 (while (< 0 arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 (insert string)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 (forward-line 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (setq arg (- arg 1))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (defun sc-fill-paragraph-manually (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 "Fill current cited paragraph.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 Really just runs the hook sc-fill-paragraph-hook, however it does set
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 the global variable sc-fill-arg to the value of ARG. This is
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 currently the only way to pass an argument to a hookified function."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 (setq sc-fill-arg arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 (run-hooks 'sc-fill-paragraph-hook))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (defun sc-modify-information (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 "Interactively modify information in the information alist.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 \\[universal-argument] if supplied, deletes the entry from the alist.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 You can add an entry by supplying a key instead of completing."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 (let* ((delete-p (consp arg))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 (action (if delete-p "delete" "modify"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 (defaultkey (aheadsym sc-gal-information))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (prompt (concat "Select information key to "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 action ": (default "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 defaultkey ") "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (key (completing-read prompt sc-gal-information))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 )
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (if (or (string= key "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (null key))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (setq key defaultkey))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 (if delete-p (adelete 'sc-gal-information key)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (let* ((oldval (aget sc-gal-information key t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (prompt (concat "Enter new value for key \""
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 key "\" (default \"" oldval "\") "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (newval (read-input prompt)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (if (or (string= newval "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 (null newval))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (aput 'sc-gal-information key newval)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 )))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (defun sc-view-field (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 "View field values in the information alist.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 This is essentially an interactive version of sc-field, and is similar
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 to sc-modify-information, except that the field values can't be
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 modified. With \\[universal-argument], if supplied, inserts the value
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 into the current buffer as well."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 (let* ((defaultkey (aheadsym sc-gal-information))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (prompt (concat "View information key: (default "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 defaultkey ") "))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (key (completing-read prompt sc-gal-information)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 (if (or (string= key "")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (null key))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 (setq key defaultkey))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 (let* ((val (aget sc-gal-information key t))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (pval (if val (concat "\"" val "\"") "nil")))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (message "value of key %s: %s" key pval)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (if (and key (consp arg)) (insert val)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 (defun sc-glom-headers ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 "Glom information from mail headers in region between point and mark.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 Any old information is lost, unless an error occurs."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 (interactive)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 (let ((attr (copy-sequence sc-gal-attributions))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (info (copy-sequence sc-gal-information)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (setq sc-gal-attributions nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 sc-gal-information nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 (let ((start (region-beginning))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (end (region-end))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (sc-force-confirmation-p t)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (sc-cite-context nil))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (sc-fetch-fields start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (if (null sc-gal-information)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 (progn
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 (message "No mail headers found! Restoring old information.")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 (setq sc-gal-attributions attr
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 sc-gal-information info))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (sc-mail-yank-clear-headers start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (if (not (catch 'select-abort
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (condition-case foo
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 (sc-select)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 (quit (beep) (throw 'select-abort nil)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 ))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (setq sc-gal-attributions attr
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 sc-gal-information info))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 ))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (defun sc-version (arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 "Show supercite version.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 Universal argument (\\[universal-argument]) ARG inserts version
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 information in the current buffer instead of printing the message in
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 the echo area."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (interactive "P")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (if (consp arg)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 (insert "Using Supercite version " sc-version-number)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (message "Using Supercite version %s" sc-version-number)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 ;; leach onto current mode
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (defun sc-append-current-keymap ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 "Append some useful key bindings to the current local key map.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 This searches sc-local-keymap for the keymap to install based on the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 major-mode of the current buffer."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (let ((hook (car (cdr (assq major-mode sc-local-keymaps)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 ((not hook)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 (run-hooks 'sc-default-keymap))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 ((not (listp hook))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (setq hook (car (cdr (assq hook sc-local-keymaps))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434 (run-hooks 'hook))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 (t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (run-hooks 'hook))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 (setq sc-leached-keymap (current-local-map)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (defun sc-snag-all-keybindings ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 "Snag all keybindings in major-mode's current keymap."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 (let* ((curkeymap (current-local-map))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442 (symregexp ".*sc-.*\n")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 (docstring (substitute-command-keys "\\{curkeymap}"))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 (start 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 (maxend (length docstring))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 (spooge ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (while (and (< start maxend)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (string-match symregexp docstring start))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (setq spooge (concat spooge (substring docstring
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (match-beginning 0)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (match-end 0))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (setq start (match-end 0)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 spooge))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 (defun sc-spoogify-docstring ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 "Modifies (makes into spooge) the docstring for the current major mode.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 This will leach the keybinding descriptions for supercite onto the end
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 of the current major mode's docstring. If major mode is preloaded,
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 this function will first make a copy of the list associated with the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 mode, then modify this copy."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (let* ((symfunc (symbol-function major-mode))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (doc-cdr (and (listp symfunc) (nthcdr 2 symfunc)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 (doc-str (documentation major-mode)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 ;; is a docstring even provided?
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 ((not (stringp doc-str)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 ;; have we already leached on?
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 ((string-match "Supercite" doc-str))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 ;; lets build the new doc string
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 (t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (let* ((described (sc-snag-all-keybindings))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (commonstr "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 The major mode for this buffer has been modified to include the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 Supercite 2.3 package for handling attributions and citations of
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 original messages in email replies. For more information on this
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 package, type \"\\[sc-describe]\".")
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (newdoc-str
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 (concat doc-str commonstr
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (if (not (string= described ""))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (concat "\n\nThe following keys are bound "
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 "to Supercite commands:\n\n"
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 described)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 ))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (cond
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (doc-cdr
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (condition-case nil
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (setcar doc-cdr newdoc-str)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (error
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 ;; the major mode must be preloaded, make a copy first
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 (setq symfunc (copy-sequence (symbol-function major-mode))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 doc-cdr (nthcdr 2 symfunc))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (setcar doc-cdr newdoc-str)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 (fset major-mode symfunc))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 ;; lemacs 19 byte-code.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ;; Set function to a new byte-code vector with the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 ;; new documentation in the documentation slot (element 4).
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 ;; We can't use aset because aset won't allow you to modify
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 ;; a byte-code vector.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 ;; Include element 5 if the vector has one.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (t
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (fset major-mode
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (apply 'make-byte-code
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 (aref symfunc 0) (aref symfunc 1)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (aref symfunc 2) (aref symfunc 3)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 newdoc-str
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (if (> (length symfunc) 5)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 (list (aref symfunc 5)))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 )))))))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 ;; this section contains default hooks and hook support for execution
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (defun sc-cite-original ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 "Hook version of sc-cite.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 This is callable from the various mail and news readers' reply
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 function according to the agreed upon standard. See \\[sc-describe]
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 for more details. Sc-cite-original does not do any yanking of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 original message but it does require a few things:
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 1) The reply buffer is the current buffer.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 2) The original message has been yanked and inserted into the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 reply buffer.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 3) Verbose mail headers from the original message have been
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 inserted into the reply buffer directly before the text of the
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 original message.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 4) Point is at the beginning of the verbose headers.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 5) Mark is at the end of the body of text to be cited."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 (run-hooks 'sc-pre-hook)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (setq sc-gal-attributions nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (setq sc-gal-information nil)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (let ((start (region-beginning))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 (end (region-end)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (sc-fetch-fields start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 (sc-mail-yank-clear-headers start end)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (if (not sc-all-but-cite-p)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 (sc-cite sc-preferred-header-style))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 (sc-append-current-keymap)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (sc-spoogify-docstring)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 (run-hooks 'sc-post-hook)))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 ;; describe this package
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 ;;
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 (defun sc-describe ()
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 "Supercite version 2.3 is now described in a texinfo manual which
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 makes the documenation available both for online perusal via emacs'
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 info system, or for hard-copy printing using the TeX facility.
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 To view the online document hit \\[info], then \"mSupercite <RET>\"."
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (interactive)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (describe-function 'sc-describe))
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 ;; ======================================================================
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 ;; load hook
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 (run-hooks 'sc-load-hook)
341d551a3411 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 (provide 'sc)