🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.emacs.vm.bug
5 messages
5 total messages Started by Ulrich Mueller Tue, 15 Sep 2009 20:44
[patch] VM 8.0.12 under Emacs 23: wrong charset for outgoing mail
#504
Author: Ulrich Mueller
Date: Tue, 15 Sep 2009 20:44
138 lines
6466 bytes
Hallo Robert,
I hope that you are still around and listen to this channel.

For an outgoing message containing only latin-1 characters, e.g.
German umlauts, VM 8.012 under GNU Emacs 23 (both in their default
configuration) will use "iso-2022-jp" as encoding. That is not a
reasonable default.

The same VM version under GNU Emacs 22 will correctly encode the
message with "iso-8859-1".

Investigating the problem, I've found two problems in function
vm-determine-proper-charset:

1. The keys of vm-mime-mule-coding-to-charset-alist are symbols, not
   strings. So the following assq (occuring in similar form in the
   code four times) will always fail, because vm-coding-system-name
   returns a string:

     (assq (vm-coding-system-name sys)
           vm-mime-mule-coding-to-charset-alist)

   The call to vm-coding-system-name should just be omitted and its
   argument used directly instead.

2. Function vm-charsets-in-region is aliased to find-charset-region.
   In Emacs 23, there really aren't separate character sets any
   more, and find-charset-region will return the first match from
   charset-priority-list. In Emacs's default configuration, this can
   only be a subset of (iso-8859-1 ascii unicode).

   I believe that in Emacs 23 it's much easier to determine the proper
   coding system by calling check-coding-systems-region. The detour
   via character sets seems no longer necessary.

Below I include a patch for vm-mime.el that should fix both problems.
It is against 8.0.12, but should also apply to the current BZR trunk.
(I didn't fix indentation of the code in all cases, in order to keep the
patch small and human-readable.)

Unfortunately, the patch adds yet another case distinction. However,
I don't see how this could be avoided.

Ulrich


--- vm-8.0.12-orig/lisp/vm-mime.el
+++ vm-8.0.12/lisp/vm-mime.el
@@ -1409,7 +1409,6 @@
 
 (defvar buffer-file-coding-system)
 
-;; TODO: integrate with the FSF's unify-8859-on-encoding-mode stuff.
 (defun vm-determine-proper-charset (beg end)
   "Work out what MIME character set to use for sending a message.
 
@@ -1430,6 +1429,28 @@
 	(if (or vm-xemacs-mule-p
 		(and vm-fsfemacs-mule-p enable-multibyte-characters))
 	    ;; Okay, we're on a MULE build.
+	  (if (fboundp 'check-coding-systems-region)
+	      ;; check-coding-systems-region appeared in GNU Emacs 23.
+	      (let* ((preapproved (vm-get-coding-system-priorities))
+		     (ucs-list (vm-get-mime-ucs-list))
+		     (cant-encode (check-coding-systems-region
+				   (point-min) (point-max)
+				   (cons 'us-ascii preapproved))))
+		(if (not (assq 'us-ascii cant-encode))
+		    ;; If there are only ASCII chars, we're done.
+		    "us-ascii"
+		  (while (and preapproved
+			      (assq (car preapproved) cant-encode)
+			      (not (memq (car preapproved) ucs-list)))
+		    (setq preapproved (cdr preapproved)))
+		  (if preapproved
+		      (cadr (assq (car preapproved)
+				  vm-mime-mule-coding-to-charset-alist))
+		    ;; None of the entries in vm-coding-system-priorities
+		    ;; can be used. This can only happen if no universal
+		    ;; coding system is included. Fall back to utf-8.
+		    "utf-8")))
+
 	    (let ((charsets (delq 'ascii
 				  (vm-charsets-in-region (point-min)
 							 (point-max)))))
@@ -1472,9 +1493,7 @@
 				(while preapproved
 				  (if (memq (car preapproved) ucs-list)
 				      (throw 'done 
-					     (car (cdr (assq 
-							(vm-coding-system-name 
-							 (car preapproved))
+					     (car (cdr (assq (car preapproved)
 				      vm-mime-mule-coding-to-charset-alist)))))
 				  (setq preapproved (cdr preapproved)))
 				;; Nothing universal in the preapproved list.
@@ -1488,8 +1507,8 @@
 			    (when (latin-unity-maybe-remap (point-min) 
 							   (point-max) sys 
 							   csets psets t)
-			      (throw 'done (second (assq 
-						    (vm-coding-system-name sys)
+			      (throw 'done
+				     (second (assq sys
 				    vm-mime-mule-coding-to-charset-alist)))))
 			  (setq systems (cdr systems)))
 			(throw 'done nil))
@@ -1511,9 +1530,8 @@
 			    ;; If we encounter a universal character set on
 			    ;; the preapproved list, pass it back.
 			    (if (memq (car preapproved) ucs-list)
-				(throw 'done (second (assq 
-						      (vm-coding-system-name
-						       (car preapproved))
+				(throw 'done
+				       (second (assq (car preapproved)
 				     vm-mime-mule-coding-to-charset-alist))))
 
 			    ;; The preapproved entry isn't universal. Check if
@@ -1549,15 +1567,14 @@
 			    ;; If we encounter a universal character set on
 			    ;; the preapproved list, pass it back.
 			    (when (memq (car preapproved) ucs-list)
-				(throw 'done (second (assq 
-						      (vm-coding-system-name
-						       (car preapproved))
+			      (throw 'done
+				     (second (assq (car preapproved)
 				     vm-mime-mule-coding-to-charset-alist))))
 			    (setq preapproved (cdr preapproved)))))
 		    (throw 'done nil))))
 	       ;; Couldn't do any magic with vm-coding-system-priorities. Pass
 	       ;; back a Japanese iso-2022 MIME character set.
-	       (t (or vm-mime-8bit-composition-charset "iso-2022-jp"))))
+	       (t (or vm-mime-8bit-composition-charset "iso-2022-jp")))))
 	  ;; If we're non-MULE and there are eight bit characters, use a
 	  ;; sensible default.
 	  (goto-char (point-min))
Re: [patch] VM 8.0.12 under Emacs 23: wrong charset for outgoing mail
#196
Author: Uday S Reddy
Date: Thu, 19 Nov 2009 18:53
12 lines
1556 bytes
Ulrich Mueller wrote:

> Below I include a patch for vm-mime.el that should fix both problems.
> It is against 8.0.12, but should also apply to the current BZR trunk.
> (I didn't fix indentation of the code in all cases, in order to keep the
> patch small and human-readable.)

These patches have now been applied to version 8.1, revision 592.
Thanks Ulrich!

Cheers,
Uday
Re: [patch] VM 8.0.12 under Emacs 23: wrong charset for outgoing mail
#200
Author: blueman
Date: Sun, 22 Nov 2009 09:09
12 lines
1842 bytes
Uday S Reddy <uDOTsDOTreddy@cs.bham.ac.uk> writes:
> Ulrich Mueller wrote:
>
>> Below I include a patch for vm-mime.el that should fix both problems.
>> It is against 8.0.12, but should also apply to the current BZR trunk.
>> (I didn't fix indentation of the code in all cases, in order to keep the
>> patch small and human-readable.)
>
> These patches have now been applied to version 8.1, revision 592.
> Thanks Ulrich!

Where can I find version 8.1 or is it still pre-release?
Re: [patch] VM 8.0.12 under Emacs 23: wrong charset for outgoing mail
#201
Author: blueman
Date: Sun, 22 Nov 2009 09:10
13 lines
1753 bytes
Uday S Reddy <uDOTsDOTreddy@cs.bham.ac.uk> writes:

> Ulrich Mueller wrote:
>
>> Below I include a patch for vm-mime.el that should fix both problems.
>> It is against 8.0.12, but should also apply to the current BZR trunk.
>> (I didn't fix indentation of the code in all cases, in order to keep the
>> patch small and human-readable.)
>
> These patches have now been applied to version 8.1, revision 592.
> Thanks Ulrich!

Where can I find version 8.1 or is it still pre-release??
Re: [patch] VM 8.0.12 under Emacs 23: wrong charset for outgoing mail
#202
Author: Uday S Reddy
Date: Sun, 22 Nov 2009 10:16
20 lines
1848 bytes
blueman wrote:

> 
> Where can I find version 8.1 or is it still pre-release?

It is pre-release I am afraid.  I am in the process of applying various 
patches that have been submitted including Rob's own updates to version 8.0.

The current version is at
    http://bazaar.launchpad.net/~reddyuday/viewmail/8.1
and you have to pull it through bazaar.  The README file tells you how.

Ulrich Mueller and I are in the process of setting up a separate 
project/branch under launchpad, which might be more suitable as a 
permanent home for VM.

Stay tuned.

Cheers,
Uday
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads