Author Topic: 'alias' eastereggs :)  (Read 9221 times)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
'alias' eastereggs :)
« on: August 12, 2006, 12:57:22 PM »
Hello SlickTeam,

I was going to check the 'alias' macro to somehow support short date format [ddmmyy] for my TODO alias.
Surprisingly there are some eastereggs already built-in !
Please update the help explaining these very useful options.

For all others (for '%\d' only the format descr. is added):
Code: [Select]
%\d           Insert the date - format:dd.mm.yyyy
%\e           Insert the date - format:ddmmyy
%\m<macro>    Execute macro in-place
%\x[+/-]<col> Move cursor to [relative] absolute column

HS2
« Last Edit: August 12, 2006, 03:51:59 PM by hs2 »

Lisa

  • Senior Community Member
  • Posts: 238
  • Hero Points: 24
  • User-friendly geek-speak translator extraordinaire
Re: 'alias' eastereggs :)
« Reply #1 on: August 14, 2006, 01:52:29 PM »
Thanks for pointing these out, hs2. Note that currently there is help for Aliases in two locations in the docs: Edit > Alias Facility, and Options > Aliases - each with different information. We plan to fix this and improve and expand the help for the Alias feature.
 
Here are some others that I don't think aren't currently documented that you may find useful!

Code: [Select]
%\o Current function name with signature
%\f Insert the current file name
%\m <macro> <arg>% -- Call Slick-C macro with optional argument "arg"

- Lisa

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: 'alias' eastereggs :)
« Reply #2 on: August 14, 2006, 06:42:15 PM »
Thanks a lot Lisa - these are also pretty useful !
I must have overlooked them while reverse-engineering alias()  ;)

It's amazing - I discovered quite a lot of 'the world of Slick', but there is so much more ...

HS2

alex

  • Community Member
  • Posts: 64
  • Hero Points: 6
Re: 'alias' eastereggs :)
« Reply #3 on: September 07, 2006, 03:43:18 PM »
By any chance, is there a way to pass a parameter to the alias as an argument to the macro without resorting to selecting the text a la http://community.slickedit.com/index.php?topic=332.0.  E.g., I'd like to do %\m macro_call %(argument)%%, except that doesn't work right.

By way of explanation, I just want to have a macro's return value inserted based on the input of a user.  I'm trying to make a macro that takes a CamelCase class name convert it to THIS_STYLE automatically.  I've written the conversion as a function taking a string and returning a string, and I'd rather not have to include text selection in the alias just to hack around this.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: 'alias' eastereggs :)
« Reply #4 on: September 08, 2006, 01:17:35 PM »
Nesting of '%' tokens is not supported.
I think you need to write your own macro to retrieve the argument and do your conversion.
You may use the cmdline for argument prompting:
Code: [Select]
// simple prompting macro example
_command _str prompt_and_convert_str (_str defarg = '')
{
   _str targ = '';
   targ = prompt ( '', "enter arg:", defarg );
   return ( do_conversion ( targ ) );
}

or rip some code from 'alias.e' (@see build_prompts()) to get a popup.

With this kind of macro (cursor is not moved -> return value is inserted) you could simply use it in your alias:
%\m prompt_and_convert_str DefaultArg% ( I hope ... )

HS2