Giter Club home page Giter Club logo

Comments (9)

dgutov avatar dgutov commented on June 26, 2024 1

Sure, no problem. We can revisit this if somebody else reports the same difficulty.

from company-quickhelp.

dgutov avatar dgutov commented on June 26, 2024

Perhaps ace-window's author will have some recommendations?

from company-quickhelp.

rdiaz02 avatar rdiaz02 commented on June 26, 2024

I tried, but I was not able to open a new issue.

Anyway, I am not sure I understand what happens and why, so I am leaving here code to reproduce the issue and hopefully a better explanation. But I am closing the issue for now, at least until I understand it better. The problem is of course solved not having ace-display-buffer display Help buffers, which might actually be a more reasonable thing to do.

  • I use ace-display-buffer to display Help buffers using display-buffer-alist
  • This works fine, except ...
  • with company-quickhelp:
    • ace-display-buffer in the display-buffer-alist is called as soon as the quickhelp is to be displayed
    • if display-buffer-at-bottom precedes ace-display-buffer, ace-display-buffer is not called, even when the quickhelp is displayed as a regular quickhelp (not in a window at the bottom)
    • but having display-buffer-pop-up-window precede ace-display-buffer still has ace-display-buffer called.

So I do not understand why the quickhelp seems to be calling ace-display-buffer, even when the quichelp is not displayed as a regular buffer. Nor do I understand why display-buffer-at-bottom prevents calling ace-display-buffer, but that does not happen with display-buffer-pop-up-window

