<<< Date Index >>>     <<< Thread Index >>>

Emacs, mutt and a problem with locales



I am running Debian unstable, and I use mutt extensively for reading
mail and GNU Emacs as the editor for the mail client.

Emacs version is 21.4.1 (modified by Debian!) and Mutt version is
1.5.13, where debianized Mutt include patches below.

patch-1.5.11.rr.compressed.1
patch-1.5.4.vk.pgp_verbose_mime
patch-1.5.5.1.nt.xtitles.3.ab.1
patch-1.5.6.dw.maildir-mtime.1
patch-1.5.6.tt.assumed_charset.1

LANG is es_ES.UTF-8 and there is no other LC_* environment variable
defined.

The problem is that Mutt shows properly any message with the correct
encoding, even I see oriental symbols in spam received with the
iso-2022-jp encoding. But when I answer a message with spanish special
characters, Emacs opens and everything starts behaving unproperly.

As an example, I read a message using Mutt, with a line like:

"Lo <accented u>nico que me dice dmesg"

I answer the message, Emacs opens and I see:

"Lo <A with a tilde followed by underscored o>nico que me dice dmesg"

And below, in Emacs status line I see "0" instead of "u", so it seems
like Emacs is not detecting that the source being edited is composed
by UTF-8 characters.

Then I edit my response, send the message, and when receiving the copy
from the mailing list I'd see:

"Lo <?>nico que me dice dmesg"

Probably because Mutt is expecting UTF-8 and Emacs inserted latin-1
special characters in my response.

I tend to think that something in my .emacs is misconfigured but I
don't know what.

Find attached my .emacs.

Any ideas welcome.

Cordially, Ismael
-- 
Ismael Valladolid Torres

http://lamediahostia.blogspot.com/     m. +34679156321
http://www.flickr.com/photos/ivalladt  j. ivalladt@xxxxxxxxxxxx
;; emacs - GNU Emacs initialization file

;; Copyright (C) 2005 Ismael Valladolid Torres <ivalladt@xxxxxxxxx>

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301, USA.

;; See the file COPYING for details.

;; Search for local elisp libraries to load
(setq elisp (expand-file-name "~/.elisp"))

