3
#:META:X_RESOURCE:%.:string:autotransform expression
7
selection-autotransform - automatically transform select text
11
This selection allows you to do automatic transforms on a selection
12
whenever a selection is made.
14
It works by specifying perl snippets (most useful is a single C<s///>
15
operator) that modify C<$_> as resources:
17
URxvt.selection-autotransform.0: transform
18
URxvt.selection-autotransform.1: transform
21
For example, the following will transform selections of the form
22
C<filename:number>, often seen in compiler messages, into C<vi +$filename
25
URxvt.selection-autotransform.0: s/^([^:[:space:]]+):(\\d+):?$/vi +$2 \\Q$1\\E\\x0d/
27
And this example matches the same,but replaces it with vi-commands you can
28
paste directly into your (vi :) editor:
30
URxvt.selection-autotransform.0: s/^([^:[:space:]]+(\\d+):?$/:e \\Q$1\\E\\x0d:$2\\x0d/
32
Of course, this can be modified to suit your needs and your editor :)
34
To expand the example above to typical perl error messages ("XXX at
35
FILENAME line YYY."), you need a slightly more elaborate solution:
37
URxvt.selection.pattern-0: ( at .*? line \\d+[,.])
38
URxvt.selection-autotransform.0: s/^ at (.*?) line (\\d+)[,.]$/:e \\Q$1\E\\x0d:$2\\x0d/
40
The first line tells the selection code to treat the unchanging part of
41
every error message as a selection pattern, and the second line transforms
42
the message into vi commands to load the file.
4
47
my ($self, $msg) = @_;
17
for (my $idx = 0; defined (my $res = $self->x_resource ("selection-autotransform.$idx")); $idx++) {
60
for (my $idx = 0; defined (my $res = $self->x_resource ("%.$idx")); $idx++) {
18
61
$res = $self->locale_decode ($res);
19
62
my $transform = eval "sub { $res }";