Author Topic: Vi emulation and ex-mode  (Read 2184 times)

scottc

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Vi emulation and ex-mode
« on: July 10, 2012, 01:33:12 pm »
Hi,
My understanding is the "ex-mode" in slickedit handles the commands after you type ':' in command-mode.  It handles things like: w (save), q (close file), s (search and replace), etc.
I have the need to always run the same macro after I save my file (called "sync"). They way I see it I have two options:
1. (preferred) When I type :w to save it automatically saves and then calls my macro
2. Record a macro that encapsulates the save and the "sync" into one macro and bind that to an ex-mode command

For #1 I don't know how to make :w do two things (or really anything different then save).  It looks like I have to modify file.e (the save method).  But I think I'm going down a slipperly slope if I do that.
For #2 I don't really want to have to type something like :wf (w for save, f for sync) but that wouldn't be so bad.. but I have no idea how to bind my macro to an "ex-mode" command.  When I type ":" it automatically tells me I'm overriding ex-mode, which breaks things.
ANy help would be appreciated.
Thank you

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6068
  • Hero Points: 467
Re: Vi emulation and ex-mode
« Reply #1 on: July 10, 2012, 01:37:23 pm »
If you write a macro function called "_cbsave_<whatever>" it will get called after the file is saved. Just make sure if doesn't conflict with an existing callback.

scottc

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Vi emulation and ex-mode
« Reply #2 on: July 10, 2012, 01:47:41 pm »
Interesting.  Is it _cb_save_whatever or _cbsave_whatever (the autocomplete seems to list a bunch of _cb_.. options)?
Also, Can I just rename my recorded macro to that?
so..
In vusrmacs.e:
#include "slick.sh"
_command _cb_save_sync() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   _deselect();
   execute('copy-fileid-to-sync','');
}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6068
  • Hero Points: 467
Re: Vi emulation and ex-mode
« Reply #3 on: July 10, 2012, 02:31:25 pm »
The name would have to be _cbsave_sync to be found. _cbsave_scottc_sync would be more unique though.