Append command line to @@key alias?

May 20, 2008
12,178
133
Syracuse, NY, USA
Is there a way to append the current command line to an @@key alias (instead of the default insert/overwrite behavior)? For example, alias @@F2=command (?) in such a way that if I type "foo" and then press F2, "command foo" is executed?
 
May 20, 2008
12,178
133
Syracuse, NY, USA
On Wed, 18 May 2011 13:52:46 -0400, rconn <> wrote:

|No. There isn't any variable substitution in key aliases.

It could be just my lack of imagination, but I can't think of a situation where
I'd use an automatic key alias (@@) to insert something into a command line in
progress, at the cursor position, and then execute that command line. That's
how it behaves.

Code:
v:\> alias @@f2 dir

v:\> p:\4Utils\ [F2]
TCC: Unknown command "p:\4Utils\dir"

Does anyone use an @@key alias with a command line in progress? ... have a good
example?

It would seem much more useful to insert at the beginning of the line followed
by a space.
 
May 20, 2008
12,178
133
Syracuse, NY, USA
On Wed, 18 May 2011 14:25:26 -0400, vefatica <> wrote:

|On Wed, 18 May 2011 13:52:46 -0400, rconn <> wrote:
|
||No. There isn't any variable substitution in key aliases.
|
|It could be just my lack of imagination, but I can't think of a situation where
|I'd use an automatic key alias (@@) to insert something into a command line in
|progress, at the cursor position, and then execute that command line. That's
|how it behaves.
|
|
|Code:
|---------
|v:\> alias @@f2 dir
|
|v:\> p:\4Utils\ [F2]
|TCC: Unknown command "p:\4Utils\dir"
|---------
|Does anyone use an @@key alias with a command line in progress? ... have a good
|example?
|
|It would seem much more useful to insert at the beginning of the line followed
|by a space.

Even better ... insertion at the beginning plus full-blown parameter
substitution from the command line in progress.
 

samintz

Scott Mintz
May 20, 2008
1,557
26
Solon, OH, USA
It's useful for things like:

alias @@Alt-F4=exit^n

-Scott

vefatica <> wrote on 05/18/2011 02:25:26 PM:


> It could be just my lack of imagination, but I can't think of a
> situation where
> I'd use an automatic key alias (@@) to insert something into a command
line in

> progress, at the cursor position, and then execute that command line.
That's

> how it behaves.


> Code:
> v:\> alias @@f2 dir
>
> v:\> p:\4Utils\ [F2]
> TCC: Unknown command "p:\4Utils\dir"
> Does anyone use an @@key alias with a command line in progress? ...
> have a good
> example?
>
> It would seem much more useful to insert at the beginning of the line
followed

> by a space.
>
>
 

rconn

Administrator
Staff member
May 14, 2008
12,557
167
It could be just my lack of imagination, but I can't think of a situation where I'd use an automatic key alias (@@) to insert something into a command line in progress, at the cursor position, and then execute that command line. That's how it behaves.

That's how it's always behaved, and that's how people wanted it. It will definitely NOT be changed now!
 
May 20, 2008
12,178
133
Syracuse, NY, USA
On Wed, 18 May 2011 17:03:07 -0400, samintz <> wrote:

|It's useful for things like:
|
|alias @@Alt-F4=exit^n

That wouldn't work in a command line in progress.

Code:
v:\> alias @@Alt-F4
exit


v:\> foo[Alt-F4]
TCC: Unknown command "fooexit"

I use:

Code:
v:\> alias @@Ctrl-F10
@exit

That's [Esc]@exit (to clear the command line and keep it out of the history).

Note I use Gateway "AnyKey" keyboards and there's an F10 right next to the left
Ctrl key.
 
May 20, 2008
12,178
133
Syracuse, NY, USA
On Wed, 18 May 2011 17:05:47 -0400, rconn <> wrote:

|---Quote (Originally by vefatica)---
|It could be just my lack of imagination, but I can't think of a situation where I'd use an automatic key alias (@@) to insert something into a command line in progress, at the cursor position, and then execute that command line. That's how it behaves.
|---End Quote---
|
|That's how it's always behaved, and that's how people wanted it. It will definitely NOT be changed now!

I never dreamed you'd change it. I was just wondering about uses for it in a
command line in progress.
 
May 20, 2008
12,178
133
Syracuse, NY, USA
It'd be easy enough to do in a keystroke plugin, though....

Not hard to do for just the unmodified F keys (code below).

Rex, how does TCC handle checking if a keystroke corresponds to a keystroke alias? ... some kind of a hash table I imagine ... could I kludge access to it?

Code:
int F[13] = {0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12};
for ( INT i=1; i<=12; i++ )
{
    if ( lpKeyInfo->nKey == F[i] )
    {
        WCHAR szAliasName[8], szSave[4096], *pszAlias;
        Sprintf(szAliasName, L"@@F%d", i);
        pszAlias = GetAlias(szAliasName);
        if ( pszAlias != NULL )
        {
            lstrcpy(szSave, lpKeyInfo->pszLine);
            Sprintf(lpKeyInfo->pszLine, L"%s %s", pszAlias, szSave);
            lpKeyInfo->nKey = 13;
            return 0;
        }
    }
}
 
May 20, 2008
3,515
4
Elkridge, MD, USA
A common situation is when you have a command calling a batch file:
xxx p1 p2 ...
and you want to run the debugger, so you want to convert it to:
bdebugger %@search[xxx] p1 p2 ...

This requires a complicated operation, consisting of the following steps:

1/ change edit mode to INSERT
2/ go to beginning of line
3/ insert the string "bdebugger %@search["
4/ go to the end of the first word
5/ insert "]"
6/ go to end of line
7/ insert "<enter>"

Step 6 may not be needed.

It would be nice to have a keystroke alias, or a plugin command invoked by a keystroke alias, to do all this automatically. For now I have a keystroke alias which does step 3 - all else must be done manually.
--
Steve
 
Hallo vefatica,


> Is there a way to append the current command line to an @@key alias
> (instead of the default insert/overwrite behavior)? For example,
> alias @@F2=command (?) in such a way that if I type "foo" and then
> press F2, "command foo" is executed?

Not a straightforward one. But I see that @READSCR still exists, which
would allow to put your cmdline intoa var and append t his to your
alias...

Clumsy, I know.

herzliche Grüße,

Klaus Meinhard
 
Nov 2, 2009
302
6
Chile
www.farah.cl
Does anyone use an @@key alias with a command line in progress? ... have a good example?

There's something that, while it's not the exact same thing, it's technically close:

On Unix shells, typing ^L will clear the screen while keeping in the command line whatever has been typed. I have an @@^L=cls alias, but it doesn't work the same way (something that drives me, the detailed-obsessed maniac, nuts).

I'd love to be able to clear the screen in this manner in TCC.
 

Similar threads