Gnus development mailing list
 help / color / mirror / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: Miles Bader <miles@gnu.org>
Cc: eliz@gnu.org, ding@gnus.org, emacs-devel@gnu.org
Subject: Re: Sending attachments
Date: Tue, 07 Jul 2009 09:59:56 +0900	[thread overview]
Message-ID: <tl7ocrxi9yr.fsf@m17n.org> (raw)
In-Reply-To: <87y6r1san7.fsf@catnip.gol.com> (message from Miles Bader on Tue, 07 Jul 2009 07:35:08 +0900)

In article <87y6r1san7.fsf@catnip.gol.com>, Miles Bader <miles@gnu.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>>> In the case non-ASCII character case mentioned above, he may not even
>>> _know_ that he needs to do anything or look at any documentation --
>>> he'll just send incorrect mail.
> >
> > Did you actually try that?  Mail mode will not let you send such
> > messages, it will prompt for a proper encoding.

> You may be thinking of a different case.

> I did test sending a message with non-ASCII text in the header, which
> mail-mode sent incorrectly, without any prompting or warning (you can't
> just encode header text using the body's encoding, you need to use the
> special "?=" encoding stuff).

I've been believed that mail-mode (and the new rmail code)
supports non-ASCII Subject: correctly, but it was not.  I've
just noticed that I'm using these setups in my .emacs.  The
similar codes should be installed (of course, not as hooks).

(require 'rfc2047)

(defun rmail-decode-header ()
  (save-excursion
    (goto-char (point-min))
    (search-forward "\n\n")
    (if (re-search-backward "^subject:" nil t)
	(let ((buffer-read-only nil)
	      (pos (match-end 0)))
	  (forward-line 1)
	  (while (looking-at "[ \t]")
	    (forward-line 1))
	  (rfc2047-decode-region pos (1- (point)))))))

(add-hook 'rmail-show-message-hook 'rmail-decode-header)

(require 'rmailsum)

(defun mail-decode-summary-line (line)
  (rfc2047-decode-string line))

(setq rmail-summary-line-decoder 'mail-decode-summary-line)

(require 'sendmail)

(defun mail-encode-header ()
  (save-excursion
    (goto-char (point-min))
    (search-forward mail-header-separator nil 'move)
    (let ((case-fold-search t)
	  pos)
      (when (re-search-backward "^subject:" nil t)
	(setq pos (point))
	(forward-line 1)
	(while (looking-at "[ \t][^ \t\n]")
	  (forward-line 1))
	(rfc2047-encode-region pos (1- (point)))))))

(add-hook 'mail-send-hook 'mail-encode-header)

(defun mail-decode-header ()
  (save-excursion
    (mail-position-on-field "Subject" t)
    (if (not (bobp))
	(let ((pos (point)))
	  (beginning-of-line)
	  (while (looking-at "[ \t]")
	    (forward-line -1))
	  (rfc2047-decode-region (point) pos)))))

(add-hook 'mail-setup-hook 'mail-decode-header)

---
Kenichi Handa
handa@m17n.org




  reply	other threads:[~2009-07-07  0:59 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1MM5lq-0003BA-MV@fencepost.gnu.org>
     [not found] ` <87vdmcnfkc.fsf@catnip.gol.com>
     [not found]   ` <E1MMRqU-0001dM-E2@fencepost.gnu.org>
     [not found]     ` <buows6qij9t.fsf@dhlpc061.dev.necel.com>
     [not found]       ` <87bpo2i52l.fsf@iki.fi>
     [not found]         ` <buo7hyqi2b6.fsf@dhlpc061.dev.necel.com>
     [not found]           ` <jwv4otqn70c.fsf-monnier+emacs@gnu.org>
2009-07-06  6:45             ` message-mode / mail-mode Reiner Steib
2009-07-11 10:04               ` Stefan Monnier
     [not found] ` <87k52rzyn1.fsf@benthic.rattlesnake.com>
     [not found]   ` <873a9fw6dt.fsf@catnip.gol.com>
     [not found]     ` <87y6r7yp1y.fsf@stupidchicken.com>
     [not found]       ` <E1MMjdS-0004fU-SB@fencepost.gnu.org>
     [not found]         ` <0922916E-B9DD-41C4-8A3D-8550CDD56B62@mit.edu>
     [not found]           ` <83r5ww1m3k.fsf@gnu.org>
2009-07-05  2:39             ` Sending attachments Miles Bader
2009-07-05  3:18               ` Eli Zaretskii
2009-07-05  3:44                 ` Miles Bader
2009-07-05 18:16                   ` Eli Zaretskii
2009-07-05 20:44                     ` Miles Bader
2009-07-06  3:15                       ` Eli Zaretskii
2009-07-06  3:50                         ` Miles Bader
2009-07-06  4:54                           ` Miles Bader
2009-07-06 20:06                             ` Eli Zaretskii
2009-07-06 22:35                               ` Miles Bader
2009-07-07  0:59                                 ` Kenichi Handa [this message]
2009-07-07  9:43                                   ` Alfred M. Szmidt
2009-07-08  0:16                                   ` Richard Stallman
2009-07-11 15:45                                     ` Stefan Monnier
2009-07-06  6:37                           ` Alfred M. Szmidt
2009-07-06  7:47                             ` Miles Bader
2009-07-06 20:08                               ` Eli Zaretskii
2009-07-06 14:13                             ` Chong Yidong
2009-07-06 20:15                               ` Eli Zaretskii
2009-07-07  5:57                             ` Giorgos Keramidas
2009-07-06 15:05                       ` Richard Stallman
2009-07-11 19:08                         ` Stefan Monnier
2009-07-11 19:41                           ` Alfred M. Szmidt
2009-07-12  3:05                             ` Leo
2009-07-12  3:10                               ` Lennart Borgman
2009-07-13 12:11                             ` Stefan Monnier
2009-07-15  9:35                               ` Alfred M. Szmidt
2009-07-15 11:44                                 ` Richard Riley
2009-07-15 14:22                                 ` Stefan Monnier
2009-07-05 22:56                     ` Chong Yidong
2009-07-06 20:10                       ` Eli Zaretskii
2009-07-05  8:01               ` Andreas Schwab
2009-07-05  8:30                 ` Miles Bader
2009-07-06 15:05               ` Richard Stallman
     [not found]       ` <E1MMj74-0003cD-P4@fencepost.gnu.org>
     [not found]         ` <877hyp3by2.fsf@stupidchicken.com>
     [not found]           ` <E1MMrcO-0000SJ-K8@fencepost.gnu.org>
2009-07-15 21:51             ` Reducing Gnus dependencies in message.el (was: Sending attachments) Reiner Steib
     [not found] ` <E1MM5xL-0003WW-TZ@fencepost.gnu.org>
     [not found]   ` <E1MNFFR-0006gw-Dn@fencepost.gnu.org>
     [not found]     ` <jwvskhalrz5.fsf-monnier+emacs@gnu.org>
     [not found]       ` <E1MNpjn-0005Ab-1m@fencepost.gnu.org>
     [not found]         ` <jwvzlbbdybf.fsf-monnier+emacs@gnu.org>
     [not found]           ` <E1MPw2H-0006YD-7X@fencepost.gnu.org>
     [not found]             ` <jwvljmsbx5i.fsf-monnier+emacs@gnu.org>
     [not found]               ` <E1MQfUg-0005pF-Gr@fencepost.gnu.org>
     [not found]                 ` <87eisjjrsc.fsf@uwakimon.sk.tsukuba.ac.jp>
     [not found]                   ` <E1MRFUw-0001fh-MZ@fencepost.gnu.org>
     [not found]                     ` <87iqhsr8jm.fsf@lifelogs.com>
     [not found]                       ` <E1MRnWA-0004Yi-Cu@fencepost.gnu.org>
     [not found]                         ` <87my73kwxc.fsf@lifelogs.com>
     [not found]                           ` <E1MSDRN-0008TW-MF@fencepost.gnu.org>
2009-07-18 19:15                             ` rfc2047.el dependencies on mm-util.el " Reiner Steib
2009-07-19  4:36                               ` Richard Stallman
2009-07-19  5:30                                 ` rfc2047.el dependencies on mm-util.el Stefan Monnier
2009-07-19 23:21                                   ` Richard Stallman
2009-07-20 18:21                                     ` Stefan Monnier
2009-07-20 18:26                                       ` Bastien
2009-07-20 18:45                                         ` Chong Yidong
2009-07-21 14:41                                           ` Richard Stallman
2009-07-19 18:10                                 ` rfc2047.el dependencies on mm-util.el (was: Sending attachments) Eli Zaretskii
2009-07-19 23:22                                   ` Richard Stallman
2009-07-22 21:57                                   ` Kevin Ryde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tl7ocrxi9yr.fsf@m17n.org \
    --to=handa@m17n.org \
    --cc=ding@gnus.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).