emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
622 stars 162 forks source link

Company-quickhelp can dump doc into process buffer #842

Closed ldluy closed 5 years ago

ldluy commented 5 years ago

Thank's for this amazing package. Use it every day. My issue: after the latest update help-information is automatically shown in IESS when writing in ESS[R], which is rather annoying.

jabranham commented 5 years ago

I don't think this is an unreasonable default - some people probably like to be writing a script, then quickly pop to help to look something up, then press q which would get back to the script/iESS split.

I've added an example to the manual for how to modify this behavior. Can you check and see if this does what you want:

(setq display-buffer-alist
      '(("*R"
         nil
         (dedicated . t))))
vspinu commented 5 years ago

@ldluy, What do you mean by "help-information is automatically shown in iESS"? Do you mean help buffer is popped on top of ESS[R] buffer or something else? In any case, with default settings help buffer should not cover the iESS buffer when invoked from iESS buffer.

jabranham commented 5 years ago

@vspinu I think they mean if you're in the script buffer, C-c C-v can show help in the window of the process.

ldluy commented 5 years ago

Hi, no the help information is written into iESS. However, I don't think this problem is related to ESS but to auto-complete. I tried to uninstall auto-complete and instead use company. After that I have auto-completion without the problem that help-info is written into iESS.

/daniel

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday 18 February 2019 kl. 12:25, Vitalie Spinu notifications@github.com wrote:

@ldluy, What do you mean by "help-information is automatically shown in iESS"? Do you mean help buffer is popped on top of ESS[R] buffer or something else? In any case, with default settings help buffer should not cover the iESS buffer when invoked from iESS buffer.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jabranham commented 5 years ago

@ldluy oh, I misunderstood completely then.

Can you be more specific? What exactly does the help info look like?

ldluy commented 5 years ago

It is just the help info you get when writing ? followed by the function. By the way I use R. If you want to I can send a screenshot (I replicated this on another computer).

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday 18 February 2019 kl. 20:34, Alex Branham notifications@github.com wrote:

@ldluy oh, I misunderstood completely then.

Can you be more specific? What exactly does the help info look like?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jabranham commented 5 years ago

Hm... Looks like auto-complete hasn't seen any development in 2+ years, and is now archived (https://github.com/auto-complete/auto-complete). I wonder if we should bother fixing this or just obsolete the auto-complete support. WDYT @vspinu ?

vspinu commented 5 years ago

Yes. auto-complete is de-facto not maintained. People are recommended to switch to company-mode.

I think we should obsolete auto-complete support.

lo-zed commented 5 years ago

