From: teranisi Date: Sun, 24 Nov 2002 13:11:59 +0000 (+0000) Subject: * utf7.el (toplevel): Check the ucs features dynamically. X-Git-Tag: wl-2_10_0pre3~5 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72d0f27be8eefc947eac107d34c370d6add2afe1;p=elisp%2Fwanderlust.git * utf7.el (toplevel): Check the ucs features dynamically. (Advice from Yoichi NAKAYAMA ) --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index b48a16c..b0c3da4 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2002-11-24 Yuuichi Teranishi + + * utf7.el (toplevel): Check the ucs features dynamically. + (Advice from Yoichi NAKAYAMA ) + 2002-11-21 Yuuichi Teranishi * elmo-nntp.el (elmo-nntp-search-primitive): Revert the last change. diff --git a/elmo/utf7.el b/elmo/utf7.el index 81e66ee..31702d7 100644 --- a/elmo/utf7.el +++ b/elmo/utf7.el @@ -86,9 +86,48 @@ "Return required length of padding for IMAP modified base64 fragment." (mod (- len) modulus)) -(static-cond +(cond + ((or (find-coding-system 'utf-7) + (module-installed-p 'un-define)) + (defun utf7-fragment-decode (start end &optional imap) + "Decode base64 encoded fragment from START to END of UTF-7 text in buffer. +Use IMAP modification if IMAP is non-nil." + (require 'un-define) + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (insert "+") + (when imap + (goto-char start) + (while (search-forward "," nil 'move-to-end) (replace-match "/"))) + (decode-coding-region (point-min) (point-max) 'utf-7))) + + (defun utf7-fragment-encode (start end &optional imap) + "Encode text from START to END in buffer as UTF-7 escape fragment. +Use IMAP modification if IMAP is non-nil." + (require 'un-define) + (let ((buffer (current-buffer)) + encoded-string) + (setq encoded-string + (with-temp-buffer + (insert-buffer-substring buffer start end) + (encode-coding-region (point-min) + (point-max) 'utf-7) + (goto-char (point-min)) + (when imap + (skip-chars-forward "+") + (delete-region (point-min) (point)) + (insert "&") + (while (search-forward "/" nil t) + (replace-match ","))) + (skip-chars-forward "^= \t\n" (point-max)) + (delete-region (point) (point-max)) + (buffer-string))) + (delete-region start end) + (insert encoded-string)))) ((and (featurep 'xemacs) - (module-installed-p 'xemacs-ucs)) + (or (find-coding-system 'utf-8) + (module-installed-p 'xemacs-ucs))) (defun utf7-fragment-decode (start end &optional imap) "Decode base64 encoded fragment from START to END of UTF-7 text in buffer. Use IMAP modification if IMAP is non-nil." @@ -105,7 +144,7 @@ Use IMAP modification if IMAP is non-nil." utf7-utf7-to-utf8-program t (current-buffer))) (decode-coding-region (point-min) (point-max) 'utf-8))) - + (defun utf7-fragment-encode (start end &optional imap) "Decode base64 encoded fragment from START to END of UTF-7 text in buffer. Use IMAP modification if IMAP is non-nil." @@ -136,54 +175,17 @@ Use IMAP modification if IMAP is non-nil." (buffer-string))) (delete-region start end) (insert encoded-string)))) - ((module-installed-p 'un-define) ;; Emacs - (defun utf7-fragment-decode (start end &optional imap) - "Decode base64 encoded fragment from START to END of UTF-7 text in buffer. -Use IMAP modification if IMAP is non-nil." - (require 'un-define) - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (insert "+") - (when imap - (goto-char start) - (while (search-forward "," nil 'move-to-end) (replace-match "/"))) - (decode-coding-region (point-min) (point-max) 'utf-7) - )) - - (defun utf7-fragment-encode (start end &optional imap) - "Encode text from START to END in buffer as UTF-7 escape fragment. -Use IMAP modification if IMAP is non-nil." - (require 'un-define) - (let ((buffer (current-buffer)) - encoded-string) - (setq encoded-string - (with-temp-buffer - (insert-buffer-substring buffer start end) - (encode-coding-region (point-min) - (point-max) 'utf-7) - (goto-char (point-min)) - (when imap - (skip-chars-forward "+") - (delete-region (point-min) (point)) - (insert "&") - (while (search-forward "/" nil t) - (replace-match ","))) - (skip-chars-forward "^= \t\n" (point-max)) - (delete-region (point) (point-max)) - (buffer-string))) - (delete-region start end) - (insert encoded-string)))) (t - ;; Define as null function. (defun utf7-fragment-decode (start end &optional imap) "Encode text from START to END in buffer as UTF-7 escape fragment. Use IMAP modification if IMAP is non-nil." + ;; Define as a null function. ) (defun utf7-fragment-encode (start end &optional imap) "Encode text from START to END in buffer as UTF-7 escape fragment. Use IMAP modification if IMAP is non-nil." + ;; Define as a null function. ))) (defun utf7-encode-region (start end &optional imap)