Hi Bram and itchyny and List,

2015/3/15(Sun) 7:48:01 UTC+9 Bram Moolenaar:
> Hirohito Higashi wrote:
> 
> > Hi Bram and List,
> > 
> > 2015/3/11(Wed) 15:14:47 UTC+9 h_east:
> > > Hello itchyny and Bram,
> > > 
> > > 2015/3/11(Wed) 10:07:53 UTC+9 itchyny:
> > > > On Wednesday, March 11, 2015 at 6:59:12 AM UTC+9, Bram Moolenaar wrote:
> > > > > Hirohito Higashi wrote:
> > > > > 
> > > > > > Oops, I fixed patch and test :-)
> > > > > > 
> > > > > > (I could not attached patch, I paste Gist.)
> > > > > > https://gist.github.com/h-east/ffabb0cdd589a5f9acd2
> > > > > 
> > > > > Thanks!  I wonder if ":tabmove" should work as documented or that the
> > > > > documentation needs to be adjusted.  Well, the documentation is 
> > > > > already
> > > > > inconsistant, it needs to be fixed anyway.
> > > > > 
> > > > > I suppose that since we have ":0tabmove" to move the tab page to the
> > > > > first position, ":$tabmove" is the most logical to move to the last
> > > > > position.  Then ":tabmove" without argument just moves it right.
> > > > > 
> > > > > I would expect ":.tabmove" to not do anything.  But that's not 
> > > > > actually
> > > > > useful.  So move it to the right, just like ":tabmove"?
> 
> > > > Hello, Bram.
> > > > 
> > > > I agree with the idea that `:.tabmove` should not move the tab page. 
> > > > The command `:.` does
> > > > not move the line, you know. If `:.tabmove` does not move the tabpage, 
> > > > the commands
> > > > `:.tabmove`, `:-tabmove`, `:+tabmove` will be consistent with `:.`, 
> > > > `:-`, `:+`.
> > > > 
> > > > The command `:tabmove` moves the tab page to the last in old Vim (I 
> > > > mean Vim before
> > > > 7.4.530). If you change the behaviour, it breaks backward 
> > > > compatibility. Some users may
> > > > use `:tabmove` in order to move the tab to the last.
> > > 
> > > Indeed. That's right.
> > > 
> > > I consider a specification that is consistent.
> > > 
> > > $ vim -N -u NONE -p 1 2 3 4 5 -c "tabnext"
> > > 
> > > LV : Latest Vim (7.4.658) behavior
> > > 
> > > 1 [2] 3 4 5   " Now tab page status. [ ] is current tab page.
> > >  (1) :tabm        " 1 3 4 5 [2]   Backward compatibility ? LV:OK?
> > >  (2) :.tabm       " 1 [2] 3 4 5   Stay current tab page. LV:NG
> > >  (3) :.+tabm      " 1 3 [2] 4 5   Move to the right one. LV:NG
> > >  (4) :.+1tabm     " Same as above. LV:NG
> > >  (5) :+tabm       " Same as above. LV:NG
> > >  (6) :+1tabm      " Same as above. LV:NG
> > >  (7) :tabm +      " Same as above. LV:NG(E474)
> > >  (8) :tabm +1     " Same as above. LV:OK
> > >  (9) :.-tabm      " [1] 2 3 4 5   Move to the left one.
> > > (10) :.-1tabm     " Same as above
> > > (11) :-tabm       " Same as above. LV:NG
> > > (12) :-1tabm      " Same as above. LV:NG
> > > (13) :tabm -      " Same as above. LV:NG(E474)
> > > (14) :tabm -1     " Same as above. LV:OK
> > > (15) :0tabm       " [2] 1 3 4 5   Move to the first. LV:OK
> > > (16) :tabm 0      " Same as above. LV:OK
> > > (17) :1tabm       " 1 [2] 3 4 5   Move to after tab page 1. LV:NG
> > > (18) :tabm 1      " Same as above. LV:NG
> > > (19) :2tabm       " 1 [2] 3 4 5   Move to after tab page 2. LV:NG
> > > (20) :tabm 2      " Same as above. LV:NG
> > > (21) :3tabm       " 1 3 [2] 4 5   Move to after tab page 3. LV:NG
> > > (22) :tabm 3      " Same as above. LV:NG
> > > (23) :4tabm       " 1 3 4 [2] 5   Move to after tab page 4. LV:NG
> > > (24) :tabm 4      " Same as above. LV:NG
> > > (25) :5tabm       " 1 3 4 5 [2]   Move to the last. LV:OK
> > > (26) :tabm 5      " Same as above. LV:OK
> > > (27) :6tabm       " Same as above. LV:OK
> > > (28) :tabm 6      " Same as above. LV:OK
> > > (29) :$tabm       " Same as above. LV:OK
> > > (30) :tabm $      " Same as above or E474?  LV:OK?
> > > 
> > > Note. (17)~(24) 
> > >   My ideal behavior has been along the document.
> > >     :help :tabm
> > >     > Move the current tab page to after tab page N.
> > > 
> > > What about this?
> > 
> > Bram, May I write a patch in this specification?
> 
> I haven't have time to look into all the variations.  Also, I was
> wondering if something changed when the command line range
> implementation was changed.
> 
> Generally, I think we should keep as much as it was before as makes
> sense, but change the ones that we can all agree on that are wrong.
> Thus for the ones were one or another behavior would be OK, depending on
> a user preference, keep what we have.

