win-vind icon indicating copy to clipboard operation
win-vind copied to clipboard

[Feature] listing apps for RESIDENT/NORMAL modes

Open gilbh opened this issue 2 years ago • 14 comments

Hi,

This is a suggestion for making the integration of win-vind in Windows more streamlines. The idea is to filter/define the specific apps in which win-vind will automatically enter RESIDENT mode and with it will automatically enter INSERT mode. This mechanism already works when switching to a vim app, where there is no need for win-vind to work, and it automatically switches to RESIDENT. Having a full control on the apps for which either INSERT / RESIDENT modes are turned on would make it ideal.

I think this would make the ongoing use of win-vind easy and fault-free. For example, I definitely need win-vind to work when I type documents in Microsoft Word, but when not when I switch to Adobe Acrobat and not when I switch to a web browser. When I switch back to Word, it would be ideal to have win-vind automatically turn on in INSERT mode so I can start working with it again. A lot of issues with the <esc> mapping for switching modes would naturally be resolves this way.

The implementation can be simple, with allowing to define a "default" mode for win-vind on entry to an app for which no specific mode was specified, as in:

set default_mode = to_resident

and then allow to define specific apps for specific modes, as in:

set to_insert_apps = [LIST OF APPS]

With the above, easy implementation, I could navigate freely between apps and putting to use win-vind seamlessly.

I hope this makes sense. Let me know your thoughts.

Love win-vind!

Best Gil

gilbh avatar Apr 25 '22 17:04 gilbh

Thanks for the suggestion. This seems to make a lot of sense. The current automatic mode change is terrible, like a toy, so needs to be enhanced.

I have two concerns.

  1. whether each name of applications should be executable name, or full path, etc.
  2. how to represent the listings. For example, in .vimrc notation, we write list something like set fileformats=unix,dos,mac, but in Vim script it is let v=[a, b, c].

In my opinion, it is better to use 1 is a regular expression for the path, and 2 should be the same notation as in .vimrc.

Please let me know your opinion. Thanks.

pit-ray avatar Jun 08 '22 15:06 pit-ray

Great! Thanks for considering this!

As for 1), I actually think that just the exe name would be enough, not only b/c this is more simple to the uninitiated user, but also b/c even multiple instances of the same exe file (in different paths etc.) should have the same behavior for win-vind. So it would keep it simple and make sense.

With 2), I really can't say as I don't know Vim Script (and try not to, as I hear it is a bit of a mess), but how do you deal with listings in .vindrc right now? Or isn't there such a behavior yet?

Best Gil

gilbh avatar Jun 09 '22 17:06 gilbh

Now, let's make 1) an exe name so that it will be recognized as a path if we put / or \\.

With 2), the .vimrc format is used for arrangewin_ignore. ref. https://pit-ray.github.io/win-vind/cheat_sheet/options/

Thanks.

pit-ray avatar Jun 13 '22 15:06 pit-ray

Yes, both of these look good to me!

gilbh avatar Jun 19 '22 00:06 gilbh

+1 great idea.

love win vind. just found it

alexn-s avatar Jun 20 '22 13:06 alexn-s

(#89, #100)

I plan to employ automatic commands using events like Vim. For example, in the following format.

autocmd AppSelect edge to_insert
autocmd AppSelect mspaint.exe to_gui_normal
autocmd AppSelect "C:\Program Files\Mozilla Firefox\firefox.exe" to_resident

pit-ray avatar Jun 20 '22 17:06 pit-ray

Yes, looks great. But is it still possible to list more than one app for one autocmd?

gilbh avatar Jun 20 '22 19:06 gilbh

Also, might add 'AppSelectDefault' for catchall/default mode, for all the apps that are not specified?

gilbh avatar Jun 20 '22 19:06 gilbh

With 'AppSelectDefault' no app should be specified, only the default mode: 'autocmd AppSelectDefault to_insert'

gilbh avatar Jun 20 '22 19:06 gilbh

@gilbh How about using regular expressions like in Vim?

autocmd AppSelect * to_insert
autocmd AppSelect *vim to_resident

pit-ray avatar Jun 21 '22 16:06 pit-ray

I think that is a bit confusing, for the following reasons:

  1. The above two lines are not mutually exclusive: * includes *vim.
  2. The wildcard * could potentially clash with a path specification.
  3. It is unclear how to list multiple items.

I would suggests going with the previous system.

Let me know your thoughts.

best!

gilbh avatar Jun 21 '22 22:06 gilbh

@gilbh After careful consideration, the default value using autocmd AppSelect *was indeed a bad idea. I want Vim users not to have to learn anything new, so I would to avoid the concept of Default as much as possible.

How about the following style command?

" .vindrc
autocmd WinLeave * to_insert
autocmd WinEnter "C:\Program Files\Mozilla Firefox\firefox.exe" to_resident
autocmd WinEnter vim to_resident
autocmd WinEnter notepad.exe to_edi_normal

It is similar to Vim notation.

" .vimrc
autocmd WinLeave * stopinsert
autocmd WinEnter *.txt startinsert

Thanks.

pit-ray avatar Jul 02 '22 14:07 pit-ray

Yes, this looks really good! Thanks for developing this.

gilbh avatar Jul 03 '22 16:07 gilbh

Now then, I'll implement along this policy.

pit-ray avatar Jul 03 '22 16:07 pit-ray

@gilbh @alexn-s Implemented in 5.3.0.

pit-ray avatar Aug 11 '23 16:08 pit-ray

I am testing now 5.3.0 and I have a few questions:

  1. This works:
autocmd AppEnter *notepad* <to_edi_normal>

-- but this doesn't:

autocmd AppEnter notepad.exe <to_edi_normal>

Is this deliberate or a bug?

  1. How to specify multiple apps in one autocmd line?

  2. There is a bug (not sure if always reproducible). From the first time I enter notepad and vind switched to NORMAL, it will happens on any switching, and also on (switching to desktop). I am getting NORMAL switch from that moment onward on any app switch ...

Thanks!!

gilbh avatar Aug 12 '23 12:08 gilbh

@gilbh Thank you for trying this feature.

1, 2.
It was neither a bug nor an intended one, and was not implemented. I will add it in the next version.

3.
This is a bug that only occurs when switching to desktop. I will fix it.

pit-ray avatar Aug 13 '23 13:08 pit-ray

Fixed in v5.4.0

pit-ray avatar Aug 13 '23 17:08 pit-ray