Author Topic: Using the alias() function to create new global aliases - How?  (Read 2779 times)

jbezem

  • Community Member
  • Posts: 84
  • Hero Points: 8
Maybe (or probably) I'm overlooking a terribly simple thing, but I'm having a hard time using the alias() function to create a new global alias.

I have several projects in parallel, and use a global alias 'ap' for the project's application path. Now I was creating a macro to switch projects, which included deleting the previous alias using
Code: [Select]
alias('-d ap');, and then setting the new alias.
But no matter what I do, the alias gets created in the *.als file for the extension of the file in the currently active buffer. Only when the buffer is 'fundamental', i.e. with an unknown extension, the alias is created in alias.slk.
The command I used is
Code: [Select]
alias('ap c:\workset');.

Does anyone have an idea what I'm doing wrong?

TIA,

Johan

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Using the alias() function to create new global aliases - How?
« Reply #1 on: March 01, 2012, 08:42:18 am »
Hi Johan,
I think you're better off writing an alias support macro similar to this example to make the global macro more generic.
You could use a workspace env.var retrieved with get_env when switching workspaces.
If you need to trigger on project switches you could use an 'Open' command setting a variable used by the alias-macro e.g. using an add setter macro command.
This also avoids changes to your SE config each time when switching.
HS2

jbezem

  • Community Member
  • Posts: 84
  • Hero Points: 8
Re: Using the alias() function to create new global aliases - How?
« Reply #2 on: March 01, 2012, 12:52:53 pm »
Works like a charm, thanks.
But - even when I resolved my issue - I'd still be interested in using alias() to create a global (directory) alias.
If someone sees what I'm missing, I'd be thankful for a response.

BR,

Johan

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Using the alias() function to create new global aliases - How?
« Reply #3 on: March 01, 2012, 02:40:05 pm »
Try alias('-g ap c:\workset');.
Although '-g' is (currently !) not supported
the 'alias' command always uses the language specific alias file if NO option is specified - if I got it right in alias.e::alias()

Edit: Tested it .. and it doesn't work. 'alias' only support '-d' for now ...

HS2
« Last Edit: March 01, 2012, 02:52:07 pm by hs2 »