annotate lisp/mu/mu-cite.el @ 32:e04119814345 r19-15b99

Import from CVS: tag r19-15b99
author cvs
date Mon, 13 Aug 2007 08:52:56 +0200
parents d95e72db5c07
children 7e54bd776075
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; mu-cite.el --- yet another citation tool for GNU Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6 ;; MINOURA Makoto <minoura@netlaputa.or.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
9 ;; Version: $Revision: 1.6 $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;; Keywords: mail, news, citation
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
12 ;; This file is part of MU (Message Utilities).
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;; - How to use
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 ;; 1. bytecompile this file and copy it to the apropriate directory.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;; 2. put the following lines to your ~/.emacs:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;; for EMACS 19 or later and XEmacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;; (autoload 'mu-cite/cite-original "mu-cite" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 ;; ;; for all but message-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 ;; (add-hook 'mail-citation-hook 'mu-cite/cite-original)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 ;; ;; for message-mode only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 ;; (setq message-cite-function (function mu-cite/cite-original))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 ;; for EMACS 18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 ;; ;; for all but mh-e
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 ;; (add-hook 'mail-yank-hooks (function mu-cite/cite-original))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ;; ;; for mh-e only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44 ;; (add-hook 'mh-yank-hooks (function mu-cite/cite-original))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 (require 'std11)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 (require 'tl-str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 (require 'tl-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 ;;; @ version
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 (defconst mu-cite/RCS-ID
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
57 "$Id: mu-cite.el,v 1.6 1997/03/16 05:55:24 steve Exp $")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 (defconst mu-cite/version (get-version-string mu-cite/RCS-ID))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 ;;; @ formats
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
64 (defvar mu-cite/cited-prefix-regexp "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 "*Regexp to match the citation prefix.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 If match, mu-cite doesn't insert citation prefix.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 (defvar mu-cite/prefix-format '(prefix-register-verbose "> ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 "*List to represent citation prefix.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 Each elements must be string or method name.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (defvar mu-cite/top-format '(in-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 ">>>>> " from " wrote:\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 "*List to represent top string of citation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 Each elements must be string or method name.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 ;;; @ hooks
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (defvar mu-cite-load-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 "*List of functions called after mu-cite is loaded.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 Use this hook to add your own methods to `mu-cite/default-methods-alist'.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (defvar mu-cite/instantiation-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 "*List of functions called just before narrowing to the message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (defvar mu-cite/pre-cite-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 "*List of functions called before citing a region of text.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (defvar mu-cite/post-cite-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 "*List of functions called after citing a region of text.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 ;;; @ field
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (defvar mu-cite/get-field-value-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 (list (cons 'mh-letter-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 (lambda (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (if (and (stringp mh-sent-from-folder)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (numberp mh-sent-from-msg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 (set-buffer mh-sent-from-folder)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 (set-buffer mh-show-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (and (boundp 'mime::preview/article-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (bufferp mime::preview/article-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 (set-buffer mime::preview/article-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (std11-field-body name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (defun mu-cite/get-field-value (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (or (std11-field-body name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (let ((method (assq major-mode mu-cite/get-field-value-method-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (if method
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (funcall (cdr method) name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 ;;; @ prefix registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
125 (defvar mu-cite/registration-file (expand-file-name "~/.mu-cite.el")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 "*The name of the user environment file for mu-cite.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (defvar mu-cite/allow-null-string-registration nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 "*If non-nil, null-string citation-name is registered.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 (defvar mu-cite/registration-symbol 'mu-cite/citation-name-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 (defvar mu-cite/citation-name-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (or (eq 'mu-cite/citation-name-alist mu-cite/registration-symbol)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (setq mu-cite/citation-name-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (symbol-value mu-cite/registration-symbol))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (defvar mu-cite/minibuffer-history nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 ;; get citation-name from the database
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 (defun mu-cite/get-citation-name (from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 (assoc-value from mu-cite/citation-name-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 ;; register citation-name to the database
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 (defun mu-cite/add-citation-name (name from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (setq mu-cite/citation-name-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (put-alist from name mu-cite/citation-name-alist))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
149 (mu-cite/save-registration-file)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
152 ;; load/save registration file
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
153 (defun mu-cite/load-registration-file ()
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
154 (let* ((file mu-cite/registration-file)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
155 (buffer (get-buffer-create " *mu-register*")))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
156 (if (file-readable-p file)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
157 (unwind-protect
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
158 (save-excursion
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
159 (set-buffer buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
160 (erase-buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
161 (insert-file-contents file)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
162 ;; (eval-buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
163 (eval-current-buffer))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
164 (kill-buffer buffer))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
165 )))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
166 (add-hook 'mu-cite-load-hook (function mu-cite/load-registration-file))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
167
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
168 (defun mu-cite/save-registration-file ()
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
169 (let* ((file mu-cite/registration-file)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (buffer (get-buffer-create " *mu-register*")))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
171 (unwind-protect
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
172 (save-excursion
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
173 (set-buffer buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
174 (setq buffer-file-name file)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
175 (erase-buffer)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
176 (insert ";;; " (file-name-nondirectory file) "\n")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
177 (insert ";;; This file is generated automatically by mu-cite "
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
178 mu-cite/version "\n\n")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
179 (insert "(setq "
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
180 (symbol-name mu-cite/registration-symbol)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
181 "\n '(")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
182 (insert (mapconcat
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
183 (function prin1-to-string)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
184 mu-cite/citation-name-alist "\n "))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
185 (insert "\n ))\n\n")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
186 (insert ";;; "
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
187 (file-name-nondirectory file)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
188 " ends here.\n")
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
189 (save-buffer))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 18
diff changeset
190 (kill-buffer buffer))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 ;;; @ item methods
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 ;;; @@ ML count
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (defvar mu-cite/ml-count-field-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 "*List of header fields which contain sequence number of mailing list.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (defun mu-cite/get-ml-count-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 (let ((field-list mu-cite/ml-count-field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 (catch 'tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (while field-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (let* ((field (car field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 (ml-count (mu-cite/get-field-value field)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 (if (and ml-count (string-match "[0-9]+" ml-count))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 (throw 'tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (substring ml-count
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (match-beginning 0)(match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 (setq field-list (cdr field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 ;;; @@ prefix and registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 (defun mu-cite/get-prefix-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (or (mu-cite/get-citation-name (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 ">")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (defun mu-cite/get-prefix-register-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (let ((addr (mu-cite/get-value 'address)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (or (mu-cite/get-citation-name addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (let ((return
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (or (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 'mu-cite/minibuffer-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (if (and (or mu-cite/allow-null-string-registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (not (string-equal return "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (y-or-n-p (format "Register \"%s\"? " return)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (mu-cite/add-citation-name return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 return))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (defun mu-cite/get-prefix-register-verbose-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (let* ((addr (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 (return1 (mu-cite/get-citation-name addr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (return (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (or return1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 'mu-cite/minibuffer-history))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (if (and (or mu-cite/allow-null-string-registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (not (string-equal return "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (not (string-equal return return1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (y-or-n-p (format "Register \"%s\"? " return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (mu-cite/add-citation-name return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 ;;; @@ set up
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 (defvar mu-cite/default-methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (list (cons 'from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 (mu-cite/get-field-value "From")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (cons 'date
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 (mu-cite/get-field-value "Date")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (cons 'message-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 (mu-cite/get-field-value "Message-Id")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (cons 'subject
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 (mu-cite/get-field-value "Subject")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (cons 'ml-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 (mu-cite/get-field-value "X-Ml-Name")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 (cons 'ml-count (function mu-cite/get-ml-count-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (cons 'address-structure
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (car
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 (std11-parse-address-string (mu-cite/get-value 'from))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 (cons 'full-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 (std11-full-name-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (mu-cite/get-value 'address-structure))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 (cons 'address
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 (std11-address-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 (mu-cite/get-value 'address-structure))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 (cons 'id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (let ((ml-name (mu-cite/get-value 'ml-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 (if ml-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 (concat "["
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 ml-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 " : No."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (mu-cite/get-value 'ml-count)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 "]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 (mu-cite/get-value 'message-id)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 (cons 'in-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 (let ((id (mu-cite/get-value 'id)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325 (if id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 (format ">>>>> In %s \n" id)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 "")))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328 (cons 'prefix (function mu-cite/get-prefix-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (cons 'prefix-register
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330 (function mu-cite/get-prefix-register-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 (cons 'prefix-register-verbose
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 (function mu-cite/get-prefix-register-verbose-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 (cons 'x-attribution
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336 (mu-cite/get-field-value "X-Attribution")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 ;;; @ fundamentals
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344 (defvar mu-cite/methods-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
345
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
346 (defun mu-cite/make-methods ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
347 (setq mu-cite/methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
348 (copy-alist mu-cite/default-methods-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
349 (run-hooks 'mu-cite/instantiation-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
350 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
351
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
352 (defun mu-cite/get-value (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
353 (let ((ret (assoc-value item mu-cite/methods-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
354 (if (functionp ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
355 (prog1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
356 (setq ret (funcall ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
357 (set-alist 'mu-cite/methods-alist item ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
358 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
359 ret)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
360
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
361 (defun mu-cite/eval-format (list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
362 (mapconcat (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
363 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
364 (cond ((stringp elt) elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
365 ((symbolp elt) (mu-cite/get-value elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
366 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
367 list "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
368 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
369
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
370
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
371 ;;; @ main function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
372 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
373
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
374 (defun mu-cite/cite-original ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
375 "Citing filter function.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
376 This is callable from the various mail and news readers' reply
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
377 function according to the agreed upon standard."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
378 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
379 (mu-cite/make-methods)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
380 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
381 (if (< (mark t) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
382 (exchange-point-and-mark))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
383 (narrow-to-region (point)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
384 (run-hooks 'mu-cite/pre-cite-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
385 (let ((last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
386 (top (mu-cite/eval-format mu-cite/top-format))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
387 (prefix (mu-cite/eval-format mu-cite/prefix-format))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
388 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
389 (if (re-search-forward "^-*$" nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
390 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
391 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
392 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
393 (delete-region last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
394 (insert top)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
395 (setq last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
396 (while (< (point)(mark t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
397 (or (looking-at mu-cite/cited-prefix-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
398 (insert prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
399 (forward-line 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
400 (goto-char last-point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
401 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
402 (run-hooks 'mu-cite/post-cite-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
403 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
404
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
405
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
406 ;;; @ message editing utilities
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
407 ;;;
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
408
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
409 (defvar citation-mark-chars ">}|"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
410 "*String of characters for citation delimiter. [mu-cite.el]")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
411
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
412 (defvar citation-disable-chars "<{"
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
413 "*String of characters not allowed as citation-prefix.")
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
414
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
415 (defun detect-paragraph-cited-prefix ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
416 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
417 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
418 (let ((i 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
419 (prefix
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
420 (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
421 (progn (beginning-of-line)(point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
422 (progn (end-of-line)(point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
423 ))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
424 str ret)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
425 (while (and (= (forward-line) 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
426 (setq str (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
427 (progn (beginning-of-line)(point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
428 (progn (end-of-line)(point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
429 (setq ret (string-compare-from-top prefix str))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
430 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
431 (setq prefix
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
432 (if (stringp ret)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
433 ret
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
434 (second ret)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
435 (setq i (1+ i))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
436 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
437 (cond ((> i 1) prefix)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
438 ((> i 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
439 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
440 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
441 (narrow-to-region (point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
442 (+ (point)(length prefix)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
443 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
444 (if (re-search-backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
445 (concat "[" citation-mark-chars "]") nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
446 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
447 (goto-char (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
448 (if (looking-at "[ \t]+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
449 (goto-char (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
450 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
451 (buffer-substring (point-min)(point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
452 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
453 prefix)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
454 ((progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
455 (goto-char (point-max))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
456 (re-search-backward
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
457 (concat "[" citation-disable-chars "]") nil t)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
458 (re-search-backward
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
459 (concat "[" citation-mark-chars "]") nil t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
460 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
461 (goto-char (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
462 (if (looking-at "[ \t]+")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
463 (goto-char (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
464 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
465 (buffer-substring (point-min)(point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
466 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
467 (t ""))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
468 )))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
469
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
470 (defun fill-cited-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
471 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
472 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
473 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
474 (goto-char end)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
475 (and (search-backward "\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
476 (setq end (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
477 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
478 (narrow-to-region beg end)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
479 (let* ((fill-prefix (detect-paragraph-cited-prefix))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
480 (pat (concat fill-prefix "\n"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
481 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
482 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
483 (while (search-forward pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
484 (let ((b (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
485 (e (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
486 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
487 (delete-region b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
488 (if (and (> b (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
489 (let ((cat (char-category
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
490 (char-before b))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
491 (or (string-match "a" cat)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
492 (string-match "l" cat)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
493 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
494 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
495 (insert " ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
496 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
497 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
498 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
499 (fill-region (point-min) (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
500 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
501
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
502 (defun compress-cited-prefix ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
503 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
504 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
505 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
506 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
507 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
508 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
509 (concat "^\\([ \t]*[^ \t\n" citation-mark-chars "]*["
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
510 citation-mark-chars "]\\)+") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
511 (let* ((b (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
512 (e (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
513 (prefix (buffer-substring b e))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
514 ps pe (s 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
515 (nest (let ((i 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
516 (if (string-match "<[^<>]+>" prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
517 (setq prefix (substring prefix 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
518 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
519 (while (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
520 (concat "\\([" citation-mark-chars "]+\\)[ \t]*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
521 prefix s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
522 (setq i (+ i (- (match-end 1)(match-beginning 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
523 ps s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
524 pe (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
525 s (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
526 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
527 i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
528 (if (and ps (< ps pe))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
529 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
530 (delete-region b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
531 (insert (concat (substring prefix ps pe) (make-string nest ?>)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
532 ))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
533
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
534 (defun replace-top-string (old new)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
535 (interactive "*sOld string: \nsNew string: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
536 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
537 (concat "^" (regexp-quote old)) nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
538 (replace-match new)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
539 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
540
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
541
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
542 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
543 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
544
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
545 (provide 'mu-cite)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
546
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
547 (run-hooks 'mu-cite-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
548
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
549 ;;; mu-cite.el ends here