Gnus development mailing list
 help / color / mirror / Atom feed
* imap.el: international/utf-7.el vs. gnus/utf7.el (was: 23.0.50; utf7-decode failed with non latin-1 charactor)
       [not found]   ` <E1IovyW-0001nS-4a@etlken.m17n.org>
@ 2007-11-06 19:53     ` Reiner Steib
  2007-11-07  0:36       ` Kenichi Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Reiner Steib @ 2007-11-06 19:53 UTC (permalink / raw)
  To: Kenichi Handa, ding, emacs-devel; +Cc: topia, Jason Rumney

On Mon, Nov 05 2007, Kenichi Handa wrote:

> Jason Rumney <jasonr@gnu.org> writes:
>> Probably lisp/international/utf-7.el should be fixed, and the Gnus one
>> dropped.

Please keep in mind the we want to keep the Gnus versions in
Emacs/trunk (Gnus 5.13) and Gnus/trunk (aka No Gnus) in sync.  We want
to keep No Gnus compatible with Emacs 21+ (and XEmacs 21.4+).  So we
need to add some compatibility code.

> I think the right thing is to uncomment all codes for
> utf-7-map in utf-7.el, and modify gnus to use normal
> encode/decode-coding-region/string with utf-7-imap.
>
> I've just committed the former change.  

AFAIKS, `utf-7-encode' also accepts that FROM is a string, but it's
not documented.  Can we rely on this?  Could you document it, please?

> Could someone do the latter change?

A grep through Gnus' sources suggests that it only uses the functions
`utf7-encode' and `utf7-decode' in `imap.el'.

