Skip to content

Commit

Permalink
Add --no-edit-warn option.
Browse files Browse the repository at this point in the history
Related to #513.
  • Loading branch information
gwsw committed Jul 1, 2024
1 parent fc16b70 commit d602455
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* Add --no-paste option (github #523).

* Add --no-edit-warn option (github #513).

* Make TAB complete option name in -- command (github #531).

* Make -R pass through all OSC escape sequences (not just OSC 8)
Expand Down
6 changes: 3 additions & 3 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern int def_search_type;
extern lbool search_wrapped;
extern int no_paste;
extern lbool pasting;
extern int no_edit_warn;
#if SHELL_ESCAPE || PIPEC
extern void *ml_shell;
#endif
Expand Down Expand Up @@ -1941,10 +1942,9 @@ public void commands(void)
error("Cannot edit standard input", NULL_PARG);
break;
}
if (get_altfilename(curr_ifile) != NULL)
if (!no_edit_warn && get_altfilename(curr_ifile) != NULL)
{
error("WARNING: This file was viewed via LESSOPEN",
NULL_PARG);
error("WARNING: This file was viewed via LESSOPEN", NULL_PARG);
}
start_mca(A_SHELL, "!", ml_shell, 0);
/*
Expand Down
2 changes: 2 additions & 0 deletions less.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
Read _N lines from the input file and look for vim modelines.
--mouse
Enable mouse input.
--no-edit-warn
Don't warn when using v command on a file opened via LESSOPEN.
--no-keypad
Don't send termcap keypad init/deinit strings.
--no-histdups
Expand Down
4 changes: 4 additions & 0 deletions less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,10 @@ and on the Windows version of
.IP "\-\-MOUSE"
Like \-\-mouse, except the direction scrolled
on mouse wheel movement is reversed.
.IP "\-\-no-edit-warn"
Don't print a warning message when using the v command
on a file which was opened using a LESSOPEN preprocessor
(see the INPUT PREPROCESSOR section below).
.IP "\-\-no-keypad"
Disables sending the keypad initialization and deinitialization strings
to the terminal.
Expand Down
11 changes: 11 additions & 0 deletions opttbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public int proc_tab; /* Special handling of tab */
public int proc_return; /* Special handling of carriage return */
public int match_shift; /* Extra horizontal shift on search match */
public int no_paste; /* Don't accept pasted input */
public int no_edit_warn; /* Don't warn when editing a LESSOPENed file */
public int stop_on_form_feed; /* Stop scrolling on a line starting with form feed */
public long match_shift_fraction = NUM_FRAC_DENOM/2; /* 1/2 of screen width */
public char intr_char = CONTROL('X'); /* Char to interrupt reads */
Expand Down Expand Up @@ -165,6 +166,8 @@ static struct optname status_line_optname = { "status-line", NULL };
static struct optname header_optname = { "header", NULL };
static struct optname no_paste_optname = { "no-paste", NULL };
static struct optname form_feed_optname = { "form-feed", NULL };
static struct optname no_edit_warn_optname2 = { "no-warn-edit", NULL };
static struct optname no_edit_warn_optname = { "no-edit-warn", &no_edit_warn_optname2 };
static struct optname nonum_headers_optname = { "no-number-headers", NULL };
static struct optname nosearch_headers_optname = { "no-search-headers", NULL };
static struct optname nosearch_header_lines_optname = { "no-search-header-lines", NULL };
Expand Down Expand Up @@ -631,6 +634,14 @@ static struct loption option[] =
NULL
}
},
{ OLETTER_NONE, &no_edit_warn_optname,
BOOL, OPT_OFF, &no_edit_warn, NULL,
{
"Warn when editing a file opened via LESSOPEN",
"Don't warn when editing a file opened via LESSOPEN",
NULL
}
},
{ OLETTER_NONE, &nonum_headers_optname,
BOOL|REPAINT, 0, &nonum_headers, NULL,
{
Expand Down
2 changes: 1 addition & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ v658 6/13/24 Fix double-free in lesskey parser; fix crash using small value
v659 6/20/24 Fix typo in help.
v660 6/24/24 Fix bug in ixerror.
v661 6/29/24 Simpler fix for ixerror bug.
v659.1
v659.1 Add --no-paste; add --no-edit-warn; add TAB for -- command.
*/

char version[] = "659.1x";

0 comments on commit d602455

Please sign in to comment.