unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch to change mouse binding for html view in gnus
@ 2007-07-01 20:42 Tom Tromey
  2007-07-01 21:48 ` Reiner Steib
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2007-07-01 20:42 UTC (permalink / raw)
  To: Emacs Hackers

I have w3m installed, and so when Gnus sees an HTML message it is
displayed via w3m.  This is quite nice.

However, if I click on a link in an HTML message rendered this way,
the target is displayed using w3m.  I generally don't want this; I
only use w3m in Emacs for specialized things and in other cases I'd
rather use my external web browser.

This patch changes Gnus to use browse-url rather than w3m for links in
buffers it renders.

Tom

2007-07-01  Tom Tromey  <tromey@redhat.com>

	* mm-view.el (mm-inline-text-html-render-with-w3m): Locally set
	w3m-goto-article-function.

cvs diff: Diffing .
Index: mm-view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/gnus/mm-view.el,v
retrieving revision 1.29
diff -u -r1.29 mm-view.el
--- mm-view.el	19 Apr 2007 12:08:53 -0000	1.29
+++ mm-view.el	1 Jul 2007 20:58:45 -0000
@@ -252,6 +252,7 @@
 	(let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
 	      w3m-force-redisplay)
 	  (w3m-region (point-min) (point-max) nil charset))
+	(set (make-local-variable 'w3m-goto-article-function) #'browse-url)
 	(when (and mm-inline-text-html-with-w3m-keymap
 		   (boundp 'w3m-minor-mode-map)
 		   w3m-minor-mode-map)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-01 21:48 ` Reiner Steib
@ 2007-07-01 21:43   ` Tom Tromey
  2007-07-02  2:59     ` Katsumi Yamaoka
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2007-07-01 21:43 UTC (permalink / raw)
  To: ding; +Cc: Emacs Hackers

>>>>> "Reiner" == Reiner Steib <reinersteib+gmane@imap.cc> writes:

>> However, if I click on a link in an HTML message rendered this way,
>> the target is displayed using w3m.  I generally don't want this; I
>> only use w3m in Emacs for specialized things and in other cases I'd
>> rather use my external web browser.

Reiner> I'm not sure if doing this unconditionally is a good idea.  Shouldn't
Reiner> it be customizable?

I don't know.  Personally I think this is a good default -- people who
want to browse extensively in Emacs can set their
browse-url-browser-function.

Maybe there are people who want to usually use an external browser but
then browse using w3m from gnus.  That seems weird to me :), but if
such people exist then, yeah, this should be customizable.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-01 20:42 Patch to change mouse binding for html view in gnus Tom Tromey
@ 2007-07-01 21:48 ` Reiner Steib
  2007-07-01 21:43   ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Reiner Steib @ 2007-07-01 21:48 UTC (permalink / raw)
  To: tromey, ding; +Cc: Emacs Hackers

[ Cc-ing the Gnus list; full quote. ]

On Sun, Jul 01 2007, Tom Tromey wrote:

> I have w3m installed, and so when Gnus sees an HTML message it is
> displayed via w3m.  This is quite nice.
>
> However, if I click on a link in an HTML message rendered this way,
> the target is displayed using w3m.  I generally don't want this; I
> only use w3m in Emacs for specialized things and in other cases I'd
> rather use my external web browser.

I'm not sure if doing this unconditionally is a good idea.  Shouldn't
it be customizable?

> This patch changes Gnus to use browse-url rather than w3m for links in
> buffers it renders.
>
> Tom
>
> 2007-07-01  Tom Tromey  <tromey@redhat.com>
>
> 	* mm-view.el (mm-inline-text-html-render-with-w3m): Locally set
> 	w3m-goto-article-function.
>
> cvs diff: Diffing .
> Index: mm-view.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/gnus/mm-view.el,v
> retrieving revision 1.29
> diff -u -r1.29 mm-view.el
> --- mm-view.el	19 Apr 2007 12:08:53 -0000	1.29
> +++ mm-view.el	1 Jul 2007 20:58:45 -0000
> @@ -252,6 +252,7 @@
>  	(let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
>  	      w3m-force-redisplay)
>  	  (w3m-region (point-min) (point-max) nil charset))
> +	(set (make-local-variable 'w3m-goto-article-function) #'browse-url)
>  	(when (and mm-inline-text-html-with-w3m-keymap
>  		   (boundp 'w3m-minor-mode-map)
>  		   w3m-minor-mode-map)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-01 21:43   ` Tom Tromey
@ 2007-07-02  2:59     ` Katsumi Yamaoka
  2007-07-02 17:29       ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Katsumi Yamaoka @ 2007-07-02  2:59 UTC (permalink / raw)
  To: tromey; +Cc: ding, emacs-devel

>>>>> In <m3r6nrajgr.fsf@fleche.redhat.com> Tom Tromey wrote:
>>>>>> "Reiner" == Reiner Steib <reinersteib+gmane@imap.cc> writes:

>>> However, if I click on a link in an HTML message rendered this way,
>>> the target is displayed using w3m.  I generally don't want this; I
>>> only use w3m in Emacs for specialized things and in other cases I'd
>>> rather use my external web browser.

Reiner> I'm not sure if doing this unconditionally is a good idea.  Shouldn't
Reiner> it be customizable?

> I don't know.  Personally I think this is a good default -- people who
> want to browse extensively in Emacs can set their
> browse-url-browser-function.

> Maybe there are people who want to usually use an external browser but
> then browse using w3m from gnus.  That seems weird to me :), but if
> such people exist then, yeah, this should be customizable.

Isn't it sufficient to use the following?

(setq w3m-goto-article-function #'browse-url)

This is used only when the `w3m-safe-view-this-url' command is
invoked, and normally the `w3m-safe-view-this-url' command is
bound to a certain key only in html articles.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-02  2:59     ` Katsumi Yamaoka
@ 2007-07-02 17:29       ` Tom Tromey
  2007-07-03  4:33         ` Katsumi Yamaoka
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2007-07-02 17:29 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding, emacs-devel

>>>>> "Katsumi" == Katsumi Yamaoka <yamaoka@jpl.org> writes:

Katsumi> Isn't it sufficient to use the following?
Katsumi> (setq w3m-goto-article-function #'browse-url)

Katsumi> This is used only when the `w3m-safe-view-this-url' command is
Katsumi> invoked, and normally the `w3m-safe-view-this-url' command is
Katsumi> bound to a certain key only in html articles.

I'm afraid I'm not a w3m expert (or a gnus expert for that matter :-).
If this is what you would prefer I am happy to send a new patch.
Just let me know.

thanks,
Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-02 17:29       ` Tom Tromey
@ 2007-07-03  4:33         ` Katsumi Yamaoka
  2007-07-03 17:19           ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Katsumi Yamaoka @ 2007-07-03  4:33 UTC (permalink / raw)
  To: tromey; +Cc: ding, emacs-devel

>>>>> In <m38x9y90k1.fsf@fleche.redhat.com> Tom Tromey wrote:
>>>>>> "Katsumi" == Katsumi Yamaoka <yamaoka@jpl.org> writes:

Katsumi> Isn't it sufficient to use the following?
Katsumi> (setq w3m-goto-article-function #'browse-url)

> I'm afraid I'm not a w3m expert (or a gnus expert for that matter :-).
> If this is what you would prefer I am happy to send a new patch.
> Just let me know.

I recalled I wrote the same suggestion to you last month. ;-)
See: http://news.gmane.org/group/gmane.emacs.w3m/thread=6852

TSUCHIYA Masatoshi implemented this variable in Jan 2004 for the
other purpose (to bind it to a certain Lisp function in
nnshimbun.el[1]), but it is just the thing for people like you.

Though I don't represent a majority (because I am a member of
the emacs-w3m team), I am satisfied with the nil value of this
variable.  I've set `w3m-make-new-session' to t in order to make
emacs-w3m pop a new tab up when Gnus (or other) requires to
visit a web page.  There is no much case for which I want to use
an external browser.  In such a case, I will type `M' in the
emacs-w3m buffer.  Anyway, I don't think it is necessary to set
it to a certain value in Gnus.

[1] http://article.gmane.org/gmane.emacs.w3m/3797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-03  4:33         ` Katsumi Yamaoka
@ 2007-07-03 17:19           ` Tom Tromey
  2007-07-03 23:18             ` Katsumi Yamaoka
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2007-07-03 17:19 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding, emacs-devel

>>>>> "Katsumi" == Katsumi Yamaoka <yamaoka@jpl.org> writes:

