vi: implement :p (go to previous file)
[busybox-power] / debian / patches / 0001-vi-implement-p-go-to-previous-file.patch
1 From 0221708f0f7147c84c8f7288e9c510241d296a4c Mon Sep 17 00:00:00 2001
2 From: Dennis Groenen <tj.groenen@gmail.com>
3 Date: Sun, 22 Jan 2012 20:15:21 +0100
4 Subject: [PATCH] vi: implement :p (go to previous file)
5
6 ---
7  editors/vi.c |    8 ++++++++
8  1 files changed, 8 insertions(+), 0 deletions(-)
9
10 diff --git a/editors/vi.c b/editors/vi.c
11 index 4a2d5d4..ddca9d6 100644
12 --- a/editors/vi.c
13 +++ b/editors/vi.c
14 @@ -1111,6 +1111,7 @@ static void colon(char *buf)
15                 Hit_Return();
16         } else if (strncmp(cmd, "quit", i) == 0 // quit
17                 || strncmp(cmd, "next", i) == 0 // edit next file
18 +               || strncmp(cmd, "prev", i) == 0 // edit previous file
19         ) {
20                 int n;
21                 if (useforce) {
22 @@ -1137,6 +1138,13 @@ static void colon(char *buf)
23                         status_line_bold("No more files to edit");
24                         goto ret;
25                 }
26 +               // are there previous files to edit
27 +               if (*cmd == 'p' && optind <= 1) {
28 +                       status_line_bold("No previous files to edit");
29 +                       goto ret;
30 +               } else if (*cmd == 'p' && optind > 1) {
31 +                       optind = optind - 2;
32 +               }
33                 editing = 0;
34         } else if (strncmp(cmd, "read", i) == 0) {      // read file into text[]
35                 fn = args;
36 -- 
37 1.7.8.4
38