casouri / eldoc-box

childframe doc for eglot and anything that uses eldoc
342 stars 27 forks source link

The eldoc-box-frame-hook might be broken and how to draw a border around the child frame #100

Open shipmints opened 3 months ago

shipmints commented 3 months ago

Thank you for this nice little package. Curious if the following is a bug, and, if not, what one should do instead. I'd like to draw a white border in the child frame. I'm emacs 29.3 on an intel mac, in case the mac drawing code is at fault. I do not have another platform on which to test.

In the function

(defun eldoc-box--get-frame (buffer)
...
      (with-selected-frame frame
        (run-hook-with-args 'eldoc-box-frame-hook main-frame))
      (make-frame-visible frame))))

it seems to me that the hook should be called with the child frame and not the main frame?

Shouldn't this work?

  (defun my/eldoc-box-post-frame-hook (frame)
    (modify-frame-parameters
     eldoc-box--frame ; frame here is the main-frame so force internal reference
     `((internal-border-width . ,1))
     )
    )
  (add-hook 'eldoc-box-frame-hook #'my/eldoc-box-post-frame-hook)

By the way, the hacked version doesn't seem to work, either. So maybe it is the mac drawing code at fault?

casouri commented 3 months ago

I looked at my config and I just have

(set-face-attribute 'eldoc-box-border nil :background "darkgray")

Give that a try and see it if works for you.

shipmints commented 3 months ago

Hi, and thank you for taking a look. No box border appears at all. The effect I'm trying to achieve is a white box around the pop-up. I've attached a screenshot of what it looks like. I set the height to 0.85 so it's clearly a tooltip (I've done the same for corfu-default). The theme is modus-vivendi from the 29.3 distribution (not prot's latest) if that has any bearing.

image

Something like this (but only one pixel, ofc (I'd also like a box around the corfu popup, too):

image

shipmints commented 3 months ago

I still wonder if the hook is being called with a reference to the correct child frame or not.

casouri commented 3 months ago

I still wonder if the hook is being called with a reference to the correct child frame or not.

It's working as expected; the docstring says "Each function runs inside the new frame and receives the main frame as argument". So if you want to reference the childframe, you should use current-frame.

If my config doesn't work, then it's probably Emacs 29 on Mac not drawing the border properly. (I remember it not working in the past but I don't remember since when it starts to work :-) Maybe try Emacs master?

shipmints commented 3 months ago

I'll keep at it.

shipmints commented 3 months ago

This works for me BUT I still don't get why the hook is being passed the frame of the buffer window vs. the child frame.

  (defun my/eldoc-box-post-frame-hook (frame)
    (modify-frame-parameters
     ;; the hook sends the parent frame this is not what we want we force the child frame
     eldoc-box--frame
     `(
       (background-color . "white")
       (internal-border-width . ,1)
       )
     )
    )
  (add-hook 'eldoc-box-frame-hook #'my/eldoc-box-post-frame-hook)