[w3m-dev 04401] Re: mailto with options handling
Hiroyuki Ito <[email protected]> Mon, 16 Aug 2010 19:07:16 +0900 (JST)
| Newsgroups | gmane.comp.web.w3m.devel |
|---|---|
| Message-ID | <[email protected]> |
伊東です。
>> w3m: mailer configuration ignored!
>> http://bugs.debian.org/473780
>
>> - 内蔵メーラの有効/無効を切り替えられるように
>> - mailto: でメールアドレスのみを利用するか、
>> ? 以降のオプションも利用するか切り替えられるように。
>
>> というオプション/機能追加のパッチです。
>
>> http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=55;filename=19-mailto-with-options-handling.patch;att=1;bug=473780
>
> この件に関連してですが、自分は無条件に内蔵メーラを使用したいのですが、
> 対応していただけないでしょうか?
debian の patch を URL に '?' が含まれない場合も内蔵メーラを使用するよ
うに変更してみました。"use internal mailer instead" で常に内蔵メーラが
使われるはずです。
> あと、mailer に存在しないコマンドを指定して mailto タグを踏むと、エラー
> を表示する時間が短いのが気になりますね。
他のコマンドを実行する場合も同様なので、
とりあえずこのままにしておきます。
Index: fm.h
===================================================================
RCS file: /cvsroot/w3m/w3m/fm.h,v
retrieving revision 1.148
diff -u -r1.148 fm.h
--- fm.h 8 Aug 2010 09:53:42 -0000 1.148
+++ fm.h 16 Aug 2010 10:04:02 -0000
@@ -959,6 +959,12 @@
#else
global char *Mailer init(DEF_MAILER);
#endif
+#ifdef USE_W3MMAILER
+#define MAILTO_OPTIONS_USE_W3MMAILER 0
+#endif
+#define MAILTO_OPTIONS_IGNORE 1
+#define MAILTO_OPTIONS_USE_MAILTO_URL 2
+global int MailtoOptions init(MAILTO_OPTIONS_IGNORE);
global char *ExtBrowser init(DEF_EXT_BROWSER);
global char *ExtBrowser2 init(NULL);
global char *ExtBrowser3 init(NULL);
Index: main.c
===================================================================
RCS file: /cvsroot/w3m/w3m/main.c,v
retrieving revision 1.268
diff -u -r1.268 main.c
--- main.c 8 Aug 2010 09:53:42 -0000 1.268
+++ main.c 16 Aug 2010 10:04:02 -0000
@@ -2890,6 +2890,42 @@
return;
}
+static int
+handleMailto(char *url)
+{
+ Str to;
+ char *pos;
+
+ if (strncasecmp(url, "mailto:", 7))
+ return 0;
+#ifdef USE_W3MMAILER
+ if (! non_null(Mailer) || MailtoOptions == MAILTO_OPTIONS_USE_W3MMAILER)
+ return 0;
+#else
+ if (!non_null(Mailer)) {
+ /* FIXME: gettextize? */
+ disp_err_message("no mailer is specified", TRUE);
+ return 1;
+ }
+#endif
+
+ /* invoke external mailer */
+ if (MailtoOptions == MAILTO_OPTIONS_USE_MAILTO_URL) {
+ to = Strnew_charp(html_unquote(url));
+ } else {
+ to = Strnew_charp(url + 7);
+ if ((pos = strchr(to->ptr, '?')) != NULL)
+ Strtruncate(to, pos - to->ptr);
+ }
+ fmTerm();
+ system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)),
+ FALSE)->ptr);
+ fmInit();
+ displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ pushHashHist(URLHist, url);
+ return 1;
+}
+
/* follow HREF link */
DEFUN(followA, GOTO_LINK, "Go to current link")
{
@@ -2939,31 +2975,8 @@
return;
}
}
- if (!strncasecmp(a->url, "mailto:", 7)
-#ifdef USE_W3MMAILER
- && non_null(Mailer) && strchr(a->url, '?') == NULL
-#endif
- ) {
- /* invoke external mailer */
- Str to = Strnew_charp(a->url + 7);
-#ifndef USE_W3MMAILER
- char *pos;
- if (!non_null(Mailer)) {
- /* FIXME: gettextize? */
- disp_err_message("no mailer is specified", TRUE);
- return;
- }
- if ((pos = strchr(to->ptr, '?')) != NULL)
- Strtruncate(to, pos - to->ptr);
-#endif
- fmTerm();
- system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)),
- FALSE)->ptr);
- fmInit();
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
- pushHashHist(URLHist, a->url);
+ if (handleMailto(a->url))
return;
- }
#if 0
else if (!strncasecmp(a->url, "news:", 5) && strchr(a->url, '@') == NULL) {
/* news:newsgroup is not supported */
@@ -3976,31 +3989,8 @@
{
Buffer *buf;
- if (!strncasecmp(url, "mailto:", 7)
-#ifdef USE_W3MMAILER
- && non_null(Mailer) && strchr(url, '?') == NULL
-#endif
- ) {
- /* invoke external mailer */
- Str to = Strnew_charp(url + 7);
-#ifndef USE_W3MMAILER
- char *pos;
- if (!non_null(Mailer)) {
- /* FIXME: gettextize? */
- disp_err_message("no mailer is specified", TRUE);
- return;
- }
- if ((pos = strchr(to->ptr, '?')) != NULL)
- Strtruncate(to, pos - to->ptr);
-#endif
- fmTerm();
- system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)),
- FALSE)->ptr);
- fmInit();
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
- pushHashHist(URLHist, url);
+ if (handleMailto(url))
return;
- }
#if 0
if (!strncasecmp(url, "news:", 5) && strchr(url, '@') == NULL) {
/* news:newsgroup is not supported */
Index: rc.c
===================================================================
RCS file: /cvsroot/w3m/w3m/rc.c,v
retrieving revision 1.115
diff -u -r1.115 rc.c
--- rc.c 4 Aug 2010 14:06:36 -0000 1.115
+++ rc.c 16 Aug 2010 10:04:02 -0000
@@ -139,6 +139,7 @@
#define CMT_URIMETHODMAP N_("List of urimethodmap files")
#define CMT_EDITOR N_("Editor")
#define CMT_MAILER N_("Mailer")
+#define CMT_MAILTO_OPTIONS N_("How to call Mailer for mailto URLs with options")
#define CMT_EXTBRZ N_("External Browser")
#define CMT_EXTBRZ2 N_("Second External Browser")
#define CMT_EXTBRZ3 N_("Third External Browser")
@@ -323,6 +324,15 @@
};
#endif /* USE_COOKIE */
+static struct sel_c mailtooptionsstr[] = {
+#ifdef USE_W3MMAILER
+ {N_S(MAILTO_OPTIONS_USE_W3MMAILER), N_("use internal mailer instead")},
+#endif
+ {N_S(MAILTO_OPTIONS_IGNORE), N_("ignore options and use only the address")},
+ {N_S(MAILTO_OPTIONS_USE_MAILTO_URL), N_("use full mailto URL")},
+ {0, NULL, NULL}
+};
+
#ifdef USE_M17N
static wc_ces_list *display_charset_str = NULL;
static wc_ces_list *document_charset_str = NULL;
@@ -543,6 +553,8 @@
CMT_URIMETHODMAP, NULL},
#endif
{"editor", P_STRING, PI_TEXT, (void *)&Editor, CMT_EDITOR, NULL},
+ {"mailto_options", P_INT, PI_SEL_C, (void *)&MailtoOptions,
+ CMT_MAILTO_OPTIONS, (void *)mailtooptionsstr},
{"mailer", P_STRING, PI_TEXT, (void *)&Mailer, CMT_MAILER, NULL},
{"extbrowser", P_STRING, PI_TEXT, (void *)&ExtBrowser, CMT_EXTBRZ, NULL},
{"extbrowser2", P_STRING, PI_TEXT, (void *)&ExtBrowser2, CMT_EXTBRZ2,