Skip to content

[suggestion] add interrupt() to stop event#2834

Closed
mattn wants to merge 9 commits intovim:masterfrom
mattn:cancelevent
Closed

[suggestion] add interrupt() to stop event#2834
mattn wants to merge 9 commits intovim:masterfrom
mattn:cancelevent

Conversation

@mattn
Copy link
Member

@mattn mattn commented Apr 21, 2018

In current implementation, we can't stop writing file in BufWritePre without send throw. For example, if we can to avoid typo of filename to write, no way to stop writing.

au BufWritePre * if expand('<amatch>:t') == ']' | throw "oops!!!!!!!!!!" | endif

I know that the policy of vim is that use BufWriteCmd to checks for mistakes in filenames and quit with error messages (without writing the file). But I do not think this is seamless. The implementation we should have is to be able to cancel the event. So I want to suggest this PR that add cancelevent(). This function can cancel XxxxxxPre event. This is similar to typing CTRL-C. And this function do nothing if it is callied in non-event function.

How do you think?

@brammool
Copy link
Contributor

brammool commented Apr 21, 2018 via email

@mattn
Copy link
Member Author

mattn commented Apr 22, 2018

implemented f_interrupt() and added test & doc.

@codecov-io
Copy link

codecov-io commented Apr 22, 2018

Codecov Report

Merging #2834 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2834      +/-   ##
==========================================
- Coverage   81.66%   81.66%   -0.01%     
==========================================
  Files         126      126              
  Lines      146182   146184       +2     
==========================================
- Hits       119378   119376       -2     
- Misses      26804    26808       +4
Impacted Files Coverage Δ
src/ex_eval.c 78.01% <ø> (ø) ⬆️
src/evalfunc.c 90.61% <100%> (ø) ⬆️
src/gui_beval.c 62.5% <0%> (-0.87%) ⬇️
src/if_xcmdsrv.c 85.81% <0%> (-0.36%) ⬇️
src/gui_gtk_x11.c 58.11% <0%> (-0.3%) ⬇️
src/gui.c 63.7% <0%> (-0.06%) ⬇️
src/term.c 79.17% <0%> (-0.06%) ⬇️
src/window.c 87.55% <0%> (-0.04%) ⬇️
src/terminal.c 81.92% <0%> (+0.03%) ⬆️
src/viminfo.c 75.65% <0%> (+0.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 410e98a...fa15123. Read the comment docs.

@mattn mattn changed the title [suggestion] add cancelevent() to stop event [suggestion] add interrupt() to stop event Feb 6, 2019
@brammool brammool closed this in 67a2deb Nov 24, 2019
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 3, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 3, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 5, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 9, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 12, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 15, 2020
Problem:    Not so easy to interrupt a script programatically.
Solution:   Add the interrupt() function. (Yasuhiro Matsumoto, closes vim/vim#2834)
vim/vim@67a2deb
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.

3 participants