Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* How to copy URL's to clipboard?
@ 2007-07-10 13:13 Svend Tollak Munkejord
  2007-07-10 22:16 ` Katsumi Yamaoka
  0 siblings, 1 reply; 11+ messages in thread
From: Svend Tollak Munkejord @ 2007-07-10 13:13 UTC (permalink / raw)
  To: info-gnus-english

Hi,

Sometimes I receive html e-mails with external links (of the type
"click here", not "http://www...") in them, and for one reason or
another, w3m is not always the ideal way of displaying them. Then it
would be nice to be able copy the URL to the clipboard, and paste the
address into a browser. How can this be done? The URL is shown in the
echo area when I move the cursor over the link, but I can't get at
it...

I use the 1 May edition of No Gnus and GNU Emacs, and I have

(setq mm-text-html-renderer 'w3m)
(setq mm-inline-text-html-renderer 'w3m)
(setq mm-inline-text-html-with-images t)
(setq browse-url-browser-function 'w3m-browse-url)

in ~/.gnus


Regards,
-- 
Svend Tollak Munkejord 

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

* Re: How to copy URL's to clipboard?
  2007-07-10 13:13 How to copy URL's to clipboard? Svend Tollak Munkejord
@ 2007-07-10 22:16 ` Katsumi Yamaoka
  2007-07-11  6:51   ` Svend Tollak Munkejord
  2007-07-11 15:31   ` Hadron
  0 siblings, 2 replies; 11+ messages in thread
From: Katsumi Yamaoka @ 2007-07-10 22:16 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Svend Tollak Munkejord wrote:

> Sometimes I receive html e-mails with external links (of the type
> "click here", not "http://www...") in them, and for one reason or
> another, w3m is not always the ideal way of displaying them. Then it
> would be nice to be able copy the URL to the clipboard, and paste the
> address into a browser. How can this be done? The URL is shown in the
> echo area when I move the cursor over the link, but I can't get at
> it...

Try the `u' command on the link in the article buffer.  If you
use the Info-like keymap, use the `Y' command instead.  This key
is bound to `w3m-print-this-url', which copies a url of the link
into the kill ring.

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

* Re: How to copy URL's to clipboard?
  2007-07-10 22:16 ` Katsumi Yamaoka
@ 2007-07-11  6:51   ` Svend Tollak Munkejord
  2007-07-11 15:31   ` Hadron
  1 sibling, 0 replies; 11+ messages in thread
From: Svend Tollak Munkejord @ 2007-07-11  6:51 UTC (permalink / raw)
  To: info-gnus-english

On 2007-07-11, Katsumi Yamaoka wrote:

>>>>>> Svend Tollak Munkejord wrote:
>
>> Sometimes I receive html e-mails with external links (of the type
>> "click here", not "http://www...") in them, and for one reason or
>> another, w3m is not always the ideal way of displaying them. Then it
>> would be nice to be able copy the URL to the clipboard, and paste the
>> address into a browser. How can this be done? The URL is shown in the
>> echo area when I move the cursor over the link, but I can't get at
>> it...
>
> Try the `u' command on the link in the article buffer.  If you
> use the Info-like keymap, use the `Y' command instead.  

Ah, thank you!

> This key is bound to `w3m-print-this-url', which copies a url of the
> link into the kill ring.

I see. I searched only for "w3m" and then "copy", so I missed it.

Regards,
-- 
Svend Tollak Munkejord 

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

* Re: How to copy URL's to clipboard?
  2007-07-10 22:16 ` Katsumi Yamaoka
  2007-07-11  6:51   ` Svend Tollak Munkejord
@ 2007-07-11 15:31   ` Hadron
  2007-07-11 22:49     ` Katsumi Yamaoka
  1 sibling, 1 reply; 11+ messages in thread
From: Hadron @ 2007-07-11 15:31 UTC (permalink / raw)
  To: info-gnus-english

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Svend Tollak Munkejord wrote:
>
>> Sometimes I receive html e-mails with external links (of the type
>> "click here", not "http://www...") in them, and for one reason or
>> another, w3m is not always the ideal way of displaying them. Then it
>> would be nice to be able copy the URL to the clipboard, and paste the
>> address into a browser. How can this be done? The URL is shown in the
>> echo area when I move the cursor over the link, but I can't get at
>> it...
>
> Try the `u' command on the link in the article buffer.  If you
> use the Info-like keymap, use the `Y' command instead.  This key
> is bound to `w3m-print-this-url', which copies a url of the link
> into the kill ring.

