Skip to content

Add MenuPopupChanged (orig. Qiming Zhao) #4176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

andymass
Copy link

This is a translation of neovim/neovim#9616, which adds an autocmd for when the popup menu item changes during insert completion (and also when the pum is redrawn due to resizing). This is useful e.g., for showing information about the selected item in the cmdline or making text edits during selection. The original author is Qiming Zhao aka. @chemzqm.

@brammool
Copy link
Contributor

The name is very confusing, since MenuPopup is for the right-click popup menu, while this event is for the completion menu, aka PUM. We do have the CompleteDone event, which comes much closer. Can we call it CompleteChanged ?

@andymass
Copy link
Author

There is definitely confusion in the documentation between the two popup menus (PUM vs right click) but I am not certain this autocmd adds to it.

FYI the specific justification for the name MenuPopupChanged was given by @justinmk as follows:

MenuPopupChanged also sounds very similar to MenuPopup which is autocmd for right click. Do we want to change the autocmd to CompleteChanged or CompleteItemChanged instead?

CompleteFoo as already discussed is not appropriate because this event is not completion-related, it is popup-related. The name MenuPopupChanged is intentional and was explained in #9616 (comment) :

Vim has an old event called MenuPopup (grep EVENT_MENUPOPUP in the Vim source) which used to be GUI-only but is now also used for :Termdebug stuff.

So let's name this new event MenuPopupChanged. Like Vim, we'll eventually have the ability for plugins to show an arbitrary popupmenu, so it's not just for "completion".

This autocmd also reacts to resize events, even when the selected item doesn't change, and provides the position/dimensions of the completion PUM.

What do you think?

@justinmk
Copy link
Contributor

The name is very confusing, since MenuPopup is for the right-click popup menu, while this event is for the completion menu, aka PUM

What is the "right-click popup menu" if not a PUM? (actual question, not rhetorical)

@k-takata
Copy link
Member

What is the "right-click popup menu" if not a PUM?

See :help 'mousemodel'. If it is set to "popup" (it is the default of Windows), the popup menu will be shown (on gVim).

@justinmk
Copy link
Contributor

I mean semantically, not technically.

@brammool
Copy link
Contributor

brammool commented Mar 27, 2019 via email

@justinmk
Copy link
Contributor

It matters very little to me what the name is, because all choices so far are suboptimal. MenuPopupChanged was an attempt to read the tea-leaves of Vim design decisions.

This reasoning is bogus. Autocommand events are not there for generic
notifications, they must be as specific as possible.

It is conceivable that plugin authors will also want MenuPopupChanged information for the "right-click menu", not only the "completion menu". Does that mean there will be MenuPopupChanged and CompletionChanged events?

@justinmk
Copy link
Contributor

The "PUM" as it's called internally

It's called PUM externally as well, including for pumvisible(), Pmenu, etc. None of this makes any sense.

@brammool
Copy link
Contributor

brammool commented Mar 27, 2019 via email

@andymass andymass force-pushed the feature-menupopupchanged branch from df59ca7 to 3adf55d Compare March 30, 2019 19:09
@andymass
Copy link
Author

Updated for recent insexpand.c refactor. Replaced MenuPopupChanged with CompleteChanged (Note: I imply no opinion on the naming and do not intend to cause tension between vim and neovim).

@justinmk
Copy link
Contributor

justinmk commented Apr 8, 2019

@brammool once again, d7f246c does not include attribution to the original author nor the Neovim project. That's not how copyright works.

@brammool
Copy link
Contributor

brammool commented Apr 8, 2019 via email

@jamessan
Copy link
Contributor

jamessan commented Apr 9, 2019

Since a pull request is created, the author has explicitly confirmed agreeing with the copyright conditions of the project.

I think you mean the licensing conditions of the project. Since Vim doesn't use a copyright assignment agreement, the author retains copyright. The assumption is that, unless stated otherwise, they're contributing the code under Vim's license.

I do try to mention at least the person who sent the change. Github user names don't make this easier.

For what it's worth, Andy made sure to include the original author's name in both the subject of this PR and the commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants