Giter Club home page Giter Club logo

Comments (2)

stardiviner avatar stardiviner commented on June 27, 2024

I was always wandering why I change company-box-frame-parameter is not working.
After checking out source code, I found this is because:

(defun company-box--display (string)
  "Display the completions."
  (company-box--render-buffer string)
  (unless (company-box--get-frame) ; the already created child-frame exist, so will not apply following new child-frame parameters.
    (company-box--set-frame (company-box--make-frame)))
  (company-box--set-frame-position (company-box--get-frame))
  (unless (frame-visible-p (company-box--get-frame))
    (make-frame-visible (company-box--get-frame)))
  (company-box--update-scrollbar (company-box--get-frame) t))

So I hope company-box can add a function to reset child-frame like this:

;; delete old child-frame, then `company-box' create new child-frame.
    (delete-frame (company-box--get-frame))
    (unless (company-box--get-frame)
      (company-box--set-frame (company-box--make-frame)))
    (delete-frame (frame-parameter nil 'company-box-doc-frame))
    (unless (frame-live-p (frame-parameter nil 'company-box-doc-frame))
      (set-frame-parameter nil 'company-box-doc-frame nil))

Here is my current config (as reference for you to considering circadian theme switching case):

(setq-default company-box-frame-parameters company-box-frame-parameters)
  (defun my:company-box-faces-setup (theme)
    "Reload company-box faces on `circadian' `THEME' toggling."
    ;; delete old child-frame, then `company-box' create new child-frame.
    (delete-frame (company-box--get-frame))
    (unless (company-box--get-frame)
      (company-box--set-frame (company-box--make-frame)))
    (delete-frame (frame-parameter nil 'company-box-doc-frame))
    (unless (frame-live-p (frame-parameter nil 'company-box-doc-frame))
      (set-frame-parameter nil 'company-box-doc-frame nil))
    
    (set-face-attribute 'company-box-candidate nil
                        :inherit nil
                        :family (face-attribute 'default :family)
                        :foreground (face-foreground 'default))
    (set-face-attribute 'company-box-selection nil
                        :inherit 'company-tooltip-selection)
    (set-face-attribute 'company-box-background nil
                        :background (cl-case (alist-get 'background-mode (frame-parameters))
                                      ('light "#EBF4FE")
                                      ('dark (color-lighten-name (face-background 'default) 4))))
    (add-to-list 'company-box-frame-parameters
                 `(background-color . ,(cl-case (alist-get 'background-mode (frame-parameters))
                                         ('light "#EBF4FE")
                                         ('dark (color-lighten-name (face-background 'default) 4)))))
    (add-to-list 'company-box-frame-parameters
                 `(foreground-color . ,(face-foreground 'default)))
    )
  (add-hook 'circadian-after-load-theme-hook #'my:company-box-faces-setup)

from company-box.

stardiviner avatar stardiviner commented on June 27, 2024

Hi, @sebastiencs any idea on this? can you add some similar workaround for this case which the company-box child-frames is dead, or invalid problems?

from company-box.

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.