What would be very nice is a piece of code to recognise when the point
is on a "hidden" url like an html link and then extract the url
automatically, else just the text url.

The one can bind the same key to browse-url-firefox passing the url as
an argument.


-- 

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

* Re: How to copy URL's to clipboard?
  2007-07-11 15:31   ` Hadron
@ 2007-07-11 22:49     ` Katsumi Yamaoka
  2007-07-12  9:34       ` Hadron
  0 siblings, 1 reply; 11+ messages in thread
From: Katsumi Yamaoka @ 2007-07-11 22:49 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Hadron wrote:

> What would be very nice is a piece of code to recognise when the point
> is on a "hidden" url like an html link and then extract the url
> automatically, else just the text url.

> The one can bind the same key to browse-url-firefox passing the url as
> an argument.

Er, although it might not be what you'd like to do, by setting
`w3m-goto-article-function' to `browse-url-firefox' (or `browse-url'),
you can use Firefox (or the browser that `browse-url-default-browser'
chooses automatically) to browse the url of a link in the article
buffer by typing the <RET> key there.  This is handled much better
in the most recent emacs-w3m[1] that is under development.

By the way, for the reason that the <RET> key is bound to
`w3m-safe-view-this-url' which browses only `cid:...' urls by
default, see: (info "(emacs-w3m)Gnus") <- type `C-x C-e' here.

[1] You can download it from the emacs-w3m CVS server as an
    anonymous user, or simply download the tarball from:
    http://cvs.namazu.org/emacs-w3m.tar.gz?view=tar

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

* Re: How to copy URL's to clipboard?
  2007-07-11 22:49     ` Katsumi Yamaoka
@ 2007-07-12  9:34       ` Hadron
  2007-07-12 11:18         ` Katsumi Yamaoka
  0 siblings, 1 reply; 11+ messages in thread
