vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 5e9c74807e9716b58ee6cfd9b06618098b47364d parent eeb78c3be33a0585bfe07a69a6fcfd3a00b19e08 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 7 Feb 2016 16:04:54 +0100 text-object: introduce text_object_filename Diffstat:
| M | text-objects.c | | | 15 | +++++++++++++++ |
| M | text-objects.h | | | 1 | + |
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/text-objects.c b/text-objects.c @@ -325,6 +325,21 @@ Filerange text_object_number(Text *txt, size_t pos) { return r; } +static int is_filename_boundary(int c) { + switch (c) { + case ';': case ':': case '|': + case '"': case '\'': + case '<': case '>': + return true; + default: + return isspace(c); + } +} + +Filerange text_object_filename(Text *txt, size_t pos) { + return text_object_range(txt, pos, is_filename_boundary); +} + Filerange text_range_linewise(Text *txt, Filerange *rin) { Filerange rout = *rin; rout.start = text_line_begin(txt, rin->start); diff --git a/text-objects.h b/text-objects.h @@ -47,6 +47,7 @@ Filerange text_object_backtick(Text*, size_t pos); Filerange text_object_range(Text*, size_t pos, int (*isboundary)(int)); /* a number in either decimal, hex or octal format */ Filerange text_object_number(Text*, size_t pos); +Filerange text_object_filename(Text*, size_t pos); /* extend a range to cover whole lines */ Filerange text_range_linewise(Text*, Filerange*);