(when (file-directory-p elisp)
  (add-to-list 'load-path elisp))

;; A different default frame font on NT and on X
(defvar default-frame-font)

;; Eval the command below to get a list of available fonts
;; (prin1-to-string (x-list-fonts "*"))

;; Stuff to be run only on X
(cond ((eq window-system 'x)
       (if (file-directory-p "/usr/share/fonts/X11/proggy")
           (setq default-frame-font 
"-windows-proggycleansz-medium-r-normal--13-80-96-96-c-70-iso8859-1")
         (setq default-frame-font "fixed"))
       
       ;; Enable clipboard only if running Gnome
       (when (getenv "GNOME_DESKTOP_SESSION_ID")
         (setq x-select-enable-clipboard 't))
       
       (set-scroll-bar-mode 'right))
      
      ;; Stuff to be run only on NT
      ((eq window-system 'w32)
           (setq default-frame-font 
"-raster-ProggyCleanSZ-normal-r-normal-normal-10-75-96-96-c-70-iso8859-1")
       
       ;; Enable printing through Windows and/or the web browser
       (when (and (locate-library "htmlize") (locate-library "w32-winprint"))
         (load-library "htmlize")
         (load-library "w32-winprint"))
       
       ;; Cygwin related stuff
       (when (file-directory-p "C:/cygwin/bin")
         
         ;; Make NT Emacs use Cygwin bash, copied verbatim from Cygwin FAQ
         ;; at http://www.cygwin.com/faq/
         
         ;; This assumes that Cygwin is installed in C:\cygwin (the
         ;; default) and that C:\cygwin\bin is not already in your
         ;; Windows Path (it generally should not be).
         ;;
         (setq exec-path (cons "C:/cygwin/bin" exec-path))
         (setenv "PATH" (concat "C:\\cygwin\\bin;" (getenv "PATH")))
         ;;
         ;; NT-emacs assumes a Windows command shell, which you change
         ;; here.
         ;;
         (setq process-coding-system-alist '(("bash" . undecided-unix)))
         (setq shell-file-name "bash")
         (setenv "SHELL" shell-file-name) 
         (setq explicit-shell-file-name shell-file-name) 
         ;;
         ;; This removes unsightly ^M characters that would otherwise
         ;; appear in the output of java applications.
         ;;
         (add-hook 'comint-output-filter-functions
                   'comint-strip-ctrl-m)
         
         ;; End of verbatim copied code
         
         ;; Make NT Emacs understand Cygwin paths
         (when (require 'cygwin-mount nil t)
           (cygwin-mount-activate))
         
         ;; Make Tramp work with Cygwin's ssh
         (when (require 'tramp nil t)
           (setq tramp-default-method "sshx"))
         
         ;; Some email niceties that need to be installed manually when
         ;; running mutt on Cygwin
         (when (file-executable-p "C:/cygwin/bin/mutt.exe")
           (when (require 'post nil t)
             (setq auto-mode-alist
                   (cons '("/tmp/mutt.*$" . post-mode) auto-mode-alist)))
           (require 'muttrc nil t)))
       
;;        ;; Not needed when running gnuclientw.exe with the -s option??
;;        (when (and (require 'gnuserv nil t) (executable-find "gnuserv"))
;;       (gnuserv-start))
       ))

;; Stuff to be run when displaying through any window system
(when window-system
  ;; Don't iconify Emacs by mistake
  (global-unset-key "\C-z")
  (tool-bar-mode 0)

  ;; Default frame colors and font
  (setq default-frame-alist
        (list
         (cons 'font default-frame-font)
         (cons 'background-color "midnight blue")
         (cons 'cursor-color "gainsboro")
         (cons 'foreground-color "gray80")))
  (setq initial-frame-alist default-frame-alist)

  ;; Enable mouse wheel when available
  (when (require 'mwheel nil t)
    (mwheel-install)))

;; Personal keyboard macros
(global-set-key "\C-ca" 'mark-whole-buffer)
(global-set-key "\C-cc" 'comment-region)
(global-set-key "\C-cg" 'goto-line)
(global-set-key "\C-cs" 'sort-lines)
(global-set-key "\C-cu" 'uncomment-region)

;; Settings common to all modes
(auto-compression-mode 't)
(column-number-mode 't)
(global-font-lock-mode 't)

(put 'overwrite-mode 'disabled t)

(setq debug-on-error 't)
(setq inhibit-default-init 't)
(setq require-final-newline 't)
(setq transient-mark-mode 't)

;; Display buffer file name in the frame title
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
;; (setq frame-title-format "%b")

;; Backup and version control
(setq backup-by-copying t)
(setq backup-directory-alist '(("." . "~/.saves")))
(setq delete-old-versions t)
(setq kept-new-versions 6)
(setq kept-old-versions 2)
(setq version-control t)

;; Settings for highlight changes mode
(global-highlight-changes "passive")
(global-set-key (kbd "\C-ch") 'highlight-changes-mode)
(custom-set-faces
 '(highlight-changes-face ((t (:foreground "white")))))

;; Binary files to be edited in hex dump format
(add-to-list 'auto-mode-alist '("\\.bin\\'" . hexl-mode))
(add-to-list 'auto-mode-alist '("\\.cap\\'" . hexl-mode))
(add-to-list 'auto-mode-alist '("\\.ijc\\'" . hexl-mode))

;; ;; Turn on auto fill for text files
;; (add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-to-list 'auto-mode-alist '("\\.txt\\'" . text-mode)) 

;; Select unicode when editing these files
(add-to-list 'file-coding-system-alist '("\\.\\(ht\\|x\\)ml\\'" . utf-8))

;; Enable my markup language modes
(when (locate-library "my-html-mode") (load-library "my-html-mode"))
(when (locate-library "my-xml-mode") (load-library "my-xml-mode"))

;; Enable some customized major modes
(require 'a-mode nil t)
(require 'pcom-mode nil t)
(require 'pcom-log-mode nil t)

;; Find some default files
(setq today (format-time-string "%Y%m%d"))

(when (file-directory-p (expand-file-name "~/doc/log"))
  (find-file (concat (expand-file-name "~/doc/log/") today ".txt")))

(find-file (concat temporary-file-directory "blog" today ".html"))

;; Local Variables:
;; mode: lisp
;; End: