unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: emacs-devel@gnu.org
Subject: Re: C-x t N
Date: Mon, 06 Sep 2021 18:58:30 +0300	[thread overview]
Message-ID: <83v93dr909.fsf@gnu.org> (raw)
In-Reply-To: <87lf49j0ww.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 06 Sep 2021 18:22:31 +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	other threads:[~2021-09-06 15:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83v93dr909.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).