[vim/vim] doc: ":tc" is no longer the abbreviation of ":tcl" (#8258)

35 views
Skip to first unread message

lacygoill

unread,
May 25, 2021, 7:48:05 AM5/25/21
to vim/vim, Subscribed

From :h :tcl:

:tc[l] {cmd} Execute Tcl command {cmd}. A simple check if :tcl
is working: >
:tcl puts "Hello"

:[range]tc[l] << [trim] [{endmarker}]
{script}
{endmarker}
Execute Tcl script {script}.
Note: This command doesn't work when the Tcl feature
wasn't compiled in. To avoid errors, see
|script-here|.

The help says that :tc is the abbreviation of :tcl. That might have been true in the past, but that's no longer the case; now, :tc is the abbreviation of :tcd (introduced in 8.1.1218).

Patch fixing the documentation:

diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index 1351d4e96..ef45e61fb 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1320,8 +1320,8 @@ present in 'cpoptions' and "!" is not used in the command.
 							*:chd* *:chdir*
 :chd[ir][!] [path]	Same as |:cd|.
 
-							*:tcd*
-:tcd[!] {path}		Like |:cd|, but only set the directory for the current
+							*:tc* *:tcd*
+:tc[d][!] {path}	Like |:cd|, but only set the directory for the current
 			tab.  The current window will also use this directory.
 			The current directory is not changed for windows in
 			other tabs and for windows in the current tab that
@@ -1331,7 +1331,7 @@ present in 'cpoptions' and "!" is not used in the command.
 :tch[dir][!]		Same as |:tcd|.
 
 							*:tcd-*
-:tcd[!] -		Change to the previous current directory, before the
+:tc[d][!] -		Change to the previous current directory, before the
 			last ":tcd {path}" command.
 
 							*:lc* *:lcd*
diff --git a/runtime/doc/if_tcl.txt b/runtime/doc/if_tcl.txt
index 90dec9dba..8290f7ba0 100644
--- a/runtime/doc/if_tcl.txt
+++ b/runtime/doc/if_tcl.txt
@@ -25,12 +25,12 @@ comments, ideas etc to <Ingo....@informatik.uni-oldenburg.de>
 ==============================================================================
 1. Commands				*tcl-ex-commands* *E571* *E572*
 
-							*:tcl* *:tc*
-:tc[l] {cmd}		Execute Tcl command {cmd}.  A simple check if `:tcl`
+								*:tcl*
+:tcl {cmd}		Execute Tcl command {cmd}.  A simple check if `:tcl`
 			is working: >
 				:tcl puts "Hello"
 
-:[range]tc[l] << [trim] [{endmarker}]
+:[range]tcl << [trim] [{endmarker}]
 {script}
 {endmarker}
 			Execute Tcl script {script}.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Dominique Pellé

unread,
May 25, 2021, 8:14:13 AM5/25/21
to vim/vim, Subscribed

Good catch. Out of curiosity: did you detect this by luck or do you have an automated way of finding whether the doc is inconsistent with the actual command being run? I wonder whether we'd find other similar discrepancies if we wrote a script to check this.

lacygoill

unread,
May 25, 2021, 8:41:56 AM5/25/21
to vim/vim, Subscribed

did you detect this by luck or do you have an automated way of finding whether the doc is inconsistent with the actual command being run?

I guess it's a bit of both (luck + automated way). I'm rewriting the default Vim syntax plugin to get a better highlighting in Vim9 scripts (e.g. the types are not highlighted). In doing so, I'm trying to build programmatically the command responsible for the vimCommand syntax group. For the moment, this is what I have:

vim9script
def Func(): string
    var cmds: list<string>
    for cmd in getcompletion('', 'command')
              ->filter((_, v: string): bool => v =~ '^[a-z]')
        var l: number
        for len in strcharlen(cmd)->range()->reverse()
            if len == 0
                continue
            endif
            if cmd->slice(0, len)->fullcommand() != cmd
                l = len
                break
            endif
        endfor
        if l == cmd->strcharlen() - 1
            cmds += [cmd]
        else
            cmds += [cmd[: l] .. '[' .. cmd[l + 1 :] .. ']']
        endif
    endfor
    # TODO: Why is `mapclear` in `vimMap` while `vmapclear` is in `vimCommand`?
    var to_remove: list<string> =<< trim END
        a[ppend]
        ab[breviate]
        au[tocmd]
        aug[roup]
        c[hange]
        ca[bbrev]
        cm[ap]
        cno[remap]
        cnorea[bbrev]
        com[mand]
        cu[nmap]
        do[autocmd]
        doautoa[ll]
        echoh[l]
        final
        finall[y]
        g[lobal]
        im[ap]
        hi[ghlight]
        i[nsert]
        ia[bbrev]
        ino[remap]
        inorea[bbrev]
        iu[nmap]
        keepalt
        keepjumps
        keepmarks
        keeppatterns
        let
        lm[ap]
        ln[oremap]
        lu[nmap]
        map
        mapc[lear]
        nm[ap]
        nn[oremap]
        no[remap]
        norea[bbrev]
        norm[al]
        nun[map]
        o[pen]
        om[ap]
        ono[remap]
        ou[nmap]
        s[ubstitute]
        smap
        smapc[lear]
        snor[emap]
        sunm[ap]
        sy[ntax]
        t
        unm[ap]
        v[global]
        vm[ap]
        vn[oremap]
        vu[nmap]
        xm[ap]
        xn[oremap]
        xu[nmap]
    END
    for c in to_remove
        var i: number = cmds->index(c)
        if i == -1
            continue
        endif
        cmds->remove(i)
    endfor
    var missing: list<string> =<< trim END
        addd
        fina[lly]
        in
        kee[pmarks]
        keepa[lt]
        keepj[umps]
        keepp[atterns]
    END
    cmds += missing
    # TODO: Once this issue is fixed:
    # https://github.com/vim/vim/issues/8256#issuecomment-847668403
    # Remove all references to `:keep*` commands from this function.
    return cmds->join()
enddef
echo Func()

To check how reliable the function is, I've diff'ed its output against the command names of the default Vim syntax plugin. In particular, the diff showed this name in the original plugin:

tc[l]
tcd

While my function showed this:

tc[d]
tcl

Since the lines are different, I wanted to know which ones were right, so I ran :tc which prints the tab-local working directory, contradicting the help. There might be a way to automate this kind of check, but I'm not sure.

Bram Moolenaar

unread,
May 27, 2021, 11:47:06 AM5/27/21
to vim/vim, Subscribed


> >From `:h :tcl`:
>
> > :tc[l] {cmd} Execute Tcl command {cmd}. A simple check if `:tcl`
> > is working: >
> > :tcl puts "Hello"
>
> > :[range]tc[l] << [trim] [{endmarker}]
> > {script}
> > {endmarker}
> > Execute Tcl script {script}.
> > Note: This command doesn't work when the Tcl feature
> > wasn't compiled in. To avoid errors, see
> > |script-here|.
>
> The help says that `:tc` is the abbreviation of `:tcl`. That might

> have been true in the past, but that's no longer the case; now, `:tc`
> is the abbreviation of `:tcd` (introduced in
> [8.1.1218](https://github.com/vim/vim/releases/tag/v8.1.1218)).
>
> Patch fixing the documentation:

Thanks, I'll include it. There is also an entry in index.txt, which is
what Charles uses to generate the syntax entries from.

--
The early bird gets the worm. If you want something else for
breakfast, get up later.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
May 27, 2021, 11:47:21 AM5/27/21
to vim/vim, Subscribed

Closed #8258.

Charles Campbell

unread,
May 28, 2021, 11:13:39 AM5/28/21
to vim...@googlegroups.com
lacygoill (Vim Github Repository) wrote:
>
> did you detect this by luck or do you have an automated way of
> finding whether the doc is inconsistent with the actual command
> being run?
>
> I guess it's a bit of both (luck + automated way). I'm rewriting the
> default Vim syntax plugin to get a better highlighting in Vim9 scripts
> (e.g. the types are not highlighted). In doing so, I'm trying to build
> programmatically the command responsible for the |vimCommand| syntax
> group. For the moment, this is what I have:
>
> #TODO: Whyis `mapclear`in `vimMap`while `vmapclear`is in `vimCommand`?
> var to_remove:list<string> =<<trim END
> a[ppend]
>
That's an easy one to explain: I didn't notice it before, and no one
mentioned it. I've adjusted my mkvimvim script to no longer accept
vmapc[lear] and have put it into vimMap. v8.2-05 will have those
changes, and I've uploaded an ASTRO-ONLY version to my website
(http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM).

I wrote a script which generates the first portion of syntax/vim.vim;
generated syntax is based on the documentation. In the case of
vimCommands, it extracts all potential commands and then removes those
which are explicitly mentioned in the second portion (or in one of the
other keyword groups). I do it this way because vim is and has been a
moving target, constantly getting new commands, and Bram is very good at
keeping the documentation up-to-date.

The syntax for vimCommands and other generated syntax makes them
keywords for speed during use and loading of syntax/vim.vim. Its already
> 75K.

Chip Campbell
Reply all
Reply to author
Forward
0 new messages