Author Topic: How to change author and other aliases  (Read 3098 times)

benem

  • Community Member
  • Posts: 6
  • Hero Points: 0
How to change author and other aliases
« on: October 22, 2013, 11:28:06 AM »
Hi

In Slick Edit there is is alias expansion mechanism that works quite well so I can define, for example, a template or a Javadoc that suite my needs and taste.

Anyway I have a problem with the author expansion. For example %\a insert the author name in a alias and $author$ make the same in templates.

The problem is that insert the Windows username that not always is correct. How can I change the name inserted when SE expands %\a or $author$?

Thanks.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: How to change author and other aliases
« Reply #1 on: October 22, 2013, 11:55:29 AM »
Where do you want it to get the author name from?

On the slickedit command line, if you type
fp expand_alias_line
you'll be taken to that function in alias.e
If you look at the %\A option you'll see this code
         case '%\A':
            // Look up author.
            after = getAuthor() :+ after;
            break;

From looking at the getAuthor function you can see it tries to look up the code template for an author setting, otherwise it gets the environment variable USERNAME (on windows).
You can modify the getAuthor function if you're keen or you can use the %\M alias to call a macro of your own that gets the author name from somewhere else.
e.g. %\m MMM 'a'%
(untested)  - MMM is the name of the macro, 'a' is an argument passed to the macro to tell it to return an author string
e.g.
_str MMM(_str args)
{
   switch (args)
   {
      case "a" : return "George";
   }
}
untested - just to give you an idea of how it works.  You could just have a macro dedicated to getting the author though, instead of passing an argument.


benem

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: How to change author and other aliases
« Reply #2 on: October 22, 2013, 12:32:44 PM »
Thank you for the reply.

Put the author name in a configuration file would be perfect. So without change anything is seem (from the getAuthor) that it get the "author" key from some option file name. The problem is which is the configuration file to edit?

How I can show the return value of _ctOptionsGetOptionsFilename(); using the command line?

Thanks.

benem

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: How to change author and other aliases
« Reply #3 on: October 22, 2013, 12:58:04 PM »
I found the answer.

It is not very intuitive as the escape sequence %\a used in Javadoc template is not directly related with the $author$ alias in the templates used to create new files in a projects. And the documentation doesn't help.

Anyway I opened the Template Manager from the File menu and clicked on the Options button.
Then I added a new Global substitution parameter called "author" with my name as value.

Now I have my full name (or whatever I like) in templates and Javadoc.

Thank for your help, without it I would never figure it.