Rhonda's Blog                    
 
Mainpage Disclaimer

Wed, 24 Mar 2010

rxvt-unicode Matcher Patch for Bug Numbers

A while ago Ganneff wondered weather it would be possible to make the matcher extension of rxvt-unicode also pick up something like #12345 and turn it into a link into the BTS.

It isn't—or rather, it wasn't. The idea got stuck in my head and invested some time to make it happen. Here is the quick'n'dirty diff to make it happen:

--- /usr/lib/urxvt/perl/matcher.distrib	2009-11-30 06:44:07.000000000 +0100
+++ /usr/lib/urxvt/perl/matcher.rhonda	2010-03-24 23:57:01.000000000 +0100
@@ -3,13 +3,14 @@
 # Author: Tim Pope <rxvt-unicodeNOSPAM@tpope.info>
 
 my $url =
-   qr{
+   qr{(?:
       (?:https?://|ftp://|news://|mailto:|file://|\bwww\.)
       [a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*
       (
          \([a-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27,~#]*\)| # Allow a pair of matched parentheses
          [a-zA-Z0-9\-\@;\/?:&=%\$_+*~]  # exclude some trailing characters (heuristic)
       )+
+      )|\#[0-9]{4,}
    }x;
 
 sub on_user_command {
@@ -145,6 +146,7 @@
          my @begin = @-;
          my @end = @+;
          if (!defined($col) || ($-[0] <= $col && $+[0] >= $col)) {
+            $match =~ s/^#/http:\/\/bugs.debian.org\//;
             if ($launcher !~ /\$/) {
                return ($launcher,$match);
             } else {

The diff is intentionally small so it is clear what is happening here. And it should give ideas for other extensions that one would like to make. I don't consider it though flexible enough to submit it upstream. Enjoy anyway!

/debian | permanent link | Comments: 0

Trackbacks are closed for this story.

Comments are closed for this story.


 
Feeds
If you want to syndicate this blog, feel free to do so.
This list contains the feeds that I follow:

 
Calendar
April
Sun Mon Tue Wed Thu Fri Sat
 
19 20
21 22 23 24 25 26 27
28 29 30        

2024
Months
AprMay Jun
Jul Aug Sep
Oct Nov Dec

 
About
©opyright 1999++ by Rhonda
[rss feed]

[html by vim] [graphics by gimp]

[generated by wml]

[powered by blosxom]