Skip to content
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

Do not change/set switchbuf=useopen #32

Open
blueyed opened this issue Mar 17, 2015 · 4 comments
Open

Do not change/set switchbuf=useopen #32

blueyed opened this issue Mar 17, 2015 · 4 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Mar 17, 2015

It gets set using setlocal, but is a global setting.

https://github.com/fs111/pydoc.vim/blob/master/ftplugin/python_pydoc.vim#L120

@fs111
Copy link
Owner

fs111 commented Apr 20, 2015

we could guard it with a config setting, which is on by default for backwards compatibility. Do you feel like giving that a try?

@blueyed
Copy link
Contributor Author

blueyed commented Apr 20, 2015

I would not add a config option for this: after all this is a config that the user is meant to make (globally).

If it was particular useful in special cases, it could be set/changed using a FileType autocommand for example. The docs could mention how to do this and provide a link to this setting's documentation.

An idea might be to use autocommands to override it when the user enters a pydoc buffer (and restore it), but that's probably not worth it.

@fs111
Copy link
Owner

fs111 commented Apr 21, 2015

It has been like this for roughly 12 years, so it should be backwards compatible IMO

@blueyed
Copy link
Contributor Author

blueyed commented Apr 21, 2015

It has been like this for roughly 12 years, so it should be backwards compatible IMO

You have a point there, but I would consider it to be just an old bug then, especially given that it uses setlocal, while it's a global setting.

It took me quite some effort back then to figure out that pydoc was changing this setting, and I think that more users are being annoyed by this than being helped.

Adding a setting for this just feels wrong, but you could start with the following patch:

diff --git i/ftplugin/python_pydoc.vim w/ftplugin/python_pydoc.vim
index 88d1ebd..f19f7fa 100644
--- i/ftplugin/python_pydoc.vim
+++ w/ftplugin/python_pydoc.vim
@@ -117,7 +117,12 @@ if !exists('g:pydoc_open_cmd')
     let g:pydoc_open_cmd = 'split'
 endif

-setlocal switchbuf=useopen
+" Override `switchbuf` setting by default, unless g:pydoc_no_switchbuf is
+" provided.
+if !exists('g:pydoc_no_switchbuf')
+    set switchbuf=useopen
+endif
+
 highlight pydoc cterm=reverse gui=reverse

 function! s:GetWindowLine(value)

I have just removed this line locally.

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

No branches or pull requests

2 participants