-
-
Notifications
You must be signed in to change notification settings - Fork 226
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
company-auto-update-doc
leaves open the buffer that it used
#1402
Comments
@nemethf What do you think about changing/fixing the behavior to close the doc buffer at the end even when |
@vemv IIUC the issue is not whether the ancillary buffer is destroyed (it won't be), but whether it remains displayed in the window. |
The documentation is helpful to find the right item to select. But often I also consult the documentation after an item has been selected. It helps me to fill out the arguments of a function call, for example. When I'm finished I usually just press However, I understand how the current behavior can annoy others. Maybe a defcustom named something like company-keep-doc-buffer-visible would make everybody happy. Except you, the maintainer, as it would introduce complexity to the code. |
I see. Well, it doesn't have to be a separate var: the current one could grow the value If you do find the current behavior good, I suppose we will live with an extra condition. |
So I can try to prepare a pull request. (But I cannot promise I will be fast.) |
Hmm, good question. What if we used a different value of prefix, such as |
FWIW, I figured that CIDER (the library, not my personal .emacs.d) could perform: (add-hook 'company-after-completion-hook (lambda (_)
(when-let ((b (get-buffer "*cider-doc*")))
(bury-buffer b)))) which I've verified to work. It seems cheap enough (with the caveat that we don't take for granted that Compliment exists - it's an optional library). However it's not exactly clean, as it might bury a previously existing buffer. I do genuinely believe that a good chunk of users would be surprised by the current default behavior, so a generalized fix/option might be well worthwhile. |
That's also what I was thinking. |
and bind it to `M-RET`. Per company-mode#1402.
and bind it to `M-RET`. Per company-mode#1402.
and bind it to `M-RET`. Per company-mode#1402.
In the end, I took a different approach. In the pull request, auto-update-doc always restores the window configuration when company finishes. But I also added a new command that shows the documentation of the selected item after exiting. This seemed more natural than the |
FWIW, it looks reasonable to me. It's the first time I hear of |
I like the suggestion, but I'd prefer a shorter patch. And Regarding the key-binding, though. I'm of the school of thought that believes that diff --git a/company.el b/company.el
index 212ff13..c0e6bb2 100644
--- a/company.el
+++ b/company.el
@@ -1360,9 +1360,6 @@ To toggle the value of this variable, call `company-show-doc-buffer' with a
prefix argument.")
(defun company-call-frontends (command)
- (when (and company-auto-update-doc
- (memq command '(update show)))
- (company-show-doc-buffer))
(cl-loop for frontend in company-frontends collect
(condition-case-unless-debug err
(funcall frontend command)
@@ -2227,7 +2224,10 @@ For more details see `company-insertion-on-trigger' and
(let (company-idle-delay) ; Against misbehavior while debugging.
(company--perform)))
(if company-candidates
- (company-call-frontends 'post-command)
+ (progn
+ (company-call-frontends 'post-command)
+ (when company-auto-update-doc
+ (company-show-doc-buffer)))
(let ((delay (company--idle-delay)))
(and (numberp delay)
(not defining-kbd-macro)
@@ -2641,6 +2641,13 @@ For use in the `select-mouse' frontend action. `let'-bound.")
(let ((result (nth company-selection company-candidates)))
(company-finish result))))
+(defun company-complete-selection-show-doc ()
+ "Insert the selected candidate and show its documentation."
+ (interactive)
+ (company--show-doc-buffer)
+ (company-complete-selection)
+ (setq company--electric-saved-window-configuration nil))
+
(defun company-complete-common ()
"Insert the common part of all candidates."
(interactive)
@@ -2883,10 +2890,8 @@ automatically show the documentation buffer for each selection."
(interactive "P")
(when toggle-auto-update
(setq company-auto-update-doc (not company-auto-update-doc)))
- (if company-auto-update-doc
- (company--show-doc-buffer)
- (company--electric-do
- (company--show-doc-buffer))))
+ (company--electric-do
+ (company--show-doc-buffer)))
(put 'company-show-doc-buffer 'company-keep t)
(defun company-show-location ()
|
There are examples in the Emacs codebase of M-RET. For example, both message-newline-and-reformat or (a bit more relevant here) minibuffer-choose-completion are bound to M-RET. On the other hand, what do you think about binding company-complete-selection-show-doc to C-j. That seems logical and easy to press even in a tty. |
Not much I can do about those. Luckily, the contexts they work in are rare enough.
I like the general direction, but maybe not the exact choice. In Emacs's minibuffer completion, In any case, we don't have to choose the binding right now. Adding the command unbound is also a good option. |
As far as my testing went, this issue is now solved. |
I think we'll keep this one open for now, to finish the discussion of adding the new command (or a different optional behavior). |
I cannot explain it, but I find What do you think about Also, we try to find a binding for company-complete-selection-show-doc, but maybe a company-complete-selection-show-location would be useful as well. Or simply a company-complete-selection-keep-windows. This is a tangent, but I wanted to check the current keybindings of company and the usual
That sounds good as well. Thanks. |
My own bias is that But if some others also really like it, and there is some semantic precedent (
https://emacsdocs.org/docs/emacs/Key-Bindings says There are two other actions (currently not implemented yet) that we should keep in mind when picking bindings:
Right, I was also wondering whether Also see #310 (I just noticed it yesterday when going through old reports).
Both good points. Any suggestions? The binding was changed from
I suppose if we implement #185 with a short binding like |
I just got a handy reminder than |
(I'll get back to this asap) |
Hi,
TIL about
company-auto-update-doc
. Very handy!However, after I'm done completing (whether it is by successfully choosing a completion, or aborting my intent), the buffer that was created, in my case
*cider-doc*
, remains open. This is problematic because leaving a buffer that wasn't there before displaces my other buffers.This isn't the case if using
<f1>
(company-show-doc-buffer
) manually with each completion - with f1, the*cider-doc*
buffer always ends up closed.I can show a GIF if that helps, but I believe the description is clear enough.
Finally, in technical terms, CIDER is specifying
:company-doc-buffer #'cider-create-doc-buffer
. We (the CIDER maintainers) certainly are completely fine with this ancilliary buffer being destroyed. It's very cheap to re-create.Thanks - V
The text was updated successfully, but these errors were encountered: