emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-x t N


From: Eli Zaretskii
Subject: Re: C-x t N
Date: Mon, 06 Sep 2021 18:58:30 +0300

> 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]