X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mu-cite.el;h=19334edb7ae95865d1a6568bf8f38fc5e8cd477c;hb=2b3e2eaf50824264fed1299a55ee05f17d1841ef;hp=1cf1d494623de760e55ee2ea9a55a2887293f381;hpb=b0f03f9bcf423f91fdc4f911c65157f7dd7c1a32;p=elisp%2Fmu-cite.git diff --git a/mu-cite.el b/mu-cite.el index 1cf1d49..19334ed 100644 --- a/mu-cite.el +++ b/mu-cite.el @@ -1,12 +1,10 @@ ;;; mu-cite.el --- yet another citation tool for GNU Emacs -;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. +;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. -;; Author: MORIOKA Tomohiko -;; MINOURA Makoto -;; Shuhei KOBAYASHI -;; Maintainer: Shuhei KOBAYASHI -;; Version: $Revision: 7.47 $ +;; Author: MORIOKA Tomohiko +;; Shuhei KOBAYASHI +;; Maintainer: Katsumi Yamaoka ;; Keywords: mail, news, citation ;; This file is part of MU (Message Utilities). @@ -32,393 +30,424 @@ ;; 1. bytecompile this file and copy it to the apropriate directory. ;; 2. put the following lines to your ~/.emacs: ;; for EMACS 19 or later and XEmacs -;; (autoload 'mu-cite/cite-original "mu-cite" nil t) +;; (autoload 'mu-cite-original "mu-cite" nil t) ;; ;; for all but message-mode -;; (add-hook 'mail-citation-hook 'mu-cite/cite-original) +;; (add-hook 'mail-citation-hook (function mu-cite-original)) ;; ;; for message-mode only -;; (setq message-cite-function (function mu-cite/cite-original)) +;; (setq message-cite-function (function mu-cite-original)) ;; for EMACS 18 ;; ;; for all but mh-e -;; (add-hook 'mail-yank-hooks (function mu-cite/cite-original)) +;; (add-hook 'mail-yank-hooks (function mu-cite-original)) ;; ;; for mh-e only -;; (add-hook 'mh-yank-hooks (function mu-cite/cite-original)) +;; (add-hook 'mh-yank-hooks (function mu-cite-original)) ;;; Code: -(require 'std11) -(require 'tl-str) -(require 'tl-list) - - -;;; @ version -;;; - -(defconst mu-cite/RCS-ID - "$Id: mu-cite.el,v 7.47 1997/02/01 18:29:43 morioka Exp $") -(defconst mu-cite/version (get-version-string mu-cite/RCS-ID)) - - -;;; @ formats -;;; - -(defvar mu-cite/cited-prefix-regexp "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)" - "*Regexp to match the citation prefix. -If match, mu-cite doesn't insert citation prefix.") - -(defvar mu-cite/prefix-format '(prefix-register-verbose "> ") - "*List to represent citation prefix. -Each elements must be string or method name.") - -(defvar mu-cite/top-format '(in-id - ">>>>> " from " wrote:\n") - "*List to represent top string of citation. -Each elements must be string or method name.") - - -;;; @ hooks -;;; - -(defvar mu-cite-load-hook nil - "*List of functions called after mu-cite is loaded. -Use this hook to add your own methods to `mu-cite/default-methods-alist'.") +;; Pickup some macros, e.g. `with-temp-buffer', for old Emacsen. +(require 'poe) -(defvar mu-cite/instantiation-hook nil - "*List of functions called just before narrowing to the message.") +(require 'pcustom) +(require 'widget) +(require 'std11) +(require 'alist) -(defvar mu-cite/pre-cite-hook nil - "*List of functions called before citing a region of text.") +(autoload 'mu-cite-get-prefix-method "mu-register") +(autoload 'mu-cite-get-prefix-register-method "mu-register") +(autoload 'mu-cite-get-prefix-register-verbose-method "mu-register") -(defvar mu-cite/post-cite-hook nil - "*List of functions called after citing a region of text.") +(autoload 'mu-bbdb-get-prefix-method "mu-bbdb") +(autoload 'mu-bbdb-get-prefix-register-method "mu-bbdb") +(autoload 'mu-bbdb-get-prefix-register-verbose-method "mu-bbdb") -;;; @ field +;;; @ version ;;; -(defvar mu-cite/get-field-value-method-alist - (list (cons 'mh-letter-mode - (function - (lambda (name) - (if (and (stringp mh-sent-from-folder) - (numberp mh-sent-from-msg)) - (save-excursion - (set-buffer mh-sent-from-folder) - (set-buffer mh-show-buffer) - (and (boundp 'mime::preview/article-buffer) - (bufferp mime::preview/article-buffer) - (set-buffer mime::preview/article-buffer)) - (std11-field-body name) - )) - ))))) - -(defun mu-cite/get-field-value (name) - (or (std11-field-body name) - (let ((method (assq major-mode mu-cite/get-field-value-method-alist))) - (if method - (funcall (cdr method) name) - )))) +(defconst mu-cite-version "8.0") -;;; @ prefix registration +;;; @ obsoletes ;;; -(defvar mu-cite/registration-file - (expand-file-name "~/.mu-cite.el") - "*The name of the user environment file for mu-cite.") - -(defvar mu-cite/allow-null-string-registration nil - "*If non-nil, null-string citation-name is registered.") - -(defvar mu-cite/registration-symbol 'mu-cite/citation-name-alist) - -(defvar mu-cite/citation-name-alist nil) -(load mu-cite/registration-file t t t) -(or (eq 'mu-cite/citation-name-alist mu-cite/registration-symbol) - (setq mu-cite/citation-name-alist - (symbol-value mu-cite/registration-symbol)) - ) -(defvar mu-cite/minibuffer-history nil) - -;; get citation-name from the database -(defun mu-cite/get-citation-name (from) - (assoc-value from mu-cite/citation-name-alist) - ) - -;; register citation-name to the database -(defun mu-cite/add-citation-name (name from) - (setq mu-cite/citation-name-alist - (put-alist from name mu-cite/citation-name-alist)) - (mu-cite/save-to-file) - ) - -;; save to file -(defun mu-cite/save-to-file () - (let* ((filename mu-cite/registration-file) - (buffer (get-buffer-create " *mu-register*"))) - (save-excursion - (set-buffer buffer) - (setq buffer-file-name filename) - (erase-buffer) - (insert - (format ";;; %s\n" (file-name-nondirectory filename))) - (insert - (format ";;; This file is generated automatically by mu-cite %s.\n\n" - mu-cite/version)) - (insert (format "(setq %s\n '(" mu-cite/registration-symbol)) - (insert (mapconcat - (function prin1-to-string) - mu-cite/citation-name-alist "\n ")) - (insert "\n ))\n\n") - (insert - (format ";;; %s ends here.\n" (file-name-nondirectory filename))) - (save-buffer)) - (kill-buffer buffer))) - - -;;; @ item methods +;; This part will be abolished in the future. + +(eval-when-compile + (require 'static) + (defmacro mu-cite-obsolete-variable-alist () + ''((mu-cite/cited-prefix-regexp mu-cite-cited-prefix-regexp) + (mu-cite/default-methods-alist mu-cite-default-methods-alist) + (mu-cite/get-field-value-method-alist + mu-cite-get-field-value-method-alist) + (mu-cite/instantiation-hook mu-cite-instantiation-hook) + (mu-cite/ml-count-field-list mu-cite-ml-count-field-list) + (mu-cite/post-cite-hook mu-cite-post-cite-hook) + (mu-cite/pre-cite-hook mu-cite-pre-cite-hook) + (mu-cite/prefix-format mu-cite-prefix-format) + (mu-cite/top-format mu-cite-top-format)))) + +(static-if (featurep 'xemacs) + (dolist (def (mu-cite-obsolete-variable-alist)) + (apply (function define-obsolete-variable-alias) def))) + +(define-obsolete-function-alias + (function mu-cite/cite-original) (function mu-cite-original)) +(define-obsolete-function-alias + (function mu-cite/get-field-value) (function mu-cite-get-field-value)) +(define-obsolete-function-alias + (function mu-cite/get-value) (function mu-cite-get-value)) + + +;;; @ macro ;;; -;;; @@ ML count -;;; +(defmacro mu-cite-remove-text-properties (string) + "Remove text properties from STRING which is read from minibuffer." + (if (or (featurep 'xemacs) + (boundp 'minibuffer-allow-text-properties);; Emacs 20.1 or later. + (not (fboundp 'set-text-properties)));; under Emacs 19.7. + string + (` (let ((obj (copy-sequence (, string)))) + (set-text-properties 0 (length obj) nil obj) + obj)))) -(defvar mu-cite/ml-count-field-list - '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id") - "*List of header fields which contain sequence number of mailing list.") -(defun mu-cite/get-ml-count-method () - (let ((field-list mu-cite/ml-count-field-list)) - (catch 'tag - (while field-list - (let* ((field (car field-list)) - (ml-count (mu-cite/get-field-value field))) - (if (and ml-count (string-match "[0-9]+" ml-count)) - (throw 'tag - (substring ml-count - (match-beginning 0)(match-end 0)) - )) - (setq field-list (cdr field-list)) - ))))) - - -;;; @@ prefix and registration +;;; @ set up ;;; -(defun mu-cite/get-prefix-method () - (or (mu-cite/get-citation-name (mu-cite/get-value 'address)) - ">") - ) - -(defun mu-cite/get-prefix-register-method () - (let ((addr (mu-cite/get-value 'address))) - (or (mu-cite/get-citation-name addr) - (let ((return - (read-string "Citation name? " - (or (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history) - )) - (if (and (or mu-cite/allow-null-string-registration - (not (string-equal return ""))) - (y-or-n-p (format "Register \"%s\"? " return))) - (mu-cite/add-citation-name return addr) - ) - return)))) - -(defun mu-cite/get-prefix-register-verbose-method () - (let* ((addr (mu-cite/get-value 'address)) - (return1 (mu-cite/get-citation-name addr)) - (return (read-string "Citation name? " - (or return1 - (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history)) - ) - (if (and (or mu-cite/allow-null-string-registration - (not (string-equal return ""))) - (not (string-equal return return1)) - (y-or-n-p (format "Register \"%s\"? " return)) - ) - (mu-cite/add-citation-name return addr) - ) - return)) - - -;;; @@ set up -;;; +(defgroup mu-cite nil + "yet another citation tool for GNU Emacs." + :prefix "mu-cite-" + :group 'mail + :group 'news) -(defvar mu-cite/default-methods-alist +(defvar mu-cite-default-methods-alist (list (cons 'from (function (lambda () - (mu-cite/get-field-value "From") - ))) + (mu-cite-get-field-value "From")))) (cons 'date (function (lambda () - (mu-cite/get-field-value "Date") - ))) + (mu-cite-get-field-value "Date")))) (cons 'message-id (function (lambda () - (mu-cite/get-field-value "Message-Id") - ))) + (mu-cite-get-field-value "Message-Id")))) (cons 'subject (function (lambda () - (mu-cite/get-field-value "Subject") - ))) + (mu-cite-get-field-value "Subject")))) (cons 'ml-name (function (lambda () - (mu-cite/get-field-value "X-Ml-Name") - ))) - (cons 'ml-count (function mu-cite/get-ml-count-method)) + (mu-cite-get-field-value "X-Ml-Name")))) + (cons 'ml-count (function mu-cite-get-ml-count-method)) (cons 'address-structure (function (lambda () (car - (std11-parse-address-string (mu-cite/get-value 'from)) - )))) + (std11-parse-address-string (mu-cite-get-value 'from)))))) (cons 'full-name (function (lambda () (std11-full-name-string - (mu-cite/get-value 'address-structure)) - ))) + (mu-cite-get-value 'address-structure))))) (cons 'address (function (lambda () (std11-address-string - (mu-cite/get-value 'address-structure)) - ))) + (mu-cite-get-value 'address-structure))))) (cons 'id (function (lambda () - (let ((ml-name (mu-cite/get-value 'ml-name))) + (let ((ml-name (mu-cite-get-value 'ml-name))) (if ml-name (concat "[" ml-name " : No." - (mu-cite/get-value 'ml-count) + (mu-cite-get-value 'ml-count) "]") - (mu-cite/get-value 'message-id) - ))))) + (mu-cite-get-value 'message-id)))))) (cons 'in-id (function (lambda () - (let ((id (mu-cite/get-value 'id))) + (let ((id (mu-cite-get-value 'id))) (if id (format ">>>>> In %s \n" id) ""))))) - (cons 'prefix (function mu-cite/get-prefix-method)) - (cons 'prefix-register - (function mu-cite/get-prefix-register-method)) - (cons 'prefix-register-verbose - (function mu-cite/get-prefix-register-verbose-method)) (cons 'x-attribution (function (lambda () - (mu-cite/get-field-value "X-Attribution") - ))) + (mu-cite-get-field-value "X-Attribution")))) + ;; mu-register + (cons 'prefix (function mu-cite-get-prefix-method)) + (cons 'prefix-register + (function mu-cite-get-prefix-register-method)) + (cons 'prefix-register-verbose + (function mu-cite-get-prefix-register-verbose-method)) + ;; mu-bbdb + (cons 'bbdb-prefix + (function mu-bbdb-get-prefix-method)) + (cons 'bbdb-prefix-register + (function mu-bbdb-get-prefix-register-method)) + (cons 'bbdb-prefix-register-verbose + (function mu-bbdb-get-prefix-register-verbose-method)) )) +;;; @ formats +;;; + +(defcustom mu-cite-cited-prefix-regexp + "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)" + "Regexp to match the citation prefix. +If match, mu-cite doesn't insert citation prefix." + :type 'regexp + :group 'mu-cite) + +(defcustom mu-cite-prefix-format '(prefix-register-verbose "> ") + "List to represent citation prefix. +Each elements must be string or method name." + :type (list + 'repeat + (list + 'group + :convert-widget + (function + (lambda (widget) + (list + 'choice + :tag "Method or String" + :args + (nconc + (mapcar + (function (lambda (elem) (list 'choice-item (car elem)))) + mu-cite-default-methods-alist) + '((symbol :tag "Method") + (const :tag "-" nil) + (choice-item :tag "String: \"> \"" "> ") + (string)))))))) + :set (function (lambda (symbol value) + (set-default symbol (delq nil value)))) + :group 'mu-cite) + +(defcustom mu-cite-top-format '(in-id ">>>>>\t" from " wrote:\n") + "List to represent top string of citation. +Each elements must be string or method name." + :type (list + 'repeat + (list + 'group + :convert-widget + (function + (lambda (widget) + (list 'choice + :tag "Method or String" + :args + (nconc + (mapcar + (function (lambda (elem) (list 'choice-item (car elem)))) + mu-cite-default-methods-alist) + '((symbol :tag "Method") + (const :tag "-" nil) + (choice-item :tag "String: \">>>>>\\t\"" ">>>>>\t") + (choice-item :tag "String: \" wrote:\\n\"" " wrote:\n") + (string :tag "String")))))))) + :set (function (lambda (symbol value) + (set-default symbol (delq nil value)))) + :group 'mu-cite) + + +;;; @ hooks +;;; + +(defcustom mu-cite-instantiation-hook nil + "List of functions called just before narrowing to the message." + :type 'hook + :group 'mu-cite) + +(defcustom mu-cite-pre-cite-hook nil + "List of functions called before citing a region of text." + :type 'hook + :group 'mu-cite) + +(defcustom mu-cite-post-cite-hook nil + "List of functions called after citing a region of text." + :type 'hook + :group 'mu-cite) + + +;;; @ field +;;; + +(defvar mu-cite-get-field-value-method-alist nil + "Alist major-mode vs. function to get field-body of header.") + +(defun mu-cite-get-field-value (name) + "Return the value of the header field NAME. +If the field is not found in the header, a method function which is +registered in variable `mu-cite-get-field-value-method-alist' is called." + (or (std11-field-body name) + (let ((method (assq major-mode mu-cite-get-field-value-method-alist))) + (if method + (funcall (cdr method) name))))) + + +;;; @ item methods +;;; + +;;; @@ ML count +;;; + +(defcustom mu-cite-ml-count-field-list + '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id") + "List of header fields which contain sequence number of mailing list." + :type '(repeat (choice :tag "Field Name" + (choice-item "X-Ml-Count") + (choice-item "X-Mail-Count") + (choice-item "X-Seqno") + (choice-item "X-Sequence") + (choice-item "Mailinglist-Id") + (const :tag "-" nil) + (string :tag "Other"))) + :set (function (lambda (symbol value) + (set-default symbol (delq nil value)))) + :group 'mu-cite) + +(defun mu-cite-get-ml-count-method () + "A mu-cite method to return a ML-count. +This function searches a field about ML-count, which is specified by +variable `mu-cite-ml-count-field-list', in a header. +If the field is found, the function returns a number part of the +field. + +Notice that please use (mu-cite-get-value 'ml-count) +instead of call the function directly." + (let ((field-list mu-cite-ml-count-field-list)) + (catch 'tag + (while field-list + (let* ((field (car field-list)) + (ml-count (mu-cite-get-field-value field))) + (if (and ml-count (string-match "[0-9]+" ml-count)) + (throw 'tag (match-string 0 ml-count))) + (setq field-list (cdr field-list))))))) + + ;;; @ fundamentals ;;; -(defvar mu-cite/methods-alist nil) +(defvar mu-cite-methods-alist nil) -(defun mu-cite/make-methods () - (setq mu-cite/methods-alist - (copy-alist mu-cite/default-methods-alist)) - (run-hooks 'mu-cite/instantiation-hook) - ) +(defun mu-cite-make-methods () + (setq mu-cite-methods-alist + (copy-alist mu-cite-default-methods-alist)) + (run-hooks 'mu-cite-instantiation-hook)) -(defun mu-cite/get-value (item) - (let ((ret (assoc-value item mu-cite/methods-alist))) +(defun mu-cite-get-value (item) + "Return current value of ITEM." + (let ((ret (cdr (assoc item mu-cite-methods-alist)))) (if (functionp ret) (prog1 - (setq ret (funcall ret)) - (set-alist 'mu-cite/methods-alist item ret) - ) + (setq ret (save-excursion (funcall ret))) + (set-alist 'mu-cite-methods-alist item ret)) ret))) -(defun mu-cite/eval-format (list) +(defun mu-cite-eval-format (list) (mapconcat (function (lambda (elt) (cond ((stringp elt) elt) - ((symbolp elt) (mu-cite/get-value elt)) - ))) - list "") - ) + ((symbolp elt) (mu-cite-get-value elt))))) + list "")) ;;; @ main function ;;; -(defun mu-cite/cite-original () +;;;###autoload +(defun mu-cite-original () "Citing filter function. This is callable from the various mail and news readers' reply function according to the agreed upon standard." (interactive) - (mu-cite/make-methods) + (mu-cite-make-methods) (save-restriction (if (< (mark t) (point)) (exchange-point-and-mark)) (narrow-to-region (point)(point-max)) - (run-hooks 'mu-cite/pre-cite-hook) + (run-hooks 'mu-cite-pre-cite-hook) (let ((last-point (point)) - (top (mu-cite/eval-format mu-cite/top-format)) - (prefix (mu-cite/eval-format mu-cite/prefix-format)) - ) + (top (mu-cite-eval-format mu-cite-top-format)) + (prefix (mu-cite-eval-format mu-cite-prefix-format))) (if (re-search-forward "^-*$" nil nil) - (forward-line 1) - ) + (forward-line 1)) (widen) (delete-region last-point (point)) (insert top) (setq last-point (point)) (while (< (point)(mark t)) - (or (looking-at mu-cite/cited-prefix-regexp) + (or (looking-at mu-cite-cited-prefix-regexp) (insert prefix)) (forward-line 1)) - (goto-char last-point) - ) - (run-hooks 'mu-cite/post-cite-hook) - )) + (goto-char last-point)) + (run-hooks 'mu-cite-post-cite-hook))) ;;; @ message editing utilities ;;; -(defvar citation-mark-chars ">}|" - "*String of characters for citation delimiter. [mu-cite.el]") - -(defvar citation-disable-chars "<{" - "*String of characters not allowed as citation-prefix.") +(defcustom citation-mark-chars ">}|" + "String of characters for citation delimiter." + :type 'string + :group 'mu-cite) + +(defcustom citation-disable-chars "<{" + "String of characters not allowed as citation-prefix." + :type 'string + :group 'mu-cite) + +(defun-maybe-cond char-category (character) + "Return string of category mnemonics for CHAR in TABLE. +CHAR can be any multilingual character +TABLE defaults to the current buffer's category table." + ((and (subr-fboundp 'char-category-set) + (subr-fboundp 'category-set-mnemonics)) + (category-set-mnemonics (char-category-set character)) + ) + ((fboundp 'char-category-list) + (mapconcat (lambda (chr) + (char-to-string (int-char chr))) + (char-category-list character) + "") + ) + ((boundp 'NEMACS) + (if (< (char-int character) 128) + "al" + "j") + ) + (t + (if (< (char-int character) 128) + "al" + "l") + )) (defun detect-paragraph-cited-prefix () (save-excursion (goto-char (point-min)) (let ((i 0) (prefix - (buffer-substring - (progn (beginning-of-line)(point)) - (progn (end-of-line)(point)) - )) + (buffer-substring (line-beginning-position) + (line-end-position))) str ret) (while (and (= (forward-line) 0) (setq str (buffer-substring (progn (beginning-of-line)(point)) (progn (end-of-line)(point)))) - (setq ret (string-compare-from-top prefix str)) - ) + (setq ret (string-compare-from-top prefix str))) (setq prefix (if (stringp ret) ret - (second ret))) - (setq i (1+ i)) - ) + (cadr ret))) + (setq i (1+ i))) (cond ((> i 1) prefix) ((> i 0) (goto-char (point-min)) @@ -431,60 +460,50 @@ function according to the agreed upon standard." (progn (goto-char (match-end 0)) (if (looking-at "[ \t]+") - (goto-char (match-end 0)) - ) - (buffer-substring (point-min)(point)) - ) + (goto-char (match-end 0))) + (buffer-substring (point-min)(point))) prefix))) ((progn (goto-char (point-max)) (re-search-backward (concat "[" citation-disable-chars "]") nil t) (re-search-backward - (concat "[" citation-mark-chars "]") nil t) - ) + (concat "[" citation-mark-chars "]") nil t)) (goto-char (match-end 0)) (if (looking-at "[ \t]+") - (goto-char (match-end 0)) - ) - (buffer-substring (point-min)(point)) - ) - (t "")) - ))) + (goto-char (match-end 0))) + (buffer-substring (point-min)(point))) + (t ""))))) +;;;###autoload (defun fill-cited-region (beg end) + "Fill each of the paragraphs in the region as a cited text." (interactive "*r") (save-excursion (save-restriction (goto-char end) (and (search-backward "\n" nil t) - (setq end (match-end 0)) - ) + (setq end (match-end 0))) (narrow-to-region beg end) (let* ((fill-prefix (detect-paragraph-cited-prefix)) - (pat (concat fill-prefix "\n")) - ) + (pat (concat fill-prefix "\n"))) (goto-char (point-min)) (while (search-forward pat nil t) (let ((b (match-beginning 0)) - (e (match-end 0)) - ) + (e (match-end 0))) (delete-region b e) (if (and (> b (point-min)) (let ((cat (char-category (char-before b)))) (or (string-match "a" cat) - (string-match "l" cat) - )) - ) - (insert " ") - )) - ) + (string-match "l" cat)))) + (insert " ")))) (goto-char (point-min)) - (fill-region (point-min) (point-max)) - )))) + (fill-region (point-min) (point-max)))))) +;;;###autoload (defun compress-cited-prefix () + "Compress nested cited prefixes." (interactive) (save-excursion (goto-char (point-min)) @@ -499,29 +518,48 @@ function according to the agreed upon standard." ps pe (s 0) (nest (let ((i 0)) (if (string-match "<[^<>]+>" prefix) - (setq prefix (substring prefix 0 (match-beginning 0))) - ) + (setq prefix + (substring prefix 0 (match-beginning 0)))) (while (string-match (concat "\\([" citation-mark-chars "]+\\)[ \t]*") prefix s) (setq i (+ i (- (match-end 1)(match-beginning 1))) ps s pe (match-beginning 1) - s (match-end 0) - )) + s (match-end 0))) i))) (if (and ps (< ps pe)) (progn (delete-region b e) - (insert (concat (substring prefix ps pe) (make-string nest ?>))) - )))))) + (insert (concat (substring prefix ps pe) + (make-string nest ?>))))) + )))) (defun replace-top-string (old new) (interactive "*sOld string: \nsNew string: ") (while (re-search-forward - (concat "^" (regexp-quote old)) nil t) - (replace-match new) - )) + (concat "^" (regexp-quote old)) nil t) + (replace-match new))) + +(defun string-compare-from-top (str1 str2) + (let* ((len1 (length str1)) + (len2 (length str2)) + (len (min len1 len2)) + (p 0) + c1 c2) + (while (and (< p len) + (progn + (setq c1 (sref str1 p) + c2 (sref str2 p)) + (eq c1 c2))) + (setq p (char-next-index c1 p))) + (and (> p 0) + (let ((matched (substring str1 0 p)) + (r1 (and (< p len1)(substring str1 p))) + (r2 (and (< p len2)(substring str2 p)))) + (if (eq r1 r2) + matched + (list 'seq matched (list 'or r1 r2))))))) ;;; @ end @@ -531,4 +569,23 @@ function according to the agreed upon standard." (run-hooks 'mu-cite-load-hook) +;; This part will be abolished in the future. + +(static-unless (featurep 'xemacs) + (let ((rest (mu-cite-obsolete-variable-alist)) + def new-sym old-sym) + (while rest + (setq def (car rest)) + (apply (function make-obsolete-variable) def) + (setq old-sym (car def) + new-sym (car (cdr def))) + (or (get new-sym 'saved-value) ; saved? + (not (eq (eval (car (get new-sym 'standard-value))) + (symbol-value new-sym))) ; set as new name? + (and (boundp old-sym) ; old name seems used + (or (eq (symbol-value new-sym) + (symbol-value old-sym)) + (set new-sym (symbol-value old-sym))))) + (setq rest (cdr rest))))) + ;;; mu-cite.el ends here