Interestingly, ace-display-buffer is not called if I use the company-box package (https://github.com/sebastiencs/company-box) instead of company-quickhelp.

Code to reproduce the issue

(require 'package)
(package-initialize)


(use-package company
  :ensure t
  :init (global-company-mode 1)
  :config
  (progn
    (company-prescient-mode 1)
    (setq company-show-quick-access t)
    (setq company-minimum-prefix-length 2)
    (setq company-idle-delay .5) 
    (setq company-require-match nil)
    (setq company-selection-wrap-around 't)
    (setq company-tooltip-limit 10) 
    (setq company-dabbrev-downcase nil)
    (setq company-auto-update-doc nil)
    ))

(use-package company-quickhelp
  :ensure t
  :after company
  :init (company-quickhelp-mode 1)
  :config
  (progn
    (setq company-quickhelp-delay 1)
  ))

(use-package ace-window
  :ensure t
  :commands (ace-window
	     ace-display-buffer
	     )
  :init
  (progn
    (setq aw-dispatch-always t)
    )
  :config
  (progn
    (setq aw-minibuffer-flag nil)
    (setq aw-background nil)
    (set-face-attribute 'aw-leading-char-face nil
			:height 8.5 :weight 'bold)
    ))

(add-to-list 'display-buffer-alist
	     '("\\*Help\\*"
	       (display-buffer-reuse-window
                display-buffer-pop-up-window
		;; display-buffer-at-bottom ;; this prevents ace-display issue
		ace-display-buffer
		)))

from company-quickhelp.

dgutov avatar dgutov commented on June 26, 2024

Interestingly, ace-display-buffer is not called if I use the company-box package (https://github.com/sebastiencs/company-box) instead of company-quickhelp.

Hmm, perhaps following its example here would be a good idea. Could you try this patch?

diff --git a/company-quickhelp.el b/company-quickhelp.el
index 17b32a9..dd21bc5 100644
--- a/company-quickhelp.el
+++ b/company-quickhelp.el
@@ -130,7 +130,8 @@ just grab the first candidate and press forward."
 
 (defun company-quickhelp--fetch-docstring (selected)
   "Fetch docstring from the current backend for SELECTED string."
-  (let ((quickhelp-str (company-call-backend 'quickhelp-string selected)))
+  (let* ((display-buffer-alist nil)
+         (quickhelp-str (company-call-backend 'quickhelp-string selected)))
     (if (stringp quickhelp-str)
         (with-temp-buffer
           (insert quickhelp-str)

Also, does C-h pressed when the company popup is active exhibit the same problem? Perhaps we should add a similar like to company--show-doc-buffer too.

from company-quickhelp.

rdiaz02 avatar rdiaz02 commented on June 26, 2024

Thanks! That solves the problem of calling ace-display-buffer when the quickhelp is displayed, initially. However, if one keeps using it, opens Help buffers and, calls C-u C-h, then it starts misbehaving again and remains broken in subsequent invocations (before we call C-u C-h again, but that is because there is already a Help buffer, even if not displayed among the visible windows).

Pressing C-h still calls ace-display-buffer , but then that is what should happen. (The behavior is somewhat jarring, and one needs to press a window number twice, not once).

The more I think about this, the more I think this really isn't worth digging into: probably the quickhelp should be left alone by ace. But then, handling Help buffers with ace and expecting it to also work smoothly with C-h and C-u C-h cannot be satisfactory. In particular C-u C-h: we are asking to keep the help updated, so it necessarily has to update a Help buffer, and we have already said that should go through ace, and it does.

I really think this is not solvable in a satisfactory way, and it is not worth more time. I really apologize for the noise.

from company-quickhelp.

dgutov avatar dgutov commented on June 26, 2024

That's too bad.

Pressing C-h still calls ace-display-buffer , but then that is what should happen.

If you're sure about that, I suppose there's not much to be done.

OTOH, you could try this additional patch:

diff --git a/company.el b/company.el
index 7060b60..6d8f9e9 100644
--- a/company.el
+++ b/company.el
@@ -3129,6 +3129,7 @@ from the candidates list.")
 (defun company--show-doc-buffer ()
   "Show the documentation buffer for the selection."
   (let ((other-window-scroll-buffer)
+        (display-buffer-alist nil)
         (selection (or company-selection 0)))
       (let* ((selected (nth selection company-candidates))
              (doc-buffer (or (company-call-backend 'doc-buffer selected)

This change could also be predicated on whether company-auto-update-doc is non-nil.

from company-quickhelp.

rdiaz02 avatar rdiaz02 commented on June 26, 2024

Pressing C-h still calls ace-display-buffer , but then that is what should happen.

If you're sure about that, I suppose there's not much to be done.

I think it cannot (and should not) be otherwise. C-h is company-show-doc-buffer which shows the documentation buffer for the selection. And if in display-buffer-alist the first entry we have for help were ace-display-buffer then it must ask us for where to show the buffer.

The change in #126 (comment) is useful to prevent quickhelp itself from triggering ace-display-buffer.

But I think the company mechanism for displaying the help should follow the display-buffer-alist setting.

OTOH, you could try this additional patch:

diff --git a/company.el b/company.el
index 7060b60..6d8f9e9 100644
--- a/company.el
+++ b/company.el
@@ -3129,6 +3129,7 @@ from the candidates list.")
 (defun company--show-doc-buffer ()
   "Show the documentation buffer for the selection."
   (let ((other-window-scroll-buffer)
+        (display-buffer-alist nil)
         (selection (or company-selection 0)))
       (let* ((selected (nth selection company-candidates))
              (doc-buffer (or (company-call-backend 'doc-buffer selected)

This change could also be predicated on whether company-auto-update-doc is non-nil.

But wouldn't this make the consequences of different values of company-auto-update-doc harder to understand?

from company-quickhelp.

dgutov avatar dgutov commented on June 26, 2024

But wouldn't this make the consequences of different values of company-auto-update-doc harder to understand?

That might indeed be a problem, if some users have display-buffer-alist entries that work automatically without user's intervention and thus are compatible with company-auto-update-doc=t.

Perhaps a solution is for you to customize display-buffer-alist in such a way that checks that company-candidates is non-nil (which would mean that completion is active), and when so, skips the application of ace-display-buffer. But, perhaps, excepting the case when this-command is eq to company-show-doc-buffer.

from company-quickhelp.

rdiaz02 avatar rdiaz02 commented on June 26, 2024

Sorry for the long delay: I missed this. I think we probably should close the issue, as this is really a contorted corner case (and I've since stopped having ace control help buffers, and instead always show them in the bottom, which is a lot simpler and more reliable). The solution, if any, I think is the last one you suggested: customize display-buffer-alist, and this is outside the scope of company-quickhelp.
I think we might want to close the issue.

from company-quickhelp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.