aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-15 08:25:23 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-15 08:27:59 +0100
commit749e6f9a50d5570d40c2c5f1ebc3eaceb32776da (patch)
treea6d6d0dafc4fdb4a8f5bea2e6a9c2ea72263a51d
parentd266238916882b4082b3ddbb71941aea5e7d20ef (diff)
downloadvis-749e6f9a50d5570d40c2c5f1ebc3eaceb32776da.tar.gz
vis-749e6f9a50d5570d40c2c5f1ebc3eaceb32776da.tar.xz
vis: remove motion and text objects related to C functions
These do not really belong into the editor core. If desired they could be implemented in Lua instead.
-rw-r--r--config.def.h6
-rw-r--r--main.c36
-rw-r--r--man/vis.118
-rw-r--r--text-motions.c75
-rw-r--r--text-motions.h5
-rw-r--r--text-objects.c31
-rw-r--r--text-objects.h4
-rw-r--r--vis-motions.c16
-rw-r--r--vis-text-objects.c6
9 files changed, 0 insertions, 197 deletions
diff --git a/config.def.h b/config.def.h
index 1849975..670c95c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,10 +26,6 @@ static const KeyBinding bindings_basic[] = {
static const KeyBinding bindings_motions[] = {
{ "|", ACTION(CURSOR_COLUMN) },
- { "]]", ACTION(CURSOR_FUNCTION_END_NEXT) },
- { "[]", ACTION(CURSOR_FUNCTION_END_PREV) },
- { "][", ACTION(CURSOR_FUNCTION_START_NEXT) },
- { "[[", ACTION(CURSOR_FUNCTION_START_PREV) },
{ "[{", ACTION(CURSOR_BLOCK_START) },
{ "]}", ACTION(CURSOR_BLOCK_END) },
{ "[(", ACTION(CURSOR_PARENTHESE_START) },
@@ -111,7 +107,6 @@ static const KeyBinding bindings_textobjects[] = {
{ "ab", ALIAS("a(") },
{ "aB", ALIAS("a{") },
{ "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
- { "af", ACTION(TEXT_OBJECT_FUNCTION_OUTER) },
{ "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
{ "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
{ "as", ACTION(TEXT_OBJECT_SENTENCE) },
@@ -134,7 +129,6 @@ static const KeyBinding bindings_textobjects[] = {
{ "ib", ALIAS("i(") },
{ "iB", ALIAS("i{") },
{ "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
- { "if", ACTION(TEXT_OBJECT_FUNCTION_INNER) },
{ "il", ACTION(TEXT_OBJECT_LINE_INNER) },
{ "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
{ "is", ACTION(TEXT_OBJECT_SENTENCE) },
diff --git a/main.c b/main.c
index 98e8ae5..e5940c5 100644
--- a/main.c
+++ b/main.c
@@ -168,10 +168,6 @@ enum {
VIS_ACTION_CURSOR_PARAGRAPH_NEXT,
VIS_ACTION_CURSOR_SENTENCE_PREV,
VIS_ACTION_CURSOR_SENTENCE_NEXT,
- VIS_ACTION_CURSOR_FUNCTION_START_PREV,
- VIS_ACTION_CURSOR_FUNCTION_END_PREV,
- VIS_ACTION_CURSOR_FUNCTION_START_NEXT,
- VIS_ACTION_CURSOR_FUNCTION_END_NEXT,
VIS_ACTION_CURSOR_BLOCK_START,
VIS_ACTION_CURSOR_BLOCK_END,
VIS_ACTION_CURSOR_PARENTHESE_START,
@@ -303,8 +299,6 @@ enum {
VIS_ACTION_TEXT_OBJECT_BACKTICK_INNER,
VIS_ACTION_TEXT_OBJECT_ENTIRE_OUTER,
VIS_ACTION_TEXT_OBJECT_ENTIRE_INNER,
- VIS_ACTION_TEXT_OBJECT_FUNCTION_OUTER,
- VIS_ACTION_TEXT_OBJECT_FUNCTION_INNER,
VIS_ACTION_TEXT_OBJECT_LINE_OUTER,
VIS_ACTION_TEXT_OBJECT_LINE_INNER,
VIS_ACTION_TEXT_OBJECT_INDENTATION,
@@ -484,26 +478,6 @@ static const KeyAction vis_action[] = {
"Move cursor sentence forward",
movement, { .i = VIS_MOVE_SENTENCE_NEXT }
},
- [VIS_ACTION_CURSOR_FUNCTION_START_PREV] = {
- "cursor-function-start-prev",
- "Move cursor backwards to start of function",
- movement, { .i = VIS_MOVE_FUNCTION_START_PREV }
- },
- [VIS_ACTION_CURSOR_FUNCTION_START_NEXT] = {
- "cursor-function-start-next",
- "Move cursor forwards to start of function",
- movement, { .i = VIS_MOVE_FUNCTION_START_NEXT }
- },
- [VIS_ACTION_CURSOR_FUNCTION_END_PREV] = {
- "cursor-function-end-prev",
- "Move cursor backwards to end of function",
- movement, { .i = VIS_MOVE_FUNCTION_END_PREV }
- },
- [VIS_ACTION_CURSOR_FUNCTION_END_NEXT] = {
- "cursor-function-end-next",
- "Move cursor forwards to end of function",
- movement, { .i = VIS_MOVE_FUNCTION_END_NEXT }
- },
[VIS_ACTION_CURSOR_BLOCK_START] = {
"cursor-block-start",
"Move cursor to the opening curly brace in a block",
@@ -1159,16 +1133,6 @@ static const KeyAction vis_action[] = {
"The whole text content, except for leading and trailing empty lines",
textobj, { .i = VIS_TEXTOBJECT_INNER_ENTIRE }
},
- [VIS_ACTION_TEXT_OBJECT_FUNCTION_OUTER] = {
- "text-object-function-outer",
- "A whole C-like function",
- textobj, { .i = VIS_TEXTOBJECT_OUTER_FUNCTION }
- },
- [VIS_ACTION_TEXT_OBJECT_FUNCTION_INNER] = {
- "text-object-function-inner",
- "A whole C-like function body",
- textobj, { .i = VIS_TEXTOBJECT_INNER_FUNCTION }
- },
[VIS_ACTION_TEXT_OBJECT_LINE_OUTER] = {
"text-object-line-outer",
"The whole line",
diff --git a/man/vis.1 b/man/vis.1
index 6054317..1e8307f 100644
--- a/man/vis.1
+++ b/man/vis.1
@@ -755,27 +755,18 @@ match bracket
.It M
goto middle line of window
.
-.It ]]
-next end of C-like function
-.
.It }
next paragraph
.
.It )
next sentence
.
-.It ][
-next start of C-like function
-.
.It N
repeat last search backwards
.
.It n
repeat last search forward
.
-.It []
-previous end of C-like function
-.
.It [{
previous start of block
.
@@ -794,9 +785,6 @@ previous paragraph
.It "("
previous sentence
.
-.It [[
-previous start of C-like function
-.
.It ;
repeat last to/till movement
.
@@ -873,12 +861,6 @@ entire file content
.It ie
entire file content except for leading and trailing empty lines
.
-.It af
-C-like function definition including immediately preceding comments
-.
-.It if
-C-like function definition only function body
-.
.It al
current line
.
diff --git a/text-motions.c b/text-motions.c
index f5701ae..094395f 100644
--- a/text-motions.c
+++ b/text-motions.c
@@ -511,81 +511,6 @@ size_t text_line_empty_prev(Text *txt, size_t pos) {
return it.pos;
}
-size_t text_function_start_next(Text *txt, size_t pos) {
- size_t a = text_function_end_next(txt, pos);
- size_t b = a;
- char c;
- if (a != pos) {
- Iterator it = text_iterator_get(txt, a);
- while (text_iterator_byte_next(&it, &c) && (c == '\r' || c == '\n'));
- a = it.pos;
- }
- if (b != pos) {
- size_t match = text_bracket_match(txt, b);
- b = match != b ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos;
- }
- if (a <= pos && b <= pos)
- return pos;
- else if (a <= pos)
- return b;
- else if (b <= pos)
- return a;
- else
- return MIN(a, b);
-}
-
-size_t text_function_start_prev(Text *txt, size_t pos) {
- char c;
- size_t apos = text_byte_get(txt, pos, &c) && c == '}' && pos > 0 ? pos - 1 : pos;
- size_t a = text_function_end_next(txt, apos);
- size_t b = text_function_end_prev(txt, pos);
- if (a != apos) {
- size_t match = text_bracket_match(txt, a);
- a = match != a ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos;
- }
- if (b != pos) {
- size_t match = text_bracket_match(txt, b);
- b = match != b ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos;
- }
- if (a >= pos && b >= pos)
- return pos;
- else if (a >= pos)
- return b;
- else if (b >= pos)
- return a;
- else
- return MAX(a, b);
-}
-
-static size_t text_function_end_direction(Text *txt, size_t pos, int direction) {
- size_t start = pos, match;
- if (direction < 0 && pos > 0)
- pos--;
- for (;;) {
- char c[3];
- if (direction > 0)
- match = text_find_next(txt, pos, "\n}");
- else
- match = text_find_prev(txt, pos, "\n}");
- if (text_bytes_get(txt, match, sizeof c, c) != 3 || c[0] != '\n' || c[1] != '}')
- break;
- if (c[2] == '\r' || c[2] == '\n')
- return match+1;
- if (match == pos)
- match += direction;
- pos = match;
- }
- return start;
-}
-
-size_t text_function_end_next(Text *txt, size_t pos) {
- return text_function_end_direction(txt, pos, +1);
-}
-
-size_t text_function_end_prev(Text *txt, size_t pos) {
- return text_function_end_direction(txt, pos, -1);
-}
-
size_t text_block_start(Text *txt, size_t pos) {
Filerange r = text_object_curly_bracket(txt, pos-1);
return text_range_valid(&r) ? r.start-1 : pos;
diff --git a/text-motions.h b/text-motions.h
index a52b778..cca84c1 100644
--- a/text-motions.h
+++ b/text-motions.h
@@ -102,11 +102,6 @@ size_t text_sentence_prev(Text*, size_t pos);
*/
size_t text_paragraph_next(Text*, size_t pos);
size_t text_paragraph_prev(Text*, size_t pos);
-/* Find next/previous start/end of a C like function definition */
-size_t text_function_start_next(Text*, size_t pos);
-size_t text_function_start_prev(Text*, size_t pos);
-size_t text_function_end_next(Text*, size_t pos);
-size_t text_function_end_prev(Text*, size_t pos);
/* A section begins after a form-feed in the first column.
size_t text_section_next(Text*, size_t pos);
size_t text_section_prev(Text*, size_t pos);
diff --git a/text-objects.c b/text-objects.c
index bbf043d..7aa96ec 100644
--- a/text-objects.c
+++ b/text-objects.c
@@ -176,37 +176,6 @@ Filerange text_object_paragraph(Text *txt, size_t pos) {
return r;
}
-static Filerange object_function(Text *txt, size_t pos) {
- size_t start_prev = text_function_start_prev(txt, pos);
- size_t end_next = text_function_end_next(txt, pos);
- size_t start = text_function_start_next(txt, start_prev);
- size_t end = text_function_end_prev(txt, end_next);
- if (start == pos)
- start_prev = pos;
- if (end == pos)
- end_next = pos;
- if (text_function_end_next(txt, start_prev) == end_next &&
- text_function_start_prev(txt, end_next) == start_prev) {
- return text_range_new(start_prev, end_next);
- }
- return text_range_empty();
-}
-
-Filerange text_object_function(Text *txt, size_t pos) {
- Filerange r = object_function(txt, pos);
- if (!text_range_valid(&r))
- return r;
- r.end++;
- return text_range_linewise(txt, &r);
-}
-
-Filerange text_object_function_inner(Text *txt, size_t pos) {
- Filerange r = object_function(txt, pos);
- if (!text_range_valid(&r))
- return r;
- return text_range_new(text_bracket_match(txt, r.end)+1, r.end);
-}
-
static Filerange text_object_bracket(Text *txt, size_t pos, char type) {
char c, open, close;
int opened = 1, closed = 1;
diff --git a/text-objects.h b/text-objects.h
index 5656a8a..b36515f 100644
--- a/text-objects.h
+++ b/text-objects.h
@@ -30,10 +30,6 @@ Filerange text_object_line_inner(Text*, size_t pos);
Filerange text_object_sentence(Text*, size_t pos);
Filerange text_object_paragraph(Text*, size_t pos);
-/* C like function definition */
-Filerange text_object_function(Text*, size_t pos);
-/* inner variant only contains the function body */
-Filerange text_object_function_inner(Text*, size_t pos);
/* these are inner text objects i.e. the delimiters themself are not
* included in the range */
Filerange text_object_square_bracket(Text*, size_t pos);
diff --git a/vis-motions.c b/vis-motions.c
index 02b687d..0a44555 100644
--- a/vis-motions.c
+++ b/vis-motions.c
@@ -472,22 +472,6 @@ const Movement vis_motions[] = {
.txt = text_paragraph_next,
.type = LINEWISE|JUMP,
},
- [VIS_MOVE_FUNCTION_START_PREV] = {
- .txt = text_function_start_prev,
- .type = LINEWISE|JUMP,
- },
- [VIS_MOVE_FUNCTION_START_NEXT] = {
- .txt = text_function_start_next,
- .type = LINEWISE|JUMP,
- },
- [VIS_MOVE_FUNCTION_END_PREV] = {
- .txt = text_function_end_prev,
- .type = LINEWISE|JUMP,
- },
- [VIS_MOVE_FUNCTION_END_NEXT] = {
- .txt = text_function_end_next,
- .type = LINEWISE|JUMP,
- },
[VIS_MOVE_BLOCK_START] = {
.txt = text_block_start,
.type = JUMP,
diff --git a/vis-text-objects.c b/vis-text-objects.c
index 86c9feb..af9aae2 100644
--- a/vis-text-objects.c
+++ b/vis-text-objects.c
@@ -177,12 +177,6 @@ const TextObject vis_textobjects[] = {
[VIS_TEXTOBJECT_INNER_ENTIRE] = {
.txt = text_object_entire_inner,
},
- [VIS_TEXTOBJECT_OUTER_FUNCTION] = {
- .txt = text_object_function,
- },
- [VIS_TEXTOBJECT_INNER_FUNCTION] = {
- .txt = text_object_function_inner,
- },
[VIS_TEXTOBJECT_OUTER_LINE] = {
.txt = text_object_line,
},