How about the following patch to gnus/utf7.el (untested)?  Could you
suggest a better test instead of `(<= 23 emacs-major-version)'?

Instead of -OLD and -NEW we should use more suitable names or include
the defuns directly.

--8<---------------cut here---------------start------------->8---
--- utf7.el	04 Aug 2007 20:36:34 +0200	1.12
+++ utf7.el	06 Nov 2007 20:42:08 +0100	
@@ -207,7 +207,7 @@
   (mm-decode-coding-region (point-min) (point-max) 'iso-8859-1)
   (mm-enable-multibyte))
 
-(defun utf7-encode (string &optional for-imap)
+(defun utf7-encode-OLD (string &optional for-imap)
   "Encode UTF-7 STRING.  Use IMAP modification if FOR-IMAP is non-nil."
   (let ((default-enable-multibyte-characters t))
     (with-temp-buffer
@@ -215,7 +215,7 @@
       (utf7-encode-internal for-imap)
       (buffer-string))))
 
-(defun utf7-decode (string &optional for-imap)
+(defun utf7-decode-OLD (string &optional for-imap)
   "Decode UTF-7 STRING.  Use IMAP modification if FOR-IMAP is non-nil."
   (let ((default-enable-multibyte-characters nil))
     (with-temp-buffer
@@ -224,6 +224,31 @@
       (mm-enable-multibyte)
       (buffer-string))))
 
+(defun utf7-encode-NEW (string &optional for-imap)
+  (with-temp-buffer
+    ;; (utf-7-encode FROM TO IMAP)
+    ;;
+    ;; `utf-7-encode' also accepts that FROM is a string, but it's not
+    ;; documented.
+    (utf-7-encode string nil for-imap)
+    (buffer-string)))
+
+(defun utf7-decode-NEW (string &optional for-imap)
+  (with-temp-buffer
+    (insert string)
+    (goto-char (point-min))
+    ;; (utf-7-decode LEN IMAP)
+    (utf-7-decode (buffer-size) for-imap)
+    (buffer-string)))
+
+(if (and (require 'utf-7 nil t) ;; Additional test for XEmacs?
+	 (<= 23 emacs-major-version)) ;; A feature test would be better
+    (progn
+      (defalias 'utf7-encode 'utf7-encode-NEW)
+      (defalias 'utf7-decode 'utf7-decode-NEW))
+  (defalias 'utf7-encode 'utf7-encode-OLD)
+  (defalias 'utf7-decode 'utf7-decode-OLD))
+
 (provide 'utf7)
 
 ;;; arch-tag: 96078b55-85c7-4161-aed2-932c24b282c7
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: imap.el: international/utf-7.el vs. gnus/utf7.el (was: 23.0.50; utf7-decode failed with non latin-1 charactor)
  2007-11-06 19:53     ` imap.el: international/utf-7.el vs. gnus/utf7.el (was: 23.0.50; utf7-decode failed with non latin-1 charactor) Reiner Steib
@ 2007-11-07  0:36       ` Kenichi Handa
  2007-11-20 21:08         ` imap.el: international/utf-7.el vs. gnus/utf7.el Reiner Steib
  0 siblings, 1 reply; 3+ messages in thread
From: Kenichi Handa @ 2007-11-07  0:36 UTC (permalink / raw)
  To: Reiner Steib; +Cc: jasonr, topia, ding, emacs-devel

In article <v9prynjgm3.fsf_-_@marauder.physik.uni-ulm.de>, Reiner Steib <reinersteib+gmane@imap.cc> writes:

> > I think the right thing is to uncomment all codes for
> > utf-7-map in utf-7.el, and modify gnus to use normal
> > encode/decode-coding-region/string with utf-7-imap.
> >
> > I've just committed the former change.  

> AFAIKS, `utf-7-encode' also accepts that FROM is a string, but it's
> not documented.  Can we rely on this?  Could you document it, please?

No, don't use utf-7-encode directly but use
encode-coding-string.

For instance, this:

> +(defun utf7-encode-NEW (string &optional for-imap)
> +  (with-temp-buffer
> +    ;; (utf-7-encode FROM TO IMAP)
> +    ;;
> +    ;; `utf-7-encode' also accepts that FROM is a string, but it's not
> +    ;; documented.
> +    (utf-7-encode string nil for-imap)
> +    (buffer-string)))

can simply be:

(defun utf7-encode-NEW (string &optional for-imap)
  (encode-coding-string string (if for-imap 'utf-7-imap 'utf-7)))

And the test for the availability is:

(and (coding-system-p 'utf-7) (coding-system-p 'utf-7-imap))

---
Kenichi Handa
handa@ni.aist.go.jp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: imap.el: international/utf-7.el vs. gnus/utf7.el
  2007-11-07  0:36       ` Kenichi Handa
@ 2007-11-20 21:08         ` Reiner Steib
  0 siblings, 0 replies; 3+ messages in thread
From: Reiner Steib @ 2007-11-20 21:08 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: jasonr, topia, ding, emacs-devel

On Wed, Nov 07 2007, Kenichi Handa wrote:

>> > I think the right thing is to uncomment all codes for
>> > utf-7-map in utf-7.el, and modify gnus to use normal
>> > encode/decode-coding-region/string with utf-7-imap.
>> >
>> > I've just committed the former change.  

I have modified gnus/utf7.el accordingly:

	* utf7.el (utf7-encode, utf7-decode): Use coding system
	`utf-7'/`utf-7-imap' from utf-7.el' if available.

> No, don't use utf-7-encode directly but use encode-coding-string.
>
> For instance, this[...] can simply be:
>
> (defun utf7-encode-NEW (string &optional for-imap)
>   (encode-coding-string string (if for-imap 'utf-7-imap 'utf-7)))
>
> And the test for the availability is:
>
> (and (coding-system-p 'utf-7) (coding-system-p 'utf-7-imap))

Thanks for the hints.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-20 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87k5p1ho29.wl%topia@clovery.jp>
     [not found] ` <472B1AD5.3090006@gnu.org>
     [not found]   ` <E1IovyW-0001nS-4a@etlken.m17n.org>
2007-11-06 19:53     ` imap.el: international/utf-7.el vs. gnus/utf7.el (was: 23.0.50; utf7-decode failed with non latin-1 charactor) Reiner Steib
2007-11-07  0:36       ` Kenichi Handa
2007-11-20 21:08         ` imap.el: international/utf-7.el vs. gnus/utf7.el Reiner Steib

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).