From: Hadron @ 2007-07-12  9:34 UTC (permalink / raw)
  To: info-gnus-english

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Hadron wrote:
>
>> What would be very nice is a piece of code to recognise when the point
>> is on a "hidden" url like an html link and then extract the url
>> automatically, else just the text url.
>
>> The one can bind the same key to browse-url-firefox passing the url as
>> an argument.
>
> Er, although it might not be what you'd like to do, by setting
> `w3m-goto-article-function' to `browse-url-firefox' (or `browse-url'),
> you can use Firefox (or the browser that `browse-url-default-browser'
> chooses automatically) to browse the url of a link in the article
> buffer by typing the <RET> key there.  This is handled much better
> in the most recent emacs-w3m[1] that is under development.

No, since then I would lose the ability to browse with the enter key
still in w3m. Or do I misunderstand?

To recap : I would like another w3m function which allows me to
"browse-url" (and thus firefox)  for an embedded link. Or is it already
there?

At the moment I "print url" and then paste it into browse-url


>
> By the way, for the reason that the <RET> key is bound to
> `w3m-safe-view-this-url' which browses only `cid:...' urls by
> default, see: (info "(emacs-w3m)Gnus") <- type `C-x C-e' here.
>
> [1] You can download it from the emacs-w3m CVS server as an
>     anonymous user, or simply download the tarball from:
>     http://cvs.namazu.org/emacs-w3m.tar.gz?view=tar

-- 

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

* Re: How to copy URL's to clipboard?
  2007-07-12  9:34       ` Hadron
@ 2007-07-12 11:18         ` Katsumi Yamaoka
  2007-07-12 12:33           ` Hadron
  0 siblings, 1 reply; 11+ messages in thread
From: Katsumi Yamaoka @ 2007-07-12 11:18 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Hadron wrote:

> To recap : I would like another w3m function which allows me to
> "browse-url" (and thus firefox)  for an embedded link. Or is it already
> there?

Try adding the following snippets to your ~/.emacs-w3m.el file:

--8<---------------cut here---------------start------------->8---
(defun my-w3m-view-this-url-with-firefox ()
  "View the URL of the link under point using Firefox."
  (interactive)
  (let ((w3m-goto-article-function 'browse-url-firefox))
    (w3m-safe-view-this-url)))

(define-key w3m-minor-mode-map "vv" 'my-w3m-view-this-url-with-firefox)
--8<---------------cut here---------------end--------------->8---

You can change the `vv' key as you like, but it is a good idea to
use `v'-prefixed keys since Gnus reserves them for user's commands.

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

* Re: How to copy URL's to clipboard?
  2007-07-12 11:18         ` Katsumi Yamaoka
@ 2007-07-12 12:33           ` Hadron
  2007-07-12 23:24             ` Katsumi Yamaoka
  0 siblings, 1 reply; 11+ messages in thread
From: Hadron @ 2007-07-12 12:33 UTC (permalink / raw)
  To: info-gnus-english

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Hadron wrote:
>
>> To recap : I would like another w3m function which allows me to
>> "browse-url" (and thus firefox)  for an embedded link. Or is it already
>> there?
>
> Try adding the following snippets to your ~/.emacs-w3m.el file:
>
> (defun my-w3m-view-this-url-with-firefox ()
>   "View the URL of the link under point using Firefox."
>   (interactive)
>   (let ((w3m-goto-article-function 'browse-url-firefox))
>     (w3m-safe-view-this-url)))
>
> (define-key w3m-minor-mode-map "vv" 'my-w3m-view-this-url-with-firefox)
>
> You can change the `vv' key as you like, but it is a good idea to
> use `v'-prefixed keys since Gnus reserves them for user's commands.

Thanks, but is it possible for this function to also work for real
"visible" links e.g

"follow this link : http://www.bbc.co.com" ?

This is the ideal thing - then I have one "browse with firefox" key for
both link types. I assume the code would first check if its a visible
link and if not then assume a hidden link processable with
w3m-safe-view-this-url.

Also, whats the "vv" key? If I hit v, it invokes the usual w3m-bookmark
with the first v.

Thanks for your feedback.

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

* Re: How to copy URL's to clipboard?
  2007-07-12 12:33           ` Hadron
@ 2007-07-12 23:24             ` Katsumi Yamaoka
  2007-07-13  4:24               ` Katsumi Yamaoka
  0 siblings, 1 reply; 11+ messages in thread
From: Katsumi Yamaoka @ 2007-07-12 23:24 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Hadron wrote:

> Thanks, but is it possible for this function to also work for real
> "visible" links e.g

> "follow this link : http://www.bbc.co.com" ?

That function can be used in only areas that are rendered by
emacs-w3m in the article buffer.  There the `w3m-minor-mode-map'
keymap lives and it hides the `gnus-article-mode-map' keymap.
For such a link expressed with a plain text, you can bind the
same key to just the function `browse-url-firefox'.  For example:

(eval-after-load "gnus-art"
  '(progn
     (define-key gnus-article-mode-map "v" (make-sparse-keymap))
     (define-key gnus-article-mode-map "vv" 'browse-url-firefox)))

If you want to add other commands, say:

(eval-after-load "gnus-art"
  '(progn
     (define-key gnus-article-mode-map "v" (make-sparse-keymap))
     (define-key gnus-article-mode-map "vv" 'browse-url-firefox)
     (define-key gnus-article-mode-map "vx" 'foo)
     (define-key gnus-article-mode-map "vy" 'bar)
     (define-key gnus-article-mode-map "vz" 'baz)))

> Also, whats the "vv" key? If I hit v, it invokes the usual w3m-bookmark
> with the first v.

You seem to have typed the v key in a normal emacs-w3m buffer.
There the `w3m-mode-mep' keymap lives.

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

* Re: How to copy URL's to clipboard?
  2007-07-12 23:24             ` Katsumi Yamaoka
@ 2007-07-13  4:24               ` Katsumi Yamaoka
  2007-07-15 17:16                 ` Hadron
  0 siblings, 1 reply; 11+ messages in thread
From: Katsumi Yamaoka @ 2007-07-13  4:24 UTC (permalink / raw)
  To: info-gnus-english

>>>>> Katsumi Yamaoka wrote:

> For such a link expressed with a plain text, you can bind the
> same key to just the function `browse-url-firefox'.  For example:

I forgot to write the way to map the `vv' key to `browse-url-firefox'
also in emacs-w3m buffers.  Here it is:

--8<---------------cut here---------------start------------->8---
(define-key w3m-mode-map "v" (make-sparse-keymap))
(define-key w3m-mode-map "vb" 'w3m-bookmark-view)
(define-key w3m-mode-map "vv"
  (lambda nil
    (interactive)
    (let* ((w3m-content-type-alist (copy-sequence w3m-content-type-alist))
	   (html (cdr (assoc "text/html" w3m-content-type-alist))))
      (setq w3m-content-type-alist (delq html w3m-content-type-alist))
      (setq html (copy-sequence html))
      ;; Make sure to use Firefox.
      (setcar (nthcdr 2 html) 'browse-url-firefox)
      (push html w3m-content-type-alist)
      (w3m-external-view-this-url))))
--8<---------------cut here---------------end--------------->8---

This should be added to your ~/.emacs-w3m.el file, not anywhere else.
Note that it remaps the key for the `w3m-bookmark-view' command into
`vb'.  I think customizing too much the keymap is not a good idea,
though.  In emacs-w3m buffers, you can use the `M' command instead.

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

* Re: How to copy URL's to clipboard?
  2007-07-13  4:24               ` Katsumi Yamaoka
@ 2007-07-15 17:16                 ` Hadron
  0 siblings, 0 replies; 11+ messages in thread
From: Hadron @ 2007-07-15 17:16 UTC (permalink / raw)
  To: info-gnus-english

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Katsumi Yamaoka wrote:
>
>> For such a link expressed with a plain text, you can bind the
>> same key to just the function `browse-url-firefox'.  For example:
>
> I forgot to write the way to map the `vv' key to `browse-url-firefox'
> also in emacs-w3m buffers.  Here it is:
>
> (define-key w3m-mode-map "v" (make-sparse-keymap))
> (define-key w3m-mode-map "vb" 'w3m-bookmark-view)
> (define-key w3m-mode-map "vv"
>   (lambda nil
>     (interactive)
>     (let* ((w3m-content-type-alist (copy-sequence w3m-content-type-alist))
> 	   (html (cdr (assoc "text/html" w3m-content-type-alist))))
>       (setq w3m-content-type-alist (delq html w3m-content-type-alist))
>       (setq html (copy-sequence html))
>       ;; Make sure to use Firefox.
>       (setcar (nthcdr 2 html) 'browse-url-firefox)
>       (push html w3m-content-type-alist)
>       (w3m-external-view-this-url))))
>
> This should be added to your ~/.emacs-w3m.el file, not anywhere else.
> Note that it remaps the key for the `w3m-bookmark-view' command into
> `vb'.  I think customizing too much the keymap is not a good idea,
> though.  In emacs-w3m buffers, you can use the `M' command instead.

I got what I wanted with this:

,----
| (defun my-w3m-view-this-url()
|   (interactive)
|   (let ((w3m-goto-article-function 'browse-url))
|     (w3m-safe-view-this-url)))
| 
| (global-set-key (quote [f4]) 'browse-url)
| (define-key w3m-mode-map [f4] 'my-w3m-view-this-url)
`----

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

end of thread, other threads:[~2007-07-15 17:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-10 13:13 How to copy URL's to clipboard? Svend Tollak Munkejord
2007-07-10 22:16 ` Katsumi Yamaoka
2007-07-11  6:51   ` Svend Tollak Munkejord
2007-07-11 15:31   ` Hadron
2007-07-11 22:49     ` Katsumi Yamaoka
2007-07-12  9:34       ` Hadron
2007-07-12 11:18         ` Katsumi Yamaoka
2007-07-12 12:33           ` Hadron
2007-07-12 23:24             ` Katsumi Yamaoka
2007-07-13  4:24               ` Katsumi Yamaoka
2007-07-15 17:16                 ` Hadron

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).