;;; mu-cite.el --- yet another citation tool for GNU Emacs
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007
;; Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
-;; We have need to pickup the function `char-category' for XEmacs which
-;; is defined in `emu'. It requires `poem' recursively for picking up
-;; the macros `char-next-index', `with-temp-buffer', etc.
-(require 'emu)
+;; For picking up the macros `char-next-index', `with-temp-buffer', etc.
+(require 'poem)
(require 'pcustom)
(require 'std11)
(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))))
+ (cond ((featurep 'xemacs)
+ `(let ((string (copy-sequence ,string)))
+ (map-extents (function (lambda (extent maparg)
+ (delete-extent extent)))
+ string 0 (length string))
+ string))
+ ((or (boundp 'minibuffer-allow-text-properties);; Emacs 20.1 or later.
+ (not (fboundp 'set-text-properties)));; under Emacs 19.7.
+ string)
+ (t
+ `(let ((string (copy-sequence ,string)))
+ (set-text-properties 0 (length string) nil string)
+ string))))
;;; @ set up
(function
(lambda ()
(mu-cite-get-field-value "X-Attribution"))))
+ (cons 'x-cite-me
+ (function
+ (lambda ()
+ (mu-cite-get-field-value "X-Cite-Me"))))
;; mu-register
(cons 'prefix (function mu-cite-get-prefix-method))
(cons 'prefix-register
(insert top)
(setq last-point (point))
(while (< (point)(mark t))
- (or (looking-at mu-cite-cited-prefix-regexp)
+ (or (and mu-cite-cited-prefix-regexp
+ (looking-at mu-cite-cited-prefix-regexp))
(insert prefix))
(forward-line 1))
(goto-char last-point))
:type 'string
:group 'mu-cite)
-(defun-maybe-cond char-category (character)
- "Return a 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")
- ))
+(eval-and-compile
+ ;; Don't use the function `char-category' which may have been
+ ;; defined by emu.el. Anyway, the best way is not to use emu.el.
+ (if (and (fboundp 'char-category)
+ (subrp (symbol-function 'char-category)))
+ (defalias 'mu-cite-char-category 'char-category)
+ (defun-maybe-cond mu-cite-char-category (character &optional table)
+ "Return a string of category mnemonics for CHARACTER in TABLE.
+CHARACTER can be any multilingual characters,
+TABLE defaults to the current buffer's category table (it is currently
+ignored)."
+ ((and (subr-fboundp 'char-category-set)
+ (subr-fboundp 'category-set-mnemonics))
+ (category-set-mnemonics (char-category-set character)))
+ ((and (fboundp 'char-category-list)
+ ;; `char-category-list' returns a list of characters
+ ;; in XEmacs 21.2.25 and later, otherwise integers.
+ (characterp (car-safe (char-category-list ?a))))
+ (concat (char-category-list 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
(buffer-substring (line-beginning-position)(point)))
(t "")))))
+(defcustom fill-column-for-fill-cited-region nil
+ "Integer to override `fill-column' while `fill-cited-region' is being
+executed. If you wish people call you ****-san, you may set the value
+of `fill-column' to 60 in the buffer for message sending and set this
+to 70. :-)"
+ :type `(choice (const :tag "Off" nil)
+ (integer ,default-fill-column))
+ :group 'mu-cite)
+
;;;###autoload
(defun fill-cited-region (beg end)
"Fill each of the paragraphs in the region as a cited text."
(let* ((fill-prefix (detect-paragraph-cited-prefix))
(fill-column (max (+ 1 (current-left-margin)
(string-width fill-prefix))
- (current-fill-column)))
+ (or fill-column-for-fill-cited-region
+ (current-fill-column))))
(pat (concat fill-prefix "\n"))
filladapt-mode)
(goto-char (point-min))
(e (match-end 0)))
(delete-region b e)
(if (and (> b (point-min))
- (let ((cat (char-category
- (char-before b))))
+ (let ((cat (mu-cite-char-category (char-before b))))
(or (string-match "a" cat)
(string-match "l" cat))))
(insert " "))))