Hi again (I was the one who opened #846)

I uninstalled auto-complete and installed company and company-quickhelp from melpa, and the exact same thing happens, i.e. help-info is written into iESS. Any idea why?

jabranham commented 5 years ago

I don't use company (or company-quickhelp). @vspinu @lionel- do either of you use those and see this?

lo-zed commented 5 years ago

Update: when I disable quickhelp and use F1 to show the doc the same thing happens, help is written in iESS. Also company doesn't work in ESS-mode if no R process is running (company only starts working when iESS is open)

ashiklom commented 5 years ago

I can confirm this behavior. To reproduce:

  1. Start Emacs, with emacs -q
  2. Initialize packages: M-x package-initialize
  3. Load ESS, company, and company-quickhelp: M-x load-library --> ess, company, company-quickhelp
  4. Open a buffer with an R script: C-x C-f test.R
  5. Launch the R process: M-x R
  6. Enable company-mode and company-quickhelp-mode (M-x company-mode, M-x company-quickhelp-mode)
  7. In the script buffer, type a partial function name (e.g. summ for summary), wait for the completion list to populate, and then select one of the items with the arrow keys. Wait a moment, and the entire contents of the help for that entry will be dumped into the iESS buffer (as opposed to the company-quickhelp popup window, as expected).

Disabling company-quickhelp-mode gets around the problem.

Interestingly, this only happens when completing function names. When completing function arguments, company-quickhelp-mode works exactly as expected.

jabranham commented 5 years ago

OK, I think it should be fixed. Let me know if you still see this behavior after updating (the fix usually rolls out to MELPA in 4-8 hours)

lo-zed commented 5 years ago

I still get the same behaviour with ess-20190222.22 . Function parameter to the correct buffer (*company-documentation*) and any other help to the iESS buffer. screenshot_ess

Edit: something has changed though. I tried auto-complete again and the same happens as with company. The quick help (resp. the help after pressing F1) appears as popup (resp. in the *company-documentation* buffer) but with the previous help message (about intercept in the above picture) and some newlines on top. The new help message still goes into iESS.

jabranham commented 5 years ago

Hm... I can't reproduce that. @ashiklom do you still see this issue?

ashiklom commented 5 years ago

I can no longer reproduce this from a clean Emacs session.

I did hit the error once with my full configuration, but I can't reproduce it. I do sometimes get some weird behavior where company-quickhelp doesn't work at all and company lists argument completions in alphabetical order (rather than argument order) and doesn't put spaces between arguments (e.g. argument= rather than argument =). However, calling M-x revert-buffer fixes this issue and makes everything work exactly as it should. Since I can't reproduce any of this behavior in a clean Emacs session, I'm guessing it's something weird in my own setup.

Thanks for resolving this so quickly! The improvements you've made to ESS over the last few months have been fantastic!

lo-zed commented 5 years ago

This is weird. Even when I try as @ashiklom (with emacs -q, and then load-library, etc.) I still get the same behaviour. Where could the difference be? emacs/company version?

Edit: everything good! I was missing the ESS very last update (20190222.22 -> 20190222.1422) Thank you indeed!! and sorry for the mess.

lo-zed commented 5 years ago

Hi, since a few new updates it started doing it again.

ashiklom commented 5 years ago

So I've been able to reproduce this problem, but it's tricky because it seems to depend on the precise timing with which functions in ESS and/or company-quickhelp (not sure which) are called.

To reproduce, start Emacs with a barebones init file like this (emacs -q -l test.el):

;; -- test.el -----
(package-initialize)
(load-library "ess")
(load-library "company")
(load-library "company-quickhelp")
(global-company-mode)
(company-quickhelp-mode)

Then, open a test R script and type the following, stopping with point at |:

summary(object = stats::|

This should open a menu of completion candidates. Now, use the arrow keys to move through the candidates with a frequency somewhere between 1-2 steps per second. If you time it right, the help documentation will occasionally be dumped into the inferior R buffer.

My guess is that this bug is triggered if the user interrupts the process of generating completion candidates after it has started (i.e. after company-quickhelp-delay) but before it has completed.

This may be a (unfixable) bug in company-quickhelp rather than ess. A possibly related issue is https://github.com/expez/company-quickhelp/issues/31.

jabranham commented 5 years ago

What version of Emacs are you using, and on what OS?

ashiklom commented 5 years ago

OS is macOS High Sierra (10.13.6). Emacs version is the one installed via brew cask emacs:

# brew cask info emacs
emacs: 26.1-2
https://emacsformacosx.com/
/usr/local/Caskroom/emacs/26.1-2 (5 files, 268.7KB)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/emacs.rb

# (emacs-version)
"GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511)) of 2018-05-30"
jabranham commented 5 years ago

So it looks like company-quickhelp--show calls while-no-input, which I bet interrupts the call to ess-command in ess--flush-help-into-current-buffer, which causes the help text to show in the process buffer. There's a similar issue with eldoc in the git master branch of Emacs (#794).

jabranham commented 5 years ago

I just made a change that I believe fixes this; let me know if you still experience it.

ashiklom commented 5 years ago

I think that fixed it. It's always been a little tricky to reproduce, but now there's a little - that shows up next to the *R* buffer name in the minibar (meaning some R code is running in the background?) but the help is never dumped into the buffer. Thanks for the fix! You guys rock 😄

lo-zed commented 5 years ago

Seems like it's working! Thanks a lot. Best