>> I'm afraid I'm not a w3m expert (or a gnus expert for that matter :-).
>> If this is what you would prefer I am happy to send a new patch.
>> Just let me know.

Katsumi> I recalled I wrote the same suggestion to you last month. ;-)
Katsumi> See: http://news.gmane.org/group/gmane.emacs.w3m/thread=6852

Sorry, I misunderstood that message.  I didn't realize that
w3m-goto-article-function was solely for this purpose -- I thought it
was more generic, and thus needed to be set buffer-local.

Katsumi> Though I don't represent a majority (because I am a member of
Katsumi> the emacs-w3m team), I am satisfied with the nil value of this
Katsumi> variable.  I've set `w3m-make-new-session' to t in order to make
Katsumi> emacs-w3m pop a new tab up when Gnus (or other) requires to
Katsumi> visit a web page.  There is no much case for which I want to use
Katsumi> an external browser.  In such a case, I will type `M' in the
Katsumi> emacs-w3m buffer.  Anyway, I don't think it is necessary to set
Katsumi> it to a certain value in Gnus.

The reason I think this patch is needed is that I've already
configured Emacs to visit URLs the way I like.  I was surprised to
find that I had to make another modification, in a different and more
obscure (w3m-goto-article-function is not customizable) place to get
the effect I want.

If you do all your browsing in Emacs then you probably already have
browse-url-browser-function set as you like...

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-03 17:19           ` Tom Tromey
@ 2007-07-03 23:18             ` Katsumi Yamaoka
  2007-07-04  6:10               ` Katsumi Yamaoka
  2007-07-12 16:05               ` Tom Tromey
  0 siblings, 2 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2007-07-03 23:18 UTC (permalink / raw)
  To: tromey; +Cc: ding, emacs-devel

>>>>> In <m3fy454d7y.fsf@fleche.redhat.com> Tom Tromey wrote:

Katsumi> I don't think it is necessary to set it to a certain value in
Katsumi> Gnus.

> The reason I think this patch is needed is that I've already
> configured Emacs to visit URLs the way I like.  I was surprised to
> find that I had to make another modification, in a different and more
> obscure (w3m-goto-article-function is not customizable) place to get
> the effect I want.

I noticed `w3m-goto-article-function' hasn't been made up as a
user option, so I've made it customizable in the emacs-w3m CVS
trunk yesterday.  Feel free to set it to a Lisp function you
like, but I noticed there is a limitation a bit (because it was
introduced for a particular purpose first).  That is the function
set should return a non-nil value.  Though `browse-url' seems to
return a non-nil value normally, it is better to ensure it.  For
this reason, I recommend using the function form

(lambda (url) (browse-url url) t)

rather than just using `browse-url'.

> If you do all your browsing in Emacs then you probably already have
> browse-url-browser-function set as you like...

I leave all those as the default and have no problem (Firefox
happens to be used by default).  I don't always necessarily use
emacs-w3m.   I use Firefox when purchasing something, manipulating
my bank account... ;-)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-03 23:18             ` Katsumi Yamaoka
@ 2007-07-04  6:10               ` Katsumi Yamaoka
  2007-07-12 16:05               ` Tom Tromey
  1 sibling, 0 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2007-07-04  6:10 UTC (permalink / raw)
  To: tromey; +Cc: ding, emacs-devel

>>>>> In <b4md4z9krec.fsf@jpl.org> Katsumi Yamaoka wrote:
>>>>>> In <m3fy454d7y.fsf@fleche.redhat.com> Tom Tromey wrote:

> but I noticed there is a limitation a bit (because it was
> introduced for a particular purpose first).  That is the function
> set should return a non-nil value.  Though `browse-url' seems to
> return a non-nil value normally, it is better to ensure it.  For
> this reason, I recommend using the function form

> (lambda (url) (browse-url url) t)

> rather than just using `browse-url'.

I've improved it so that just `browse-url' may work no matter
what it returns (in the emacs-w3m CVS trunk).  So, you may use
the one that I suggested first.

>>>>> In <b4mbqevzf0y.fsf@jpl.org> Katsumi Yamaoka wrote:

