Gnus development mailing list
 help / color / mirror / Atom feed
* mm-coding-system-priorities
@ 2004-03-24 14:09 Miles Bader
  2004-03-24 14:28 ` mm-coding-system-priorities Jesper Harder
  2004-03-24 14:47 ` mm-coding-system-priorities Reiner Steib
  0 siblings, 2 replies; 7+ messages in thread
From: Miles Bader @ 2004-03-24 14:09 UTC (permalink / raw)


Hi,

I'm using the gnus in the Emacs source tree, so maybe this problem has
already been fixed:

`mm-coding-system-priorities' seems to only work properly if the members
are `canonical' character-set names instead of aliases, for instance
this fails to do the right thing:

   (setq mm-coding-system-priorities '(euc-jp))

but this works:

   (setq mm-coding-system-priorities (mapcar 'coding-system-base '(euc-jp)))

It seems to me that gnus ought to do this mapping itself, as many coding
systems have aliases which are more widely used than their canonical emacs
names.

Perhaps something like (untested):

--- orig/lisp/gnus/mm-util.el
+++ mod/lisp/gnus/mm-util.el
@@ -507,8 +507,11 @@
 	     ;; system that has one.
 	     (let ((systems (find-coding-systems-region b e)))
 	       (when mm-coding-system-priorities
-		 (setq systems
-		       (sort systems 'mm-sort-coding-systems-predicate)))
+		 (let ((mm-coding-system-priorities 
+			(mapcar #'coding-system-base
+				mm-coding-system-priorities)))
+		   (setq systems
+			 (sort systems 'mm-sort-coding-systems-predicate))))
 	       ;; Fixme: The `mime-charset' (`x-ctext') of `compound-text'
 	       ;; is not in the IANA list.
 	       (setq systems (delq 'compound-text systems))

Thanks,

-Miles
-- 
"Though they may have different meanings, the cries of 'Yeeeee-haw!' and
 'Allahu akbar!' are, in spirit, not actually all that different."




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

* Re: mm-coding-system-priorities
  2004-03-24 14:09 mm-coding-system-priorities Miles Bader
@ 2004-03-24 14:28 ` Jesper Harder
  2004-03-24 14:47 ` mm-coding-system-priorities Reiner Steib
  1 sibling, 0 replies; 7+ messages in thread
From: Jesper Harder @ 2004-03-24 14:28 UTC (permalink / raw)


Miles Bader <miles@gnu.org> writes:

> I'm using the gnus in the Emacs source tree, so maybe this problem has
> already been fixed:
>
> `mm-coding-system-priorities' seems to only work properly if the
> members are `canonical' character-set names instead of aliases,

It was fixed with this change:

2003-04-13  Reiner Steib  <Reiner.Steib@gmx.de>

	* mm-util.el (mm-sort-coding-systems-predicate): Convert elements
	of `mm-coding-system-priorities' to base coding system.



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

* Re: mm-coding-system-priorities
  2004-03-24 14:09 mm-coding-system-priorities Miles Bader
  2004-03-24 14:28 ` mm-coding-system-priorities Jesper Harder
@ 2004-03-24 14:47 ` Reiner Steib
  2004-03-24 15:06   ` mm-coding-system-priorities Miles Bader
  1 sibling, 1 reply; 7+ messages in thread
From: Reiner Steib @ 2004-03-24 14:47 UTC (permalink / raw)


On Wed, Mar 24 2004, Miles Bader wrote:

> I'm using the gnus in the Emacs source tree, so maybe this problem has
> already been fixed:
>
> `mm-coding-system-priorities' seems to only work properly if the members
> are `canonical' character-set names instead of aliases, 

I have fixed this (before 5.10.1 was released):

,----
| 2003-04-13  Reiner Steib  <Reiner.Steib@gmx.de>
| 
| 	* mm-util.el (mm-sort-coding-systems-predicate): Convert elements
| 	of `mm-coding-system-priorities' to base coding system.
`----

> It seems to me that gnus ought to do this mapping itself, as many coding
> systems have aliases which are more widely used than their canonical emacs
> names.

I agree.

> Perhaps something like (untested):
>
> --- orig/lisp/gnus/mm-util.el
> +++ mod/lisp/gnus/mm-util.el
> @@ -507,8 +507,11 @@
>  	     ;; system that has one.
>  	     (let ((systems (find-coding-systems-region b e)))
>  	       (when mm-coding-system-priorities
> -		 (setq systems
> -		       (sort systems 'mm-sort-coding-systems-predicate)))
> +		 (let ((mm-coding-system-priorities 
> +			(mapcar #'coding-system-base
> +				mm-coding-system-priorities)))
> +		   (setq systems
> +			 (sort systems 'mm-sort-coding-systems-predicate))))
>  	       ;; Fixme: The `mime-charset' (`x-ctext') of `compound-text'
>  	       ;; is not in the IANA list.
>  	       (setq systems (delq 'compound-text systems))

I've done it in `mm-sort-coding-systems-predicate' (but I don't
remember exactly why I did it in this way).  If you think that your
solution is better, we may change it.

(defun mm-sort-coding-systems-predicate (a b)
  (let ((priorities
	 (mapcar (lambda (cs)
		   ;; Note: invalid entries are dropped silently
		   (and (coding-system-p cs)
			(coding-system-base cs)))
		 mm-coding-system-priorities)))
    (> (length (memq a priorities))
       (length (memq b priorities)))))

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




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

* Re: mm-coding-system-priorities
  2004-03-24 14:47 ` mm-coding-system-priorities Reiner Steib
@ 2004-03-24 15:06   ` Miles Bader
  0 siblings, 0 replies; 7+ messages in thread
From: Miles Bader @ 2004-03-24 15:06 UTC (permalink / raw)


Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:
> I've done it in `mm-sort-coding-systems-predicate' (but I don't
> remember exactly why I did it in this way).  If you think that your
> solution is better, we may change it.

The difference would seem to be that doing it in
`mm-sort-coding-systems-predicate' ends up doing the mapcar around log-N
times, whereas temporarily rebinding mm-coding-system-priorities just
does it once.  I think N is often around ~30-40 if the message contains
any non-ascii characters, so it may be worth changing (though
mm-coding-system-priorities is probably usually fairly short, in which
case each mapcar is not all that expensive).

-Miles
-- 
80% of success is just showing up.  --Woody Allen




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

* Re: mm-coding-system-priorities
  2003-04-13 20:44       ` mm-coding-system-priorities Reiner Steib
@ 2003-04-15 21:54         ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-04-15 21:54 UTC (permalink / raw)


Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:

> | A base coding system is what made by `make-coding-system'.
> | Any alias nor subsidiary coding systems are not base coding system.

Ah, right; I didn't know that.

> Changing `mm-sort-coding-systems-predicate' should achieve it (I have
> committed this):

Cool.

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



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

* Re: mm-coding-system-priorities
  2003-04-12 19:53     ` mm-coding-system-priorities Lars Magne Ingebrigtsen
@ 2003-04-13 20:44       ` Reiner Steib
  2003-04-15 21:54         ` mm-coding-system-priorities Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Reiner Steib @ 2003-04-13 20:44 UTC (permalink / raw)


On Sat, Apr 12 2003, Lars Magne Ingebrigtsen wrote:

> Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:
>> ,----[ M-x describe-coding-system utf-8 RET ]
>> | u -- utf-8 (alias of mule-utf-8)
>> `----
>>
>> Hm, does it even expect the original name of the coding-system and
>> *not* an alias?  If so, I think this should be made more clear in the
>> documentation.
>
> utf-8 is both a coding system and a charset, I think.

AFAICS, we need to distinguish between "base coding-system",
"aliased/subsidiary coding-system" and mime-charset.  utf-8 is both,
an "aliased/subsidiary coding-system" and a mime-charset, but not a
"base coding-system".  The problem is, that using utf-8 in
`mm-coding-system-priorities' has no effect[1] at all: You need to use
a non-aliased coding-system, as returned by `coding-system-base':

,----[ C-h f coding-system-base RET ]
| coding-system-base is a compiled Lisp function in `international/mule'.
| (coding-system-base CODING-SYSTEM)
| 
| Return the base coding system of CODING-SYSTEM.
| A base coding system is what made by `make-coding-system'.
| Any alias nor subsidiary coding systems are not base coding system.
`----

The doc-string of `mm-coding-system-priorities' doesn't mention this.
Even the default value for users with "current-language-environment =
Japanese" contains the bogus entry utf-8.

> (And I don't think it should matter whether you use the name or an
> alias.)

Changing `mm-sort-coding-systems-predicate' should achieve it (I have
committed this):

(defun mm-sort-coding-systems-predicate (a b)
  (let ((priorities
	 (mapcar (lambda (cs)
		   ;; Note: invalid entries are dropped silently
		   (and (coding-system-p cs)
			(coding-system-base cs)))
		 mm-coding-system-priorities)))
    (> (length (memq a priorities))
       (length (memq b priorities)))))

Bye, Reiner.

[1] See my test in <news:v965pyw1gv.fsf@marauder.physik.uni-ulm.de>
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/




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

* Re: mm-coding-system-priorities
  2003-04-01 17:51   ` mm-coding-system-priorities (was: charset=macintosh) Reiner Steib
@ 2003-04-12 19:53     ` Lars Magne Ingebrigtsen
  2003-04-13 20:44       ` mm-coding-system-priorities Reiner Steib
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-04-12 19:53 UTC (permalink / raw)


Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:

> So `mm-coding-system-priorities' expects an Emacs coding system and
> not a MIME charset.  But OTOH...
>
> ,----[ M-x describe-coding-system utf-8 RET ]
> | u -- utf-8 (alias of mule-utf-8)
> `----
>
> Hm, does it even expect the original name of the coding-system and
> *not* an alias?  If so, I think this should be made more clear in the
> documentation.

utf-8 is both a coding system and a charset, I think.  (And I don't
think it should matter whether you use the name or an alias.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



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

end of thread, other threads:[~2004-03-24 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 14:09 mm-coding-system-priorities Miles Bader
2004-03-24 14:28 ` mm-coding-system-priorities Jesper Harder
2004-03-24 14:47 ` mm-coding-system-priorities Reiner Steib
2004-03-24 15:06   ` mm-coding-system-priorities Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2003-03-07 17:39 charset=macintosh Karl Eichwalder
2003-03-07 18:25 ` charset=macintosh Simon Josefsson
2003-04-01 17:51   ` mm-coding-system-priorities (was: charset=macintosh) Reiner Steib
2003-04-12 19:53     ` mm-coding-system-priorities Lars Magne Ingebrigtsen
2003-04-13 20:44       ` mm-coding-system-priorities Reiner Steib
2003-04-15 21:54         ` mm-coding-system-priorities Lars Magne Ingebrigtsen

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).