X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mu-cite.el;h=19334edb7ae95865d1a6568bf8f38fc5e8cd477c;hb=5f66538717d0ff9602b345613953b5efe3d07501;hp=6c2e2e59b8597c1888accaf033101254d1ffa172;hpb=d4602ae46d75d217e916c582e8ad5c68cec4fc49;p=elisp%2Fmu-cite.git diff --git a/mu-cite.el b/mu-cite.el index 6c2e2e5..19334ed 100644 --- a/mu-cite.el +++ b/mu-cite.el @@ -71,28 +71,44 @@ ;; This part will be abolished in the future. -(eval-when-compile (require 'static)) - -(defconst 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))) +(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) + (dolist (def (mu-cite-obsolete-variable-alist)) (apply (function define-obsolete-variable-alias) def))) -(dolist (def '((mu-cite/cite-original mu-cite-original) - (mu-cite/get-field-value mu-cite-get-field-value) - (mu-cite/get-value mu-cite-get-value))) - (apply (function define-obsolete-function-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 +;;; + +(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)))) ;;; @ set up @@ -182,42 +198,6 @@ ;;; @ formats ;;; -(define-widget 'mu-cite-choose-prefix-format 'group - "Widget for entering a prefix citation method." - :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))))))) - -(define-widget 'mu-cite-choose-top-format 'group - "Widget for entering a top citation method." - :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"))))))) - -(defun mu-cite-custom-set-variable (symbol value) - (set-default symbol (delq nil value))) - (defcustom mu-cite-cited-prefix-regexp "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)" "Regexp to match the citation prefix. @@ -228,15 +208,53 @@ If match, mu-cite doesn't insert citation prefix." (defcustom mu-cite-prefix-format '(prefix-register-verbose "> ") "List to represent citation prefix. Each elements must be string or method name." - :type '(repeat mu-cite-choose-prefix-format) - :set (function mu-cite-custom-set-variable) + :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 '(repeat mu-cite-choose-top-format) - :set (function mu-cite-custom-set-variable) + :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) @@ -292,7 +310,8 @@ registered in variable `mu-cite-get-field-value-method-alist' is called." (choice-item "Mailinglist-Id") (const :tag "-" nil) (string :tag "Other"))) - :set (function mu-cite-custom-set-variable) + :set (function (lambda (symbol value) + (set-default symbol (delq nil value)))) :group 'mu-cite) (defun mu-cite-get-ml-count-method () @@ -509,9 +528,11 @@ TABLE defaults to the current buffer's category table." pe (match-beginning 1) s (match-end 0))) i))) - (when (and ps (< ps pe)) - (delete-region b e) - (insert (concat (substring prefix ps pe) (make-string nest ?>)))) + (if (and ps (< ps pe)) + (progn + (delete-region b e) + (insert (concat (substring prefix ps pe) + (make-string nest ?>))))) )))) (defun replace-top-string (old new) @@ -551,7 +572,7 @@ TABLE defaults to the current buffer's category table." ;; This part will be abolished in the future. (static-unless (featurep 'xemacs) - (let ((rest mu-cite-obsolete-variable-alist) + (let ((rest (mu-cite-obsolete-variable-alist)) def new-sym old-sym) (while rest (setq def (car rest))