Update.
[elisp/mu-cite.git] / mu-cite.el
1 ;;; mu-cite.el --- yet another citation tool for GNU Emacs
2
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;;         MINOURA Makoto <minoura@netlaputa.or.jp>
7 ;;         Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
8 ;; Maintainer: Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, citation
10
11 ;; This file is part of MU (Message Utilities).
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;; - How to use
31 ;;   1. bytecompile this file and copy it to the apropriate directory.
32 ;;   2. put the following lines to your ~/.emacs:
33 ;;      for EMACS 19 or later and XEmacs
34 ;;              (autoload 'mu-cite-original "mu-cite" nil t)
35 ;;              ;; for all but message-mode
36 ;;              (add-hook 'mail-citation-hook (function mu-cite-original))
37 ;;              ;; for message-mode only
38 ;;              (setq message-cite-function (function mu-cite-original))
39 ;;      for EMACS 18
40 ;;              ;; for all but mh-e
41 ;;              (add-hook 'mail-yank-hooks (function mu-cite-original))
42 ;;              ;; for mh-e only
43 ;;              (add-hook 'mh-yank-hooks (function mu-cite-original))
44
45 ;;; Code:
46
47 (eval-when-compile (require 'cl))
48
49 ;; Pickup some macros, e.g. `with-temp-buffer', for old Emacsen.
50 (require 'poe)
51
52 ;; Pickup `char-category' for XEmacs.
53 (require 'emu)
54
55 (require 'custom)
56 (require 'std11)
57 (require 'alist)
58
59
60 ;;; @ version
61 ;;;
62
63 (defconst mu-cite-version "8.0")
64
65
66 ;;; @ obsoletes
67 ;;;
68
69 ;; This part will be abolished in the future.
70
71 ;; variables
72 (eval-when-compile (require 'static))
73
74 (defvar mu-cite/registration-file)
75 (defvar mu-cite-registration-file)
76 (defmacro mu-cite-registration-file ()
77   (if (fboundp 'defvaralias)
78       'mu-cite-registration-file
79     '(if (boundp 'mu-cite/registration-file)
80          (prog1
81              (if (yes-or-no-p
82                   (format "Obsolete variable `%s' found, use anyway? "
83                           'mu-cite/registration-file))
84                  mu-cite/registration-file
85                mu-cite-registration-file)
86            (message "You should use `%s' instead of `%s'."
87                     'mu-cite-registration-file 'mu-cite/registration-file)
88            (sleep-for 1))
89        mu-cite-registration-file)))
90
91 (eval-and-compile
92   (defconst mu-cite-obsolete-variable-alist
93     '((mu-cite/allow-null-string-registration
94        mu-cite-allow-null-string-registration)
95       (mu-cite/citation-name-alist      mu-cite-citation-name-alist)
96       (mu-cite/cited-prefix-regexp      mu-cite-cited-prefix-regexp)
97       (mu-cite/default-methods-alist    mu-cite-default-methods-alist)
98       (mu-cite/instantiation-hook       mu-cite-instantiation-hook)
99       (mu-cite/minibuffer-history       mu-cite-minibuffer-history)
100       (mu-cite/ml-count-field-list      mu-cite-ml-count-field-list)
101       (mu-cite/post-cite-hook           mu-cite-post-cite-hook)
102       (mu-cite/pre-cite-hook            mu-cite-pre-cite-hook)
103       (mu-cite/prefix-format            mu-cite-prefix-format)
104       (mu-cite/registration-file        mu-cite-registration-file)
105       (mu-cite/top-format               mu-cite-top-format)))
106
107   (mapcar
108    (function
109     (lambda (elem)
110       (apply (function make-obsolete-variable) elem)
111       (when (boundp (car elem))
112         (apply (function message)
113                "WARNING: `%s' is an obsolete variable, use `%s' instead."
114                elem))
115       (static-if (fboundp 'defvaralias) ; It may exists in XEmacs.
116           (apply (function defvaralias) elem)
117         (when (boundp (car elem))
118           (eval (list 'defvar (cadr elem) (car elem)))))))
119    mu-cite-obsolete-variable-alist)
120   )
121
122 ;; functions
123 (eval-and-compile
124   (defconst mu-cite-obsolete-function-alist
125     '((mu-cite/add-citation-name        mu-cite-add-citation-name)
126       (mu-cite/cite-original            mu-cite-original)
127       (mu-cite/eval-format              mu-cite-eval-format)
128       (mu-cite/get-citation-name        mu-cite-get-citation-name)
129       (mu-cite/get-field-value          mu-cite-get-field-value)
130       (mu-cite/get-ml-count-method      mu-cite-get-ml-count-method)
131       (mu-cite/get-prefix-method        mu-cite-get-prefix-method)
132       (mu-cite/get-prefix-register-method
133        mu-cite-get-prefix-register-method)
134       (mu-cite/get-prefix-register-verbose-method
135        mu-cite-get-prefix-register-verbose-method)
136       (mu-cite/get-value                mu-cite-get-value)
137       (mu-cite/load-registration-file   mu-cite-load-registration-file)
138       (mu-cite/make-methods             mu-cite-make-methods)
139       (mu-cite/save-registration-file   mu-cite-save-registration-file)))
140
141   (mapcar
142    (function (lambda (elem)
143                (apply (function define-obsolete-function-alias) elem)))
144    mu-cite-obsolete-function-alist)
145   )
146
147
148 ;;; @ set up
149 ;;;
150
151 (defgroup mu-cite nil
152   "yet another citation tool for GNU Emacs."
153   :prefix "mu-cite-"
154   :group 'mail
155   :group 'news)
156
157 (defvar mu-cite-default-methods-alist
158   (list (cons 'from
159               (function
160                (lambda ()
161                  (mu-cite-get-field-value "From"))))
162         (cons 'date
163               (function
164                (lambda ()
165                  (mu-cite-get-field-value "Date"))))
166         (cons 'message-id
167               (function
168                (lambda ()
169                  (mu-cite-get-field-value "Message-Id"))))
170         (cons 'subject
171               (function
172                (lambda ()
173                  (mu-cite-get-field-value "Subject"))))
174         (cons 'ml-name
175               (function
176                (lambda ()
177                  (mu-cite-get-field-value "X-Ml-Name"))))
178         (cons 'ml-count (function mu-cite-get-ml-count-method))
179         (cons 'address-structure
180               (function
181                (lambda ()
182                  (car
183                   (std11-parse-address-string (mu-cite-get-value 'from))))))
184         (cons 'full-name
185               (function
186                (lambda ()
187                  (std11-full-name-string
188                   (mu-cite-get-value 'address-structure)))))
189         (cons 'address
190               (function
191                (lambda ()
192                  (std11-address-string
193                   (mu-cite-get-value 'address-structure)))))
194         (cons 'id
195               (function
196                (lambda ()
197                  (let ((ml-name (mu-cite-get-value 'ml-name)))
198                    (if ml-name
199                        (concat "["
200                                ml-name
201                                " : No."
202                                (mu-cite-get-value 'ml-count)
203                                "]")
204                      (mu-cite-get-value 'message-id))))))
205         (cons 'in-id
206               (function
207                (lambda ()
208                  (let ((id (mu-cite-get-value 'id)))
209                    (if id
210                        (format ">>>>> In %s \n" id)
211                      "")))))
212         (cons 'prefix (function mu-cite-get-prefix-method))
213         (cons 'prefix-register
214               (function mu-cite-get-prefix-register-method))
215         (cons 'prefix-register-verbose
216               (function mu-cite-get-prefix-register-verbose-method))
217         (cons 'x-attribution
218               (function
219                (lambda ()
220                  (mu-cite-get-field-value "X-Attribution"))))
221         ))
222
223
224 ;;; @ formats
225 ;;;
226
227 (defcustom mu-cite-cited-prefix-regexp
228   "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)"
229   "Regexp to match the citation prefix.
230 If match, mu-cite doesn't insert citation prefix."
231   :type 'regexp
232   :group 'mu-cite)
233
234 (defcustom mu-cite-prefix-format '(prefix-register-verbose "> ")
235   "List to represent citation prefix.
236 Each elements must be string or method name."
237   :type (list 'repeat
238               (nconc '(choice :tag "String or Method name")
239                      (mapcar
240                       (function
241                        (lambda (elem) (list 'choice-item (car elem))))
242                       mu-cite-default-methods-alist)
243                      '((symbol :tag "Other Method")
244                        (item "-")
245                        (choice-item :tag "String: \"> \"" "> ")
246                        (string :tag "Other String"))))
247   :group 'mu-cite)
248
249 (defcustom mu-cite-top-format '(in-id ">>>>>\t" from " wrote:\n")
250   "List to represent top string of citation.
251 Each elements must be string or method name."
252   :type (list 'repeat
253               (nconc
254                '(choice :tag "String or Method name")
255                (mapcar
256                 (function
257                  (lambda (elem) (list 'choice-item (car elem))))
258                 mu-cite-default-methods-alist)
259                '((symbol :tag "Other Method")
260                  (item "-")
261                  (choice-item :tag "String: \">>>>>\\t\"" ">>>>>\t")
262                  (choice-item :tag "String: \" wrote:\\n\"" " wrote:\n")
263                  (string :tag "Other String"))))
264   :group 'mu-cite)
265
266
267 ;;; @ hooks
268 ;;;
269
270 (defcustom mu-cite-load-hook nil
271   "List of functions called after mu-cite is loaded.
272 Use this hook to add your own methods to `mu-cite-default-methods-alist'."
273   :type 'hook
274   :group 'mu-cite)
275
276 (defcustom mu-cite-instantiation-hook nil
277   "List of functions called just before narrowing to the message."
278   :type 'hook
279   :group 'mu-cite)
280
281 (defcustom mu-cite-pre-cite-hook nil
282   "List of functions called before citing a region of text."
283   :type 'hook
284   :group 'mu-cite)
285
286 (defcustom mu-cite-post-cite-hook nil
287   "List of functions called after citing a region of text."
288   :type 'hook
289   :group 'mu-cite)
290
291
292 ;;; @ field
293 ;;;
294
295 (defvar mu-cite-get-field-value-method-alist nil
296   "Alist major-mode vs. function to get field-body of header.")
297
298 (defun mu-cite-get-field-value (name)
299   (or (std11-field-body name)
300       (let ((method (assq major-mode mu-cite-get-field-value-method-alist)))
301         (when method
302           (funcall (cdr method) name)))))
303
304
305 ;;; @ prefix registration
306 ;;;
307
308 (defcustom mu-cite-registration-file (expand-file-name "~/.mu-cite.el")
309   "The name of the user environment file for mu-cite."
310   :type 'file
311   :group 'mu-cite)
312
313 (defcustom mu-cite-allow-null-string-registration nil
314   "If non-nil, null-string citation-name is registered."
315   :type 'boolean
316   :group 'mu-cite)
317
318 (defcustom mu-cite-registration-file-coding-system-for-read nil
319   "Coding system for reading registration file."
320   :group 'mu-cite)
321
322 (defcustom mu-cite-registration-file-coding-system-for-write nil
323   "Coding system for writing registration file."
324   :group 'mu-cite)
325
326 (defcustom mu-cite-registration-file-modes 384
327   "Mode bits of `mu-cite-registration-file', as an integer."
328   :type 'integer
329   :group 'mu-cite)
330
331 (defvar mu-cite-registration-symbol 'mu-cite-citation-name-alist)
332
333 (defvar mu-cite-citation-name-alist nil)
334 (unless (eq 'mu-cite-citation-name-alist mu-cite-registration-symbol)
335   (setq mu-cite-citation-name-alist
336         (symbol-value mu-cite-registration-symbol)))
337 (defvar mu-cite-minibuffer-history nil)
338
339 ;; get citation-name from the database
340 (defun mu-cite-get-citation-name (from)
341   (cdr (assoc from mu-cite-citation-name-alist)))
342
343 ;; register citation-name to the database
344 (defun mu-cite-add-citation-name (name from)
345   (setq mu-cite-citation-name-alist
346         (put-alist from name mu-cite-citation-name-alist))
347   (mu-cite-save-registration-file))
348
349 ;; load/save registration file
350 ;;(defun mu-cite-load-registration-file ()
351 ;;  (let ((file mu-cite-registration-file))
352 ;;    (when (file-readable-p file)
353 ;;      (let ((alist (with-temp-buffer
354 ;;                   (eval
355 ;;                    (` (let ((, mu-cite-registration-symbol))
356 ;;                         (insert-file-contents-as-coding-system
357 ;;                          mu-cite-registration-file-coding-system-for-read
358 ;;                          file)
359 ;;                         (condition-case nil
360 ;;                             (progn
361 ;;                               (eval-current-buffer)
362 ;;                               (, mu-cite-registration-symbol))
363 ;;                           (error nil))))))))
364 ;;      (when alist
365 ;;        (setq mu-cite-citation-name-alist alist))))))
366 (defun mu-cite-load-registration-file ()
367   (let ((file (mu-cite-registration-file)))
368     (when (file-readable-p file)
369       (let ((alist (with-temp-buffer
370                      (eval
371                       (` (let ((, mu-cite-registration-symbol)
372                                mu-cite/citation-name-alist)
373                            (insert-file-contents-as-coding-system
374                             mu-cite-registration-file-coding-system-for-read
375                             file)
376                            (condition-case nil
377                                (progn
378                                  (eval-current-buffer)
379                                  (or mu-cite/citation-name-alist
380                                      (, mu-cite-registration-symbol)))
381                              (error nil))))))))
382         (when alist
383           (setq mu-cite-citation-name-alist alist))))))
384 (add-hook 'mu-cite-load-hook (function mu-cite-load-registration-file))
385
386 (defun mu-cite-save-registration-file ()
387   ;;(let ((file mu-cite-registration-file))
388   (let ((file (mu-cite-registration-file)))
389     (with-temp-buffer
390       (setq buffer-file-name file)
391       (insert ";;; " (file-name-nondirectory file) "\n")
392       (insert ";;; This file is generated automatically by mu-cite "
393               mu-cite-version "\n\n")
394       (insert "(setq "
395               (symbol-name mu-cite-registration-symbol)
396               "\n      '(")
397       (insert (mapconcat
398                (function prin1-to-string)
399                mu-cite-citation-name-alist "\n        "))
400       (insert "\n        ))\n\n")
401       (insert ";;; "
402               (file-name-nondirectory file)
403               " ends here.\n")
404       (write-region 1 1 file nil 'nomsg)
405       (condition-case nil
406           (set-file-modes file mu-cite-registration-file-modes)
407         (error nil))
408       (save-buffer-as-coding-system
409        mu-cite-registration-file-coding-system-for-write))))
410
411
412 ;;; @ item methods
413 ;;;
414
415 ;;; @@ ML count
416 ;;;
417
418 (defcustom mu-cite-ml-count-field-list
419   '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id")
420   "List of header fields which contain sequence number of mailing list."
421   :type '(repeat (choice (choice-item "X-Ml-Count")
422                          (choice-item "X-Mail-Count")
423                          (choice-item "X-Seqno")
424                          (choice-item "X-Sequence")
425                          (choice-item "Mailinglist-Id")
426                          (item "-")
427                          (string :tag "Other")))
428   :group 'mu-cite)
429
430 (defun mu-cite-get-ml-count-method ()
431   (let ((field-list mu-cite-ml-count-field-list))
432     (catch 'tag
433       (while field-list
434         (let* ((field (car field-list))
435                (ml-count (mu-cite-get-field-value field)))
436           (when (and ml-count (string-match "[0-9]+" ml-count))
437             (throw 'tag
438                    (substring ml-count
439                               (match-beginning 0)(match-end 0))))
440           (setq field-list (cdr field-list)))))))
441
442
443 ;;; @@ prefix and registration
444 ;;;
445
446 (defun mu-cite-get-prefix-method ()
447   (or (mu-cite-get-citation-name (mu-cite-get-value 'address))
448       ">"))
449
450 (defun mu-cite-get-prefix-register-method ()
451   (let ((addr (mu-cite-get-value 'address)))
452     (or (mu-cite-get-citation-name addr)
453         (let ((return
454                (read-string "Citation name? "
455                             (or (mu-cite-get-value 'x-attribution)
456                                 (mu-cite-get-value 'full-name))
457                             'mu-cite-minibuffer-history)))
458           (when (and (or mu-cite-allow-null-string-registration
459                          (not (string-equal return "")))
460                      (y-or-n-p (format "Register \"%s\"? " return)))
461             (mu-cite-add-citation-name return addr))
462           return))))
463
464 (defun mu-cite-get-prefix-register-verbose-method ()
465   (let* ((addr (mu-cite-get-value 'address))
466          (return1 (mu-cite-get-citation-name addr))
467          (return (read-string "Citation name? "
468                               (or return1
469                                   (mu-cite-get-value 'x-attribution)
470                                   (mu-cite-get-value 'full-name))
471                               'mu-cite-minibuffer-history)))
472     (when (and (or mu-cite-allow-null-string-registration
473                    (not (string-equal return "")))
474                (not (string-equal return return1))
475                (y-or-n-p (format "Register \"%s\"? " return)))
476       (mu-cite-add-citation-name return addr))
477     return))
478
479
480 ;;; @ fundamentals
481 ;;;
482
483 (defvar mu-cite-methods-alist nil)
484
485 (defun mu-cite-make-methods ()
486   (setq mu-cite-methods-alist
487         (copy-alist mu-cite-default-methods-alist))
488   (run-hooks 'mu-cite-instantiation-hook))
489
490 (defun mu-cite-get-value (item)
491   (let ((ret (cdr (assoc item mu-cite-methods-alist))))
492     (if (functionp ret)
493         (prog1
494             (setq ret (save-excursion (funcall ret)))
495           (set-alist 'mu-cite-methods-alist item ret))
496       ret)))
497
498 (defun mu-cite-eval-format (list)
499   (mapconcat (function
500               (lambda (elt)
501                 (cond ((stringp elt) elt)
502                       ((symbolp elt) (mu-cite-get-value elt)))))
503              list ""))
504
505
506 ;;; @ main function
507 ;;;
508
509 ;;;###autoload
510 (defun mu-cite-original ()
511   "Citing filter function.
512 This is callable from the various mail and news readers' reply
513 function according to the agreed upon standard."
514   (interactive)
515   (mu-cite-make-methods)
516   (save-restriction
517     (when (< (mark t) (point))
518       (exchange-point-and-mark))
519     (narrow-to-region (point)(point-max))
520     (run-hooks 'mu-cite-pre-cite-hook)
521     (let ((last-point (point))
522           (top (mu-cite-eval-format mu-cite-top-format))
523           (prefix (mu-cite-eval-format mu-cite-prefix-format)))
524       (when (re-search-forward "^-*$" nil nil)
525         (forward-line 1))
526       (widen)
527       (delete-region last-point (point))
528       (insert top)
529       (setq last-point (point))
530       (while (< (point)(mark t))
531         (unless (looking-at mu-cite-cited-prefix-regexp)
532           (insert prefix))
533         (forward-line 1))
534       (goto-char last-point))
535     (run-hooks 'mu-cite-post-cite-hook)))
536
537
538 ;;; @ message editing utilities
539 ;;;
540
541 (defcustom citation-mark-chars ">}|"
542   "String of characters for citation delimiter."
543   :type 'string
544   :group 'mu-cite)
545
546 (defcustom citation-disable-chars "<{"
547   "String of characters not allowed as citation-prefix."
548   :type 'string
549   :group 'mu-cite)
550
551 (defun detect-paragraph-cited-prefix ()
552   (save-excursion
553     (goto-char (point-min))
554     (let ((i 0)
555           (prefix
556            (buffer-substring
557             (progn (beginning-of-line)(point))
558             (progn (end-of-line)(point))))
559           str ret)
560       (while (and (= (forward-line) 0)
561                   (setq str (buffer-substring
562                              (progn (beginning-of-line)(point))
563                              (progn (end-of-line)(point))))
564                   (setq ret (string-compare-from-top prefix str)))
565         (setq prefix
566               (if (stringp ret)
567                   ret
568                 (cadr ret)))
569         (incf i))
570       (cond ((> i 1) prefix)
571             ((> i 0)
572              (goto-char (point-min))
573              (save-restriction
574                (narrow-to-region (point)
575                                  (+ (point)(length prefix)))
576                (goto-char (point-max))
577                (if (re-search-backward
578                     (concat "[" citation-mark-chars "]") nil t)
579                    (progn
580                      (goto-char (match-end 0))
581                      (when (looking-at "[ \t]+")
582                        (goto-char (match-end 0)))
583                      (buffer-substring (point-min)(point)))
584                  prefix)))
585             ((progn
586                (goto-char (point-max))
587                (re-search-backward
588                 (concat "[" citation-disable-chars "]") nil t)
589                (re-search-backward
590                 (concat "[" citation-mark-chars "]") nil t))
591              (goto-char (match-end 0))
592              (when (looking-at "[ \t]+")
593                (goto-char (match-end 0)))
594              (buffer-substring (point-min)(point)))
595             (t "")))))
596
597 (defun fill-cited-region (beg end)
598   (interactive "*r")
599   (save-excursion
600     (save-restriction
601       (goto-char end)
602       (and (search-backward "\n" nil t)
603            (setq end (match-end 0)))
604       (narrow-to-region beg end)
605       (let* ((fill-prefix (detect-paragraph-cited-prefix))
606              (pat (concat fill-prefix "\n")))
607         (goto-char (point-min))
608         (while (search-forward pat nil t)
609           (let ((b (match-beginning 0))
610                 (e (match-end 0)))
611             (delete-region b e)
612             (when (and (> b (point-min))
613                        (let ((cat (char-category
614                                    (char-before b))))
615                          (or (string-match "a" cat)
616                              (string-match "l" cat))))
617               (insert " "))))
618         (goto-char (point-min))
619         (fill-region (point-min) (point-max))))))
620
621 (defun compress-cited-prefix ()
622   (interactive)
623   (save-excursion
624     (goto-char (point-min))
625     (re-search-forward
626      (concat "^" (regexp-quote mail-header-separator) "$") nil t)
627     (while (re-search-forward
628             (concat "^\\([ \t]*[^ \t\n" citation-mark-chars "]*["
629                     citation-mark-chars "]\\)+") nil t)
630       (let* ((b (match-beginning 0))
631              (e (match-end 0))
632              (prefix (buffer-substring b e))
633              ps pe (s 0)
634              (nest (let ((i 0))
635                      (when (string-match "<[^<>]+>" prefix)
636                        (setq prefix (substring prefix 0 (match-beginning 0))))
637                      (while (string-match
638                              (concat "\\([" citation-mark-chars "]+\\)[ \t]*")
639                              prefix s)
640                        (setq i (+ i (- (match-end 1)(match-beginning 1)))
641                              ps s
642                              pe (match-beginning 1)
643                              s (match-end 0)))
644                      i)))
645         (when (and ps (< ps pe))
646           (delete-region b e)
647           (insert (concat (substring prefix ps pe) (make-string nest ?>))))
648         ))))
649
650 (defun replace-top-string (old new)
651   (interactive "*sOld string: \nsNew string: ")
652   (while (re-search-forward
653           (concat "^" (regexp-quote old)) nil t)
654     (replace-match new)))
655
656 (defun string-compare-from-top (str1 str2)
657   (let* ((len1 (length str1))
658          (len2 (length str2))
659          (len (min len1 len2))
660          (p 0)
661          c1 c2)
662     (while (and (< p len)
663                 (progn
664                   (setq c1 (aref str1 p)
665                         c2 (aref str2 p))
666                   (eq c1 c2)))
667       (setq p (+ p (char-length c1))))
668     (and (> p 0)
669          (let ((matched (substring str1 0 p))
670                (r1 (and (< p len1)(substring str1 p)))
671                (r2 (and (< p len2)(substring str2 p))))
672            (if (eq r1 r2)
673                matched
674              (list 'seq matched (list 'or r1 r2)))))))
675
676
677 ;;; @ obsoletes
678 ;;;
679
680 ;; This part will be abolished in the future.
681
682 (static-unless (fboundp 'defvaralias)
683   (mapcar
684    (function
685     (lambda (elem)
686       (eval (list 'defvar (car elem) (cadr elem)))))
687    mu-cite-obsolete-variable-alist))
688
689
690 ;;; @ end
691 ;;;
692
693 (provide 'mu-cite)
694
695 (run-hooks 'mu-cite-load-hook)
696
697 ;;; mu-cite.el ends here