> (setq w3m-goto-article-function #'browse-url)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-03 23:18             ` Katsumi Yamaoka
  2007-07-04  6:10               ` Katsumi Yamaoka
@ 2007-07-12 16:05               ` Tom Tromey
  2007-07-12 18:19                 ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2007-07-12 16:05 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding, emacs-devel

>>>>> "Katsumi" == Katsumi Yamaoka <yamaoka@jpl.org> writes:

Katsumi> For this reason, I recommend using the function form
Katsumi> (lambda (url) (browse-url url) t)
Katsumi> rather than just using `browse-url'.

I tried:

(setq w3m-goto-article-function (lambda (url) (browse-url url) t))

but this fails:

  fboundp((lambda (url) (browse-url url) t))
  w3m-safe-view-this-url()
  w3m-mouse-safe-view-this-url((mouse-2 (#<window 1388 on *Article*> 436 (111 . 209) -81415166 nil 436 (18 . 16) nil (3 . 1) (6 . 13))))
  call-interactively(w3m-mouse-safe-view-this-url)

The reason is this code in w3m-safe-view-this-url:

     (url (or (when (fboundp w3m-goto-article-function)
		(funcall w3m-goto-article-function url))

So to make this work I had to make a new defun and then setq
w3m-goto-article-function to that.  Using an anonymous function won't
work, due to the fboundp.

I didn't look to see whether your patch here fixed this problem or
not, I just thought I'd post in case anybody else is trying to set
things up this way.

>> If you do all your browsing in Emacs then you probably already have
>> browse-url-browser-function set as you like...

Katsumi> I leave all those as the default and have no problem (Firefox
Katsumi> happens to be used by default).  I don't always necessarily use
Katsumi> emacs-w3m.   I use Firefox when purchasing something, manipulating
Katsumi> my bank account... ;-)

Ok.  I suppose this response means you are not swayed by my argument
that users should only have to customize in a single place.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-12 16:05               ` Tom Tromey
@ 2007-07-12 18:19                 ` Stefan Monnier
  2007-07-12 22:42                   ` Katsumi Yamaoka
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2007-07-12 18:19 UTC (permalink / raw)
  To: tromey; +Cc: Katsumi Yamaoka, ding, emacs-devel

>   fboundp((lambda (url) (browse-url url) t))

The code should use `functionp' instead of `fboundp'.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Patch to change mouse binding for html view in gnus
  2007-07-12 18:19                 ` Stefan Monnier
@ 2007-07-12 22:42                   ` Katsumi Yamaoka
  0 siblings, 0 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2007-07-12 22:42 UTC (permalink / raw)
  To: tromey; +Cc: ding, emacs-devel

>>>>> Stefan Monnier wrote:

>>   fboundp((lambda (url) (browse-url url) t))

> The code should use `functionp' instead of `fboundp'.

Yup.  I've fixed it about a week ago in the emacs-w3m CVS trunk[1].
Furthermore, I also made a change so that just `browse-url' rather
than such a lambda form for `w3m-goto-article-function' may work[2].

[1] See http://emacs-w3m.namazu.org/index-en.html, or simply get:
    http://cvs.namazu.org/emacs-w3m.tar.gz

[2] http://article.gmane.org/gmane.emacs.devel/74274

>>>>> Tom Tromey wrote:

[...]

Katsumi> I leave all those as the default and have no problem (Firefox
Katsumi> happens to be used by default).  I don't always necessarily use
Katsumi> emacs-w3m.   I use Firefox when purchasing something, manipulating
Katsumi> my bank account... ;-)

> Ok.  I suppose this response means you are not swayed by my argument
> that users should only have to customize in a single place.

That is that at least I am only not motivated to do that.
Neither this represents the emacs-w3m team nor I am a chief of
the team.  You can contact the team at a suitable place, i.e.,
the emacs-w3m mailing list for example.

Regards,

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-07-12 22:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-01 20:42 Patch to change mouse binding for html view in gnus Tom Tromey
2007-07-01 21:48 ` Reiner Steib
2007-07-01 21:43   ` Tom Tromey
2007-07-02  2:59     ` Katsumi Yamaoka
2007-07-02 17:29       ` Tom Tromey
2007-07-03  4:33         ` Katsumi Yamaoka
2007-07-03 17:19           ` Tom Tromey
2007-07-03 23:18             ` Katsumi Yamaoka
2007-07-04  6:10               ` Katsumi Yamaoka
2007-07-12 16:05               ` Tom Tromey
2007-07-12 18:19                 ` Stefan Monnier
2007-07-12 22:42                   ` Katsumi Yamaoka

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).