[suggestion] add interrupt() to stop event#2834
Closed
mattn wants to merge 9 commits intovim:masterfrom
Closed
Conversation
Contributor
|
Yasuhiro Matsumoto wrote:
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?
I like the idea, but cancelevent() is too specific.
How about a function that works like hitting CTRL-C? It would set
"got_int", which means most operations bail out. We can call it
interrupt().
…--
If you're sending someone Styrofoam, what do you pack it in?
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Member
Author
|
implemented f_interrupt() and added test & doc. |
mattn
commented
Apr 22, 2018
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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?