Author Topic: How to call macro from everywhere  (Read 930 times)

at5dapa1

  • Senior Community Member
  • Posts: 285
  • Hero Points: 24
How to call macro from everywhere
« on: May 12, 2023, 10:28:31 AM »
I have a small macro for manual tagging:
Code: [Select]
_command project_retag_modal()  name_info(','VSARG2_MACRO|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   project_retag(true);
}
And I did bind it to a key:
Code: [Select]
def  'C-S-T'= project_retag_modal;
It works fine if the focus is in any document tab, but if the focus is in the Preview or References tools it's not called.
Intereseting that it works from some other tools like Build, Output, Find and Replace, but not in others like Backup History, Code Annotations, Find Symbol, Open, Projects...
Any hints how to make it work from anywhere? Thanks!

hs2

  • Senior Community Member
  • Posts: 2762
  • Hero Points: 292
Re: How to call macro from everywhere
« Reply #1 on: May 12, 2023, 11:07:14 AM »
You tell the macro with VSARG2_REQUIRES_EDITORCT that .. it requires an editor control (like edit window, build/output window, etc.)
I think you don't need it at all.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2910
  • Hero Points: 153
Re: How to call macro from everywhere
« Reply #2 on: May 12, 2023, 01:06:29 PM »
It works fine if the focus is in any document tab, but if the focus is in the Preview or References tools it's not called.
Intereseting that it works from some other tools like Build, Output, Find and Replace, but not in others like Backup History, Code Annotations, Find Symbol, Open, Projects...
Any hints how to make it work from anywhere? Thanks!

Things that use Diff (like Backup History), have a built-in table of allowed commands.  I'm afraid it has to be that way for those dialogs.

hs2

  • Senior Community Member
  • Posts: 2762
  • Hero Points: 292
Re: How to call macro from everywhere
« Reply #3 on: May 12, 2023, 01:49:47 PM »
Oh yes - that might be also a showstopper..
@at5dapa1 You could add a command alias (e.g. prm) as commandline 'shortcut'
_command prm, project_retag_modal() ...
in case you like using the commandline :)

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2910
  • Hero Points: 153
Re: How to call macro from everywhere
« Reply #4 on: May 12, 2023, 02:26:33 PM »
The diff things have to keep the number of lines in the buffer balanced, and try to keep undo balanced.

I don't know how much people edit in the diff, I use this a lot when I expand the Compare Dir/Project/Workspace with Git to see the diff.  Places that need a little more documentation or maybe something leftover from debugging really stand out right before a commit.

at5dapa1

  • Senior Community Member
  • Posts: 285
  • Hero Points: 24
Re: How to call macro from everywhere
« Reply #5 on: May 13, 2023, 11:06:10 AM »
Thanks for the answers and for the command alias hint  :)

Here's my use case scenario:
  • I have Preview and References tools docked and active all the time
  • I am in the editor (area 1 in the picture) and trigger a "Find References to ..."
  • The focus moves to References tool (area 2 in the picture): this is expected and fine
  • But sometimes the references are incomplete (sometimes it shows only the current file and the associated header) and I figured out that if I trigger a retagging, then immediately try a new "Find References to ..." then it works fine. But if I try here (when the focus is at 2) the macro will not work, unless I press an ESC: the focus moves to document and try the macro from there where it works
  • Same, if the focus is in Preview tool (area 3 in the picture)

I tried
Code: [Select]
_command prm, project_retag_modal()  name_info(','VSARG2_MACRO|VSARG2_MARK)
or
Code: [Select]
_command prm, project_retag_modal()  name_info(',')
formats, but the same result, not big deal though, hoped that it should be some config which I miss or an easy workaround  ;)