[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] vi: :wq/:x should warn if there are more files to edit
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2021-05-04 12:55:05
Message-ID: CAK1hOcPtd7WjnviSPNGQAXAKC4s6caZav90_+nA8As=qoKgMWg () mail ! gmail ! com
[Download RAW message or body]
Applied, thank you
On Sat, May 1, 2021 at 2:15 PM Ron Yorston <rmy@pobox.com> wrote:
>
> ':wq' or ':x' should issue a warning if there are more files to edit,
> unless they're followed by '!'.
>
> function old new delta
> colon 3911 3960 +49
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 1/0 up/down: 49/0) Total: 49 bytes
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
> editors/vi.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/editors/vi.c b/editors/vi.c
> index 63c7537c2..65ca13b18 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -3181,9 +3181,20 @@ static void colon(char *buf)
> modified_count = 0;
> last_modified_count = -1;
> }
> - if (cmd[0] == 'x'
> - || cmd[1] == 'q' || cmd[1] == 'n'
> - ) {
> + if (cmd[1] == 'n') {
> + editing = 0;
> + } else if (cmd[0] == 'x' || cmd[1] == 'q') {
> + // are there other files to edit?
> + int n = cmdline_filecnt - optind - 1;
> + if (n > 0) {
> + if (useforce) {
> + // force end of argv list
> + optind = cmdline_filecnt;
> + } else {
> + status_line_bold("%u more file(s) to edit", n);
> + goto ret;
> + }
> + }
> editing = 0;
> }
> }
> --
> 2.31.1
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic