Open stardiviner opened 6 years ago
The font used in the frame is the one specified in default-frame-alist
, you can either change this variable or company-box-frame-parameters
For the scrollbar it should be fixed in a recent commit, from yesterday
About the scrollbar, it is fixed. Then I found it is little kind of thick. Can it be thinner? Sorry I raise so many requests. Because I try to figure out company-box child-frame code, but can't understand them enough. If I can I might PR by myself. And thanks for this great package.
I tried following settings, but none of them works.
(add-to-list 'company-box-frame-parameters
'(font . "-SRC-Hack-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1"))
(add-to-list 'company-box-frame-parameters
'(font-parameter . "-SRC-Hack-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1"))
(add-to-list 'company-box-frame-parameters
'(border-width . 2))
(add-to-list 'company-box-frame-parameters
'(border-color . "red"))
(add-to-list 'company-box-frame-parameters
'(scroll-bar-width . 2))
EDITED After restart Emacs, now those settings like font seems worked. But border width and border color still does not work.
I also tried to change the scroll-bar width but noticed that while I could make it larger, I couldn't make it any smaller than its original size.
@nealot I checked out (current-frame-configuration)
, found company-box-scrollbar
value is a buffer: (company-box-scrollbar . #<buffer *company-box-60817588-scrollbar*>)
. In function company-box--update-scrollbar
, The scrollbar-pixels
in let-binding seems decide the scrollbar width.
You're right, after I changed code
(setq
company-box--scrollbar-window
(with-selected-frame (company-box--get-frame)
(display-buffer-in-side-window
(company-box--update-scrollbar-buffer height-blank height-scrollbar percent buffer)
'((side . right) (window-width . 2)))))
In function company-box--update-scrollbar
, the scrollbar get larger, and can't get back smaller anymore no matter I re-evaluate function definition. Weird.
Sorry I raise so many requests.
No problem, you're raising issues others might have too :)
The scrollbar can't be smaller. It has its own window and the minimum width of a window is hardcoded in the emacs source code: https://github.com/emacs-mirror/emacs/blob/6e362a32bc9d21f73a0f29ca6f45481edeea6f29/src/window.c#L3970 I didn't try to change this hardcoded value, it might work.
The scrollbar-pixels in let-binding seems decide the scrollbar width.
This value is the scrollbar height, in pixel.
border width and border color still does not work.
You can't define "normal" borders with child frames, you need to use internal border with the frame parameter internal-border-width
(add-to-list 'company-box-frame-parameters '(internal-border-width . 10))
@sebastiencs Would it be possible to define faces specifically for company-box borders? I know you can set the global internal border face but that makes some other components look ugly.
@nealot I think that you can use the function set-face-attribute
to change faces on a specific frame
I know this not really about original issue, but stumbled upon this looking for a way to change the border color.
Actually what I was after was something similar to Sublime Text's version of popups:
I think I have achieved something very close, but it seems like kind of a hack. I'll share it, in case it is helpful. Here is what mine looks like:
First, set the value for undecorated
to nil
in company-box-frame-parameters
, then add this code somewhere which will turn it back to t
after the frame has already been created.
(defun add-ui-frame-hack (orig-fun &rest args)
"Set some frame parameters AFTER the frame has already been created."
(let ((frame (apply orig-fun args)))
(set-frame-parameter frame 'undecorated t)
(set-frame-parameter frame 'ns-appearance 'light)
frame))
(advice-add 'company-box--make-frame :around #'add-ui-frame-hack)
The ultimate result is you get the shadow around the frame which gives a nice border, without the title bar and buttons at the top.
This does it for me.
(Emacs 26.1, Max OS 10.14)
I also wanted to change the font face of the documentation and candidates list. I thought that was defined by company
but it seems company-box
overrides those faces, so thanks to the code snippet of @stardiviner I was able to make the adjustment like this:
(use-package company-box
:after company
:ensure t
:hook (company-mode . company-box-mode)
:config
(setq company-box-show-single-candidate t)
(setq x-gtk-resize-child-frames 'hide) ;; This solves the variable scrollbar width. This is probably related to Wayland
(add-to-list
'company-box-frame-parameters
'(font . "JetBrains Mono-11")
)
)
I'm not quite happy with that since I was using a default face setting like this:
(set-face-attribute 'default nil :family "JetBrains Mono" :height 130)
Then inheriting from it to adjust the font height of other faces. Using add-to-list
makes me add a hardcoded style in the configuration.
Is there another way to set the font size?
Thanks!
@ig-perez You can define a variable of cons like '("JetBrains Mono" . 130)
, And use this variable in font setting to avoid hardcoded style.
This is my screenshot, you can see, there is offset between typed text and candidate.
BTW, why there is no scrollbar, and I can't scroll down candidates too.