Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection
@ 2010-11-04 15:49 Chris Parsons
  2010-11-04 17:54 ` Alvaro Herrera
  2010-11-05 10:37 ` Michael Stapelberg
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Parsons @ 2010-11-04 15:49 UTC (permalink / raw)
  To: sup-devel

I know there's been some discussion about opening URLs from e-mails in Sup, and
because many people use Sup via an SSH session, client-side solutions are not
universally useful... but here is a patch that seems to copy a URL on the
currently highlighted line to the X selection buffer. (From there I use Kupfer
http://kaizer.se/wiki/kupfer/ to open the link in a web client.)
Obviously you can do something similar with a mouse but I use a
netbook and try to avoid using the trackpad if I can.

It relies on having the program xsel available in your path.

I've never fiddled in Ruby before so accept my apologies if the lines are
ridiculous, and also if this has been done before by others.

For the reasons I mention (not universal, requires xsel) I don't
expect it to make it into the Sup code base but I put it out here in
case it suits anyone else.
---
 lib/sup/modes/line-cursor-mode.rb |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/sup/modes/line-cursor-mode.rb b/lib/sup/modes/line-cursor-mode.rb
index 1cae994..e65cbee 100644
--- a/lib/sup/modes/line-cursor-mode.rb
+++ b/lib/sup/modes/line-cursor-mode.rb
@@ -8,6 +8,7 @@ class LineCursorMode < ScrollMode
     k.add :cursor_down, "Move cursor down one line", :down, 'j'
     k.add :cursor_up, "Move cursor up one line", :up, 'k'
     k.add :select, "Select this item", :enter
+    k.add :selurl, "Copy URL to selection", 'u'
   end
 
   attr_reader :curpos
@@ -90,6 +91,18 @@ protected
     set_cursor_pos botline - 1 if @curpos > botline - 1
   end
 
+  def selurl
+     regex = /(?:http|https|mailto):\/\/\S+/i
+     this_line = self[curpos][0][1]
+     match = regex.match(this_line)
+     return if not match
+
+     output = pipe_to_process("xsel -i") do |stream|
+        stream.print match
+     end
+     BufferManager.flash "selected url #{match}"
+  end
+
   def cursor_down
     call_load_more_callbacks buffer.content_height if @curpos >= lines - [buffer.content_height/2,1].max
     return false unless @curpos < lines - 1
-- 
1.7.3.2
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


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

* Re: [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection
  2010-11-04 15:49 [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection Chris Parsons
@ 2010-11-04 17:54 ` Alvaro Herrera
  2010-11-05 10:37 ` Michael Stapelberg
  1 sibling, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2010-11-04 17:54 UTC (permalink / raw)
  To: Chris Parsons; +Cc: sup-devel

Excerpts from Chris Parsons's message of jue nov 04 12:49:03 -0300 2010:
> I know there's been some discussion about opening URLs from e-mails in Sup, and
> because many people use Sup via an SSH session, client-side solutions are not
> universally useful... but here is a patch that seems to copy a URL on the
> currently highlighted line to the X selection buffer. (From there I use Kupfer
> http://kaizer.se/wiki/kupfer/ to open the link in a web client.)
> Obviously you can do something similar with a mouse but I use a
> netbook and try to avoid using the trackpad if I can.

It seems like this should be more generally doable with a hook.

-- 
Álvaro Herrera <alvherre@alvh.no-ip.org>
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

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

* Re: [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection
  2010-11-04 15:49 [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection Chris Parsons
  2010-11-04 17:54 ` Alvaro Herrera
@ 2010-11-05 10:37 ` Michael Stapelberg
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Stapelberg @ 2010-11-05 10:37 UTC (permalink / raw)
  To: sup-devel

Hi Chris,

Excerpts from Chris Parsons's message of 2010-11-04 16:49:03 +0100:
> I know there's been some discussion about opening URLs from e-mails in Sup, and
> because many people use Sup via an SSH session, client-side solutions are not
> universally useful... but here is a patch that seems to copy a URL on the
Not sure which side you mean with client-side now, but I usually want to open
the URL on the computer I am currently using (not always the side on which sup
is running, but always the side on which my terminal is running). For that, I
use the mark-and-yank plugin for urxvt:

http://www.jukie.net/bart/blog/urxvt-url-yank

Best regards,
Michael
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


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

end of thread, other threads:[~2010-11-05 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-04 15:49 [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection Chris Parsons
2010-11-04 17:54 ` Alvaro Herrera
2010-11-05 10:37 ` Michael Stapelberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox