unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* C-x t N
@ 2021-09-06  8:35 Eli Zaretskii
  2021-09-06 15:22 ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-09-06  8:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

NEWS says:

  *** 'C-x t N' creates a new tab at the specified absolute position.
  It also supports a negative argument.

The doc string says:

  Add a new tab at the absolute position TO-INDEX.
  TO-INDEX counts from 1.  If no TO-INDEX is specified, then add
  a new tab at the position specified by ‘tab-bar-new-tab-to’.
  Negative TO-INDEX counts tabs from the end of the tab bar.

I think the interpretation of the negative values here is
counter-intuitive, because using -1 will add a new tab to the right of
the rightmost tab, and if that's what is meant by "from the end of the
tab bar", then what exactly is "the end of the tab bar" needs to be
explicitly documented.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-06  8:35 C-x t N Eli Zaretskii
@ 2021-09-06 15:22 ` Juri Linkov
  2021-09-06 15:58   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-09-06 15:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> NEWS says:
>
>   *** 'C-x t N' creates a new tab at the specified absolute position.
>   It also supports a negative argument.
>
> The doc string says:
>
>   Add a new tab at the absolute position TO-INDEX.
>   TO-INDEX counts from 1.  If no TO-INDEX is specified, then add
>   a new tab at the position specified by ‘tab-bar-new-tab-to’.
>   Negative TO-INDEX counts tabs from the end of the tab bar.
>
> I think the interpretation of the negative values here is
> counter-intuitive, because using -1 will add a new tab to the right of
> the rightmost tab, and if that's what is meant by "from the end of the
> tab bar", then what exactly is "the end of the tab bar" needs to be
> explicitly documented.

I see you already fixed this by adding this text:

  "and -1 means the new tab will become the last one"

I confirm this is correct.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-06 15:22 ` Juri Linkov
@ 2021-09-06 15:58   ` Eli Zaretskii
  2021-09-06 16:41     ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-09-06 15:58 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> From: Juri Linkov <juri@linkov.net>
> Cc: emacs-devel@gnu.org
> Date: Mon, 06 Sep 2021 18:22:31 +0300
> 
> > NEWS says:
> >
> >   *** 'C-x t N' creates a new tab at the specified absolute position.
> >   It also supports a negative argument.
> >
> > The doc string says:
> >
> >   Add a new tab at the absolute position TO-INDEX.
> >   TO-INDEX counts from 1.  If no TO-INDEX is specified, then add
> >   a new tab at the position specified by ‘tab-bar-new-tab-to’.
> >   Negative TO-INDEX counts tabs from the end of the tab bar.
> >
> > I think the interpretation of the negative values here is
> > counter-intuitive, because using -1 will add a new tab to the right of
> > the rightmost tab, and if that's what is meant by "from the end of the
> > tab bar", then what exactly is "the end of the tab bar" needs to be
> > explicitly documented.
> 
> I see you already fixed this by adding this text:
> 
>   "and -1 means the new tab will become the last one"
> 
> I confirm this is correct.

The text I added just describes what the implementation does, but is
that reasonable?  Any such scheme should make sense, otherwise people
will have trouble memorizing it, will make mistakes, and will only
know how to DTRT after they read the fine print of the doc string.

Here's the problem: if index = 1 means "the first tab", then -1 which
"counts from the end" is not the last one, it's one before that.  The
semantics of -1 being the last one would work if the index of the
first were zero, not 1.  And the fact that the code needs to add 1 and
subtract 1 while handling this tells me that the concept as
implemented is problematic.  I mean this code:

    (let* (...
           (to-index (or (if to-index
                             (if (< to-index 0)
                                 (+ (length tabs) (1+ to-index))
                               (1- to-index)))



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-06 15:58   ` Eli Zaretskii
@ 2021-09-06 16:41     ` Andreas Schwab
  2021-09-06 17:27       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2021-09-06 16:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, Juri Linkov

On Sep 06 2021, Eli Zaretskii wrote:

> Here's the problem: if index = 1 means "the first tab", then -1 which
> "counts from the end" is not the last one, it's one before that.

If indexes are one-based, then -1 is the last.

> The semantics of -1 being the last one would work if the index of the
> first were zero, not 1.

There is no -0, so that doesn't work.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-06 16:41     ` Andreas Schwab
@ 2021-09-06 17:27       ` Eli Zaretskii
  2021-09-09  7:57         ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-09-06 17:27 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel, juri

> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: Juri Linkov <juri@linkov.net>,  emacs-devel@gnu.org
> Date: Mon, 06 Sep 2021 18:41:52 +0200
> 
> On Sep 06 2021, Eli Zaretskii wrote:
> 
> > Here's the problem: if index = 1 means "the first tab", then -1 which
> > "counts from the end" is not the last one, it's one before that.
> 
> If indexes are one-based, then -1 is the last.

It's the last existing one, but we are adding one more.  And adding a
tab at index IDX means all those at IDX and after it move to the right
to free a slot for the new one.  But that's not what we do with tabs
in this case.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-06 17:27       ` Eli Zaretskii
@ 2021-09-09  7:57         ` Juri Linkov
  2021-09-09 11:51           ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-09-09  7:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Andreas Schwab, emacs-devel

>> > Here's the problem: if index = 1 means "the first tab", then -1 which
>> > "counts from the end" is not the last one, it's one before that.
>>
>> If indexes are one-based, then -1 is the last.
>
> It's the last existing one, but we are adding one more.  And adding a
> tab at index IDX means all those at IDX and after it move to the right
> to free a slot for the new one.  But that's not what we do with tabs
> in this case.

-1 defines the position that the moved tab will have after moving.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C-x t N
  2021-09-09  7:57         ` Juri Linkov
@ 2021-09-09 11:51           ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2021-09-09 11:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: schwab, emacs-devel

> From: Juri Linkov <juri@linkov.net>
> Cc: Andreas Schwab <schwab@linux-m68k.org>,  emacs-devel@gnu.org
> Date: Thu, 09 Sep 2021 10:57:09 +0300
> 
> >> > Here's the problem: if index = 1 means "the first tab", then -1 which
> >> > "counts from the end" is not the last one, it's one before that.
> >>
> >> If indexes are one-based, then -1 is the last.
> >
> > It's the last existing one, but we are adding one more.  And adding a
> > tab at index IDX means all those at IDX and after it move to the right
> > to free a slot for the new one.  But that's not what we do with tabs
> > in this case.
> 
> -1 defines the position that the moved tab will have after moving.

And that is the problem, see above.

I get it that you are unconvinced, and will stop arguing, but I still
think this is not a good semantics, if my opinion on these matters
means anything to you.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-09 11:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  8:35 C-x t N Eli Zaretskii
2021-09-06 15:22 ` Juri Linkov
2021-09-06 15:58   ` Eli Zaretskii
2021-09-06 16:41     ` Andreas Schwab
2021-09-06 17:27       ` Eli Zaretskii
2021-09-09  7:57         ` Juri Linkov
2021-09-09 11:51           ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).