I attached patch. Please check this.

Specification is below.

$ vim -N -u NONE -p 1 2 3 4 5 -c "tabnext"

1 [2] 3 4 5   " Now tab page status. [ ] is current tab page.
 (1) :tabm        " 1 3 4 5 [2]   move to last
 (2) :.tabm       " do nothing
 (3) :.+tabm      " 1 3 [2] 4 5   Move to the right
 (4) :.+1tabm     " as above
 (5) :+tabm       " as above
 (6) :+1tabm      " as above
 (7) :tabm +      " as above
 (8) :tabm +1     " as above
 (9) :.-tabm      " [1] 2 3 4 5   Move to the left
(10) :.-1tabm     " as above
(11) :-tabm       " as above
(12) :-1tabm      " as above
(13) :tabm -      " as above
(14) :tabm -1     " as above
(15) :0tabm       " [2] 1 3 4 5   Move to the first
(16) :tabm 0      " as above
(17) :1tabm       " do nothing (already moved)
(18) :tabm 1      " as above
(19) :2tabm       " do nothing (already moved)
(20) :tabm 2      " as above
(21) :3tabm       " 1 3 [2] 4 5   Move to after tab page 3
(22) :tabm 3      " as above
(23) :4tabm       " 1 3 4 [2] 5   Move to after tab page 4
(24) :tabm 4      " as above
(25) :5tabm       " 1 3 4 5 [2]   Move to last tab page
(26) :tabm 5      " as above
(27) :6tabm       " as above
(28) :tabm 6      " as above
(29) :$tabm       " as above
(30) :tabm $      " as above

