From: Dmitry Alexandrov <321942@gmail.com>
To: Kevin Brubeck Unhammer <unhammer@fsfe.org>
Cc: info-gnus-english@gnu.org
Subject: Re: xdg-email vs browse-url-mail
Date: Fri, 15 Jul 2016 00:09:31 +0300 [thread overview]
Message-ID: <87r3awc4fo.fsf@gmail.com> (raw)
In-Reply-To: <874m7sfkne.fsf@fsfe.org> (Kevin Brubeck Unhammer's message of "Thu, 14 Jul 2016 14:51:01 +0200")
[-- Attachment #1: Type: text/plain, Size: 784 bytes --]
Kevin Brubeck Unhammer <unhammer@fsfe.org> writes:
> I just tried using browse-url-mail as a mailto-handler with the below
> script as my mail handler (set in XFCE settings):
>
> #!/bin/bash
> mailto="${*//\"/}"
...
> if [[ ! ${mailto} =~ ^mailto: ]]; then
> mailto="mailto:${mailto}"
> fi
Does not xdg-email(1) already do that?
> emacsclient -c --eval "(browse-url-mail \"${mailto}\")"
>
> It seems to work with xdg-email, but when I use --attach to attach a
> file, it just appears as an "Attach: /path/to/file" header instead of
> the usual <#part thing. After sending, nothing is attached to the
> received message that I can tell. Is there a way to make browse-url-mail
> do the right thing, or to make message-mode treat that "Attach:" line
> correctly?
Try this:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: browse-url-mail.patch --]
[-- Type: text/x-diff, Size: 2886 bytes --]
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index c0b3591..a4d47f6 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -1562,31 +1562,42 @@ When called non-interactively, optional second argument NEW-WINDOW is
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Mailto URL: "))
(save-excursion
- (let* ((alist (rfc2368-parse-mailto-url url))
- (to (assoc "To" alist))
- (subject (assoc "Subject" alist))
- (body (assoc "Body" alist))
- (rest (delq to (delq subject (delq body alist))))
- (to (cdr to))
- (subject (cdr subject))
- (body (cdr body))
- (mail-citation-hook (unless body mail-citation-hook)))
- (if (browse-url-maybe-new-window new-window)
- (compose-mail-other-window to subject rest nil
- (list 'insert-buffer (current-buffer)))
- (compose-mail to subject rest nil nil
- (list 'insert-buffer (current-buffer))))
- (when body
- (goto-char (point-min))
- (unless (or (search-forward (concat "\n" mail-header-separator "\n")
- nil 'move)
- (bolp))
- (insert "\n"))
- (goto-char (prog1
- (point)
- (insert (replace-regexp-in-string "\r\n" "\n" body))
- (unless (bolp)
- (insert "\n"))))))))
+ (let ((headers (rfc2368-parse-mailto-url url))
+ to subject body attaches rest)
+ (dolist (header headers)
+ (cond
+ ((equal (car header) "To")
+ (setq to (cdr header)))
+ ((equal (car header) "Subject")
+ (setq subject (cdr header)))
+ ((equal (car header) "Body")
+ (setq body (cdr header)))
+ ((equal (car header) "Attach")
+ (add-to-list 'attaches (cdr header)))
+ (t
+ (push header rest))))
+ (let ((mail-citation-hook (unless body mail-citation-hook)))
+ (if (browse-url-maybe-new-window new-window)
+ (compose-mail-other-window to subject rest nil
+ (list 'insert-buffer (current-buffer)))
+ (compose-mail to subject rest nil nil
+ (list 'insert-buffer (current-buffer))))
+ (when body
+ (goto-char (point-min))
+ (unless (or (search-forward (concat "\n" mail-header-separator "\n")
+ nil 'move)
+ (bolp))
+ (insert "\n"))
+ (goto-char (prog1
+ (point)
+ (insert (replace-regexp-in-string "\r\n" "\n" body))
+ (unless (bolp)
+ (insert "\n")))))
+ (when attaches
+ (if (not mml-mode)
+ (error "Enable MML mode if you want to attach files")
+ (dolist (attach attaches)
+ (mml-attach-file attach nil nil "attachment"))))))))
;; --- Random browser ---
[-- Attachment #3: Type: text/plain, Size: 85 bytes --]
(Note, that I have virtually no experience with elisp, so use at your
own risk. :-)
next prev parent reply other threads:[~2016-07-14 21:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 12:51 Kevin Brubeck Unhammer
2016-07-14 21:09 ` Dmitry Alexandrov [this message]
2016-07-15 8:31 ` Kevin Brubeck Unhammer
2016-07-15 18:29 ` Dmitry Alexandrov
2016-07-15 21:16 ` Kevin Brubeck Unhammer
2016-07-16 17:13 ` Dmitry Alexandrov
2016-07-25 8:10 ` Kevin Brubeck Unhammer
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=87r3awc4fo.fsf@gmail.com \
--to=321942@gmail.com \
--cc=info-gnus-english@gnu.org \
--cc=unhammer@fsfe.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).