nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 124b41acdb61a634832ba78a70849b20d372838b
parent 2ce71a1332a8f2215056f2a03f311aa18f2fa363
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 30 Jun 2025 16:23:32 +0200

new feature: interpret a line number prefixed with ++ or -- as relative

This permits jumping a precise number of lines forward or backward.

Inspired-by: Brian Sandro <email@bsandro.tech>

Diffstat:
Msrc/search.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c @@ -774,6 +774,7 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer, int response = do_prompt(MGOTOLINE, retain_answer ? answer : "", NULL, /* TRANSLATORS: This is a prompt. */ edit_refresh, _("Enter line number, column number")); + int doublesign = 0; /* If the user cancelled or gave a blank answer, get out. */ if (response < 0) { @@ -792,11 +793,18 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer, if (response > 0) return; + /* A ++ or -- before the number signifies a relative jump. */ + if ((answer[0] == '+' && answer[1] == '+') || (answer[0] == '-' && answer[1] == '-')) + doublesign = 1; + /* Try to extract one or two numbers from the user's response. */ - if (!parse_line_column(answer, &line, &column)) { + if (!parse_line_column(answer + doublesign, &line, &column)) { statusline(AHEM, _("Invalid line or column number")); return; } + + if (doublesign) + line += openfile->current->lineno; } else { if (line == 0) line = openfile->current->lineno;