Best regards,
Hirohito Higashi (a.k.a h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 3bd553b9e4bf runtime/doc/tabpage.txt
--- a/runtime/doc/tabpage.txt	Sat Mar 14 15:35:52 2015 +0100
+++ b/runtime/doc/tabpage.txt	Tue Mar 17 15:09:50 2015 +0900
@@ -202,23 +202,29 @@
 		Move the current tab page to after tab page N.  Use zero to
 		make the current tab page the first one.  Without N the tab
 		page is made the last one. >
+		    :.tabmove	" do nothing
 		    :-tabmove	" move the tab page to the left
-		    :tabmove	" move the tab page to the right
-		    :.tabmove	" as above
-		    :+tabmove	" as above
+		    :+tabmove	" move the tab page to the right
 		    :0tabmove	" move the tab page to the beginning of the tab
 				" list
-		    :$tabmove	" move the tab page to the end of the tab list
-<
+		    :tabmove 0	" as above
+		    :tabmove	" move the tab page to the last
+		    :$tabmove	" as above
+		    :tabmove $	" as above
 
 :tabm[ove] +[N]
 :tabm[ove] -[N]
 		Move the current tab page N places to the right (with +) or to
-		the left (with -).
+		the left (with -). >
+		    :tabmove -	" move the tab page to the left
+		    :tabmove -1	" as above
+		    :tabmove +	" move the tab page to the right
+		    :tabmove +1	" as above
+
 
 Note that although it is possible to move a tab behind the N-th one by using
-:Ntabmove, it is impossible to move it by N places by using :+Ntabmove. For
-clarification what +N means in this context see |[range]|.
+:Ntabmove. And move it by N places by using :+Ntabmove. For clarification what
++N means in this context see |[range]|.
 
 
 LOOPING OVER TAB PAGES:
diff -r 3bd553b9e4bf src/ex_docmd.c
--- a/src/ex_docmd.c	Sat Mar 14 15:35:52 2015 +0100
+++ b/src/ex_docmd.c	Tue Mar 17 15:09:50 2015 +0900
@@ -8145,7 +8145,7 @@
 ex_tabmove(eap)
     exarg_T	*eap;
 {
-    int tab_number = 9999;
+    int tab_number;
 
     if (eap->arg && *eap->arg != NUL)
     {
@@ -8166,19 +8166,38 @@
 	else
 	    p = eap->arg;
 
-	if (p == skipdigits(p))
-	{
-	    /* No numbers as argument. */
-	    eap->errmsg = e_invarg;
-	    return;
-	}
-
-	tab_number = getdigits(&p);
-	if (relative != 0)
-	    tab_number = tab_number * relative + tabpage_index(curtab) - 1;;
+	if (relative == 0)
+	{
+	    if (STRCMP(p, "$") == 0)
+		tab_number = LAST_TAB_NR;
+	    else if (p == skipdigits(p))
+	    {
+		/* No numbers as argument. */
+		eap->errmsg = e_invarg;
+		return;
+	    }
+	    else
+		tab_number = getdigits(&p);
+	}
+	else
+	{
+	    if (*p != NUL)
+		tab_number = getdigits(&p);
+	    else
+		tab_number = 1;
+	    tab_number = tab_number * relative + tabpage_index(curtab);
+	    if (relative == -1)
+		--tab_number;
+	}
     }
     else if (eap->addr_count != 0)
+    {
 	tab_number = eap->line2;
+	if (**eap->cmdlinep == '-')
+	    --tab_number;
+    }
+    else
+	tab_number = LAST_TAB_NR;
 
     tabpage_move(tab_number);
 }
diff -r 3bd553b9e4bf src/testdir/test62.in
--- a/src/testdir/test62.in	Sat Mar 14 15:35:52 2015 +0100
+++ b/src/testdir/test62.in	Tue Mar 17 15:09:50 2015 +0900
@@ -96,30 +96,44 @@
 :"
 :for i in range(9) | tabnew | endfor
 1gt
-Go=tabpagenr()


+:$put =tabpagenr()
 :tabmove 5
-i=tabpagenr()


+:$put =tabpagenr()
+:.tabmove
+:$put =tabpagenr()
+:tabmove -
+:$put =tabpagenr()
+:tabmove +
+:$put =tabpagenr()
 :tabmove -2
-i=tabpagenr()


+:$put =tabpagenr()
 :tabmove +4
-i=tabpagenr()


+:$put =tabpagenr()
 :tabmove
-i=tabpagenr()


+:$put =tabpagenr()
 :tabmove -20
-i=tabpagenr()


+:$put =tabpagenr()
 :tabmove +20
-i=tabpagenr()


+:$put =tabpagenr()
+:0tabmove
+:$put =tabpagenr()
+:$tabmove
+:$put =tabpagenr()
+:tabmove 0
+:$put =tabpagenr()
+:tabmove $
+:$put =tabpagenr()
 :3tabmove
-i=tabpagenr()


+:$put =tabpagenr()
 :7tabmove 5
-i=tabpagenr()


+:$put =tabpagenr()
 :let a='No error caught.'
 :try
 :tabmove foo
 :catch E474
 :let a='E474 caught.'
 :endtry
-i=a

+:$put =a
 :"
 :" Test autocommands
 :tabonly!
diff -r 3bd553b9e4bf src/testdir/test62.ok
--- a/src/testdir/test62.ok	Sat Mar 14 15:35:52 2015 +0100
+++ b/src/testdir/test62.ok	Tue Mar 17 15:09:50 2015 +0900
@@ -9,14 +9,21 @@
 tab drop 2: pass
 tab drop 3: pass
 1
-6
+5
+5
 4
-8
+5
+3
+7
+10
+1
+10
+1
 10
 1
 10
 4
-6
+5
 E474 caught.
 === tab split ===
 WinLeave
diff -r 3bd553b9e4bf src/window.c
--- a/src/window.c	Sat Mar 14 15:35:52 2015 +0100
+++ b/src/window.c	Tue Mar 17 15:09:50 2015 +0900
@@ -4114,18 +4114,26 @@
 }
 
 /*
- * Move the current tab page to before tab page "nr".
+ * Move the current tab page to after tab page "nr".
  */
     void
 tabpage_move(nr)
     int		nr;
 {
-    int		n = nr;
-    tabpage_T	*tp;
+    int		n = 1;
+    tabpage_T	*tp, *tp_dst;
 
     if (first_tabpage->tp_next == NULL)
 	return;
 
+    for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next)
+	++n;
+
+    if (tp == curtab || (nr > 0 && tp->tp_next != NULL && tp->tp_next == curtab))
+	return;
+
+    tp_dst = tp;
+
     /* Remove the current tab page from the list of tab pages. */
     if (curtab == first_tabpage)
 	first_tabpage = curtab->tp_next;
@@ -4140,17 +4148,15 @@
     }
 
     /* Re-insert it at the specified position. */
-    if (n <= 0)
+    if (nr <= 0)
     {
 	curtab->tp_next = first_tabpage;
 	first_tabpage = curtab;
     }
     else
     {
-	for (tp = first_tabpage; tp->tp_next != NULL && n > 1; tp = tp->tp_next)
-	    --n;
-	curtab->tp_next = tp->tp_next;
-	tp->tp_next = curtab;
+	curtab->tp_next = tp_dst->tp_next;
+	tp_dst->tp_next = curtab;
     }
 
     /* Need to redraw the tabline.  Tab page contents doesn't change. */

Raspunde prin e-mail lui