annotate lisp/mu/mu-cite.el @ 8:4b173ad71786 r19-15b5

Import from CVS: tag r19-15b5
author cvs
date Mon, 13 Aug 2007 08:47:35 +0200
parents b82b59fe008d
children 49a24b4fd526
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
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>
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 4
diff changeset
9 ;; Version: $Revision: 1.2 $
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; This file is part of tl (Tiny Library).
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
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 4
diff changeset
57 "$Id: mu-cite.el,v 1.2 1996/12/22 00:29:20 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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (defvar mu-cite/cited-prefix-regexp "\\(^[^ \t\n>]+>+[ \t]*\\|^[ \t]*$\\)"
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (defvar mu-cite/registration-file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (expand-file-name "~/.mu-cite.el")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 "*The name of the user environment file for mu-cite.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (defvar mu-cite/allow-null-string-registration nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 "*If non-nil, null-string citation-name is registered.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 (defvar mu-cite/registration-symbol 'mu-cite/citation-name-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (defvar mu-cite/citation-name-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (load mu-cite/registration-file t t t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (or (eq 'mu-cite/citation-name-alist mu-cite/registration-symbol)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (setq mu-cite/citation-name-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (symbol-value mu-cite/registration-symbol))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (defvar mu-cite/minibuffer-history nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 ;; get citation-name from the database
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 (defun mu-cite/get-citation-name (from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 (assoc-value from mu-cite/citation-name-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 ;; register citation-name to the database
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (defun mu-cite/add-citation-name (name from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (setq mu-cite/citation-name-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (put-alist from name mu-cite/citation-name-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (mu-cite/save-to-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 ;; save to file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (defun mu-cite/save-to-file ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 (let* ((filename mu-cite/registration-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (buffer (get-buffer-create " *mu-register*")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (set-buffer buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (setq buffer-file-name filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 (format ";;; %s\n" (file-name-nondirectory filename)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (format ";;; This file is generated automatically by mu-cite %s.\n\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 mu-cite/version))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (insert (format "(setq %s\n '(" mu-cite/registration-symbol))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (insert (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (function prin1-to-string)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 mu-cite/citation-name-alist "\n "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 (insert "\n ))\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 (format ";;; %s ends here.\n" (file-name-nondirectory filename)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (save-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 (kill-buffer buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 ;;; @ item methods
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 ;;; @@ ML count
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (defvar mu-cite/ml-count-field-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 "*List of header fields which contain sequence number of mailing list.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 (defun mu-cite/get-ml-count-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 (let ((field-list mu-cite/ml-count-field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 (catch 'tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 (while field-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 (let* ((field (car field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 (ml-count (mu-cite/get-field-value field)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 (if (and ml-count (string-match "[0-9]+" ml-count))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 (throw 'tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 (substring ml-count
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 (match-beginning 0)(match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (setq field-list (cdr field-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 ;;; @@ prefix and registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (defun mu-cite/get-prefix-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (or (mu-cite/get-citation-name (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 ">")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (defun mu-cite/get-prefix-register-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (let ((addr (mu-cite/get-value 'address)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 (or (mu-cite/get-citation-name addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 (let ((return
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 (or (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 'mu-cite/minibuffer-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 (if (and (or mu-cite/allow-null-string-registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 (not (string-equal return "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (y-or-n-p (format "Register \"%s\"? " return)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (mu-cite/add-citation-name return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 return))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (defun mu-cite/get-prefix-register-verbose-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (let* ((addr (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (return1 (mu-cite/get-citation-name addr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (return (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (or return1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 'mu-cite/minibuffer-history))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (if (and (or mu-cite/allow-null-string-registration
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (not (string-equal return "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (not (string-equal return return1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (y-or-n-p (format "Register \"%s\"? " return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (mu-cite/add-citation-name return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 ;;; @@ set up
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 (defvar mu-cite/default-methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (list (cons 'from
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (mu-cite/get-field-value "From")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (cons 'date
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 (mu-cite/get-field-value "Date")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 (cons 'message-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 (mu-cite/get-field-value "Message-Id")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (cons 'subject
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 "Subject")
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 'ml-name
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 "X-Ml-Name")
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 'ml-count (function mu-cite/get-ml-count-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (cons 'address-structure
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 (car
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (std11-parse-address-string (mu-cite/get-value 'from))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (cons 'full-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (std11-full-name-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 (mu-cite/get-value 'address-structure))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 (cons 'address
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (std11-address-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (mu-cite/get-value 'address-structure))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (cons 'id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 (let ((ml-name (mu-cite/get-value 'ml-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (if ml-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 (concat "["
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 ml-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 " : No."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (mu-cite/get-value 'ml-count)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 "]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 (mu-cite/get-value 'message-id)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 (cons 'in-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 (let ((id (mu-cite/get-value 'id)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (if id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (format ">>>>> In %s \n" id)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 "")))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 (cons 'prefix (function mu-cite/get-prefix-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 (cons 'prefix-register
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 (function mu-cite/get-prefix-register-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 (cons 'prefix-register-verbose
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (function mu-cite/get-prefix-register-verbose-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 (cons 'x-attribution
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 (mu-cite/get-field-value "X-Attribution")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 ;;; @ fundamentals
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (defvar mu-cite/methods-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 (defun mu-cite/make-methods ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 (setq mu-cite/methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 (copy-alist mu-cite/default-methods-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 (run-hooks 'mu-cite/instantiation-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337 (defun mu-cite/get-value (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 (let ((ret (assoc-value item mu-cite/methods-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339 (if (functionp ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340 (prog1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 (setq ret (funcall ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 (set-alist 'mu-cite/methods-alist item ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344 ret)))
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/eval-format (list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
347 (mapconcat (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
348 (lambda (elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
349 (cond ((stringp elt) elt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
350 ((symbolp elt) (mu-cite/get-value elt))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
351 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
352 list "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
353 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
354
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
355
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
356 ;;; @ main function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
357 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
358
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
359 (defun mu-cite/cite-original ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
360 "Citing filter function.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
361 This is callable from the various mail and news readers' reply
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
362 function according to the agreed upon standard."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
363 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
364 (mu-cite/make-methods)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
365 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
366 (if (< (mark t) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
367 (exchange-point-and-mark))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
368 (narrow-to-region (point)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
369 (run-hooks 'mu-cite/pre-cite-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
370 (let ((last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
371 (top (mu-cite/eval-format mu-cite/top-format))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
372 (prefix (mu-cite/eval-format mu-cite/prefix-format))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
373 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
374 (if (re-search-forward "^-*$" nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
375 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
376 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
377 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
378 (delete-region last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
379 (insert top)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
380 (setq last-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
381 (while (< (point)(mark t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
382 (or (looking-at mu-cite/cited-prefix-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
383 (insert prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
384 (forward-line 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
385 (goto-char last-point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
386 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
387 (run-hooks 'mu-cite/post-cite-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
388 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
389
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
390
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
391 ;;; @ message editing utilities
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
392 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
393
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
394 (defvar cited-prefix-regexp "^[^ \t>]*[>|]+[ \t#]*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
395 "*Regexp to match the citation prefix.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
396
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
397 (defun fill-cited-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
398 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
399 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
400 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
401 (goto-char end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
402 (while (not (eolp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
403 (backward-char)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
404 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
405 (setq end (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
406 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
407 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
408 (let* ((fill-prefix
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
409 (let* ((str1 (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
410 (progn (beginning-of-line)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
411 (progn (end-of-line)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
412 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
413 (str2 (let ((p0 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
414 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
415 (if (> (count-lines p0 (point)) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
416 (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
417 (progn (beginning-of-line)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
418 (progn (end-of-line)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
419 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
420 (ret (string-compare-from-top str1 str2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
421 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
422 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
423 (let ((prefix (nth 1 ret)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
424 (if (string-match cited-prefix-regexp prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
425 (substring prefix 0 (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
426 prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
427 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
428 (if (re-search-forward cited-prefix-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
429 (buffer-substring (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
430 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
431 (pat (concat "\n" fill-prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
432 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
433 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
434 (while (search-forward pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
435 (let ((b (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
436 (e (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
437 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
438 (delete-region b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
439 (if (and (> b (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
440 (let ((cat (char-category
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
441 (char-before b))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
442 (or (string-match "a" cat)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
443 (string-match "l" cat)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
444 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
445 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
446 (insert " ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
447 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
448 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
449 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
450 (fill-region (point-min) (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
451 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
452
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
453 (defvar citation-mark-chars ">}|")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
454
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
455 (defun compress-cited-prefix ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
456 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
457 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
458 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
459 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
460 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
461 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
462 (concat "^\\([ \t]*[^ \t\n" citation-mark-chars "]*["
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
463 citation-mark-chars "]\\)+") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
464 (let* ((b (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
465 (e (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
466 (prefix (buffer-substring b e))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
467 ps pe (s 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
468 (nest (let ((i 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
469 (if (string-match "<[^<>]+>" prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
470 (setq prefix (substring prefix 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
471 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
472 (while (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
473 (concat "\\([" citation-mark-chars "]+\\)[ \t]*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
474 prefix s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
475 (setq i (+ i (- (match-end 1)(match-beginning 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
476 ps s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
477 pe (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
478 s (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
479 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
480 i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
481 (if (and ps (< ps pe))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
482 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
483 (delete-region b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
484 (insert (concat (substring prefix ps pe) (make-string nest ?>)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
485 ))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
486
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
487 (defun replace-top-string (old new)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
488 (interactive "*sOld string: \nsNew string: ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
489 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
490 (concat "^" (regexp-quote old)) nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
491 (replace-match new)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
492 ))
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 ;;; @ end
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 (provide 'mu-cite)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
499
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
500 (run-hooks 'mu-cite-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
501
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
502 ;;; mu-cite.el ends here