From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.42.180.131 with SMTP id bu3cs53521icb; Thu, 4 Nov 2010 10:11:06 -0700 (PDT) Received: by 10.229.231.3 with SMTP id jo3mr940969qcb.21.1288890665677; Thu, 04 Nov 2010 10:11:05 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id o7si310415qcs.71.2010.11.04.10.11.05; Thu, 04 Nov 2010 10:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@yahoo.co.uk Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 36FE818583B2; Thu, 4 Nov 2010 13:11:05 -0400 (EDT) X-Greylist: delayed 409 seconds by postgrey-1.31 at rubyforge.org; Thu, 04 Nov 2010 11:56:07 EDT Received: from nm1-vm0.bullet.mail.sp2.yahoo.com (nm1-vm0.bullet.mail.sp2.yahoo.com [98.139.91.202]) by rubyforge.org (Postfix) with SMTP id 7393A1858361 for ; Thu, 4 Nov 2010 11:56:07 -0400 (EDT) Received: from [98.139.91.68] by nm1.bullet.mail.sp2.yahoo.com with NNFMP; 04 Nov 2010 15:49:17 -0000 Received: from [98.136.185.46] by tm8.bullet.mail.sp2.yahoo.com with NNFMP; 04 Nov 2010 15:49:17 -0000 Received: from [127.0.0.1] by smtp107.mail.gq1.yahoo.com with NNFMP; 04 Nov 2010 15:49:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1288885757; bh=JK3snf/aSiUW8qDCyMFiFHDtmmZW8h+2P5gGhHAkUdw=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Received:Content-Type:From:To:Subject:Date:Message-Id:User-Agent:Content-Transfer-Encoding; b=d2nMz73zTc3mYLuSOsaDx9/cucsW3buOVAfuXK/zJhCk3J2dgQlupXwTxmYCqD8bZig+432MrIb1DerpH9RY3RFMUqLdlh0D0zvTeipG/Rb2QAJwsmwPq9WVLDamjKm7r6m0mqe7ysFeLP2rXPtECPW+vWq8wUkhzMAVDgO+/H0= X-Yahoo-Newman-Id: 449137.40563.bm@smtp107.mail.gq1.yahoo.com Received: from chris-eee.chrisparsons.me.uk (cjparsons1@131.227.78.32 with login) by smtp107.mail.gq1.yahoo.com with SMTP; 04 Nov 2010 08:49:16 -0700 PDT X-Yahoo-SMTP: lSFROKCswBDqnet5DzTJQ_yxAMq.dCU- X-YMail-OSG: O_ppv.IVM1l3y62hy1lXwbNzbBFm3HqM2yVjAglbFlsvi05 I0wOrvmJQBpF9lxWFp9p3GVKfXSIqGxJxh3Hby0dhIKWFWDc0VlDupNbJawZ G.lut0J8ZNugGB5MqlgtjfzlwsRbI8F9jHz_uD6g.ecVi0bYQHNb2XwoZlur q5PRzwMmwxCcAQyLbtW6lL8dFKlXvuMLeIsRdjJIgnPLWG8RKjlF931ATRPb 0mmbkDGot4.bFsstuwjABq0xPKzmC9z1kHvJPmPrdhUdOFN4ueAATebsAXpG Z.GeAB1RPu_18TINy5C3.OfS1MD4cKbovVEybp8hXo5FH5FKe9nSWog-- X-Yahoo-Newman-Property: ymail-3 Received: by chris-eee.chrisparsons.me.uk (Postfix, from userid 1000) id 3C7DF4FD99; Thu, 4 Nov 2010 15:49:03 +0000 (GMT) From: Chris Parsons To: sup-devel Date: Thu, 04 Nov 2010 15:49:03 +0000 Message-Id: <1288885683-sup-601@chris-eee> User-Agent: Sup/git Subject: [sup-devel] [PATCH] 'u' in thread-view-mode copies URL to X selection X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org 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