tumashu / ivy-posframe

ivy-posframe is a ivy extension, which let ivy use posframe to show its candidate menu, ivy-posframe is a **GNU ELPA** package.
415 stars 26 forks source link

ivy-posframe-width has no effect. #77

Closed dunkarooftop closed 5 years ago

dunkarooftop commented 5 years ago

Updated the package few days ago and start to see ivy-posframe-width has no effect.

My config will be at the end of the post. I tried to run (setq ivy-posframe-width NUMBER) and inspected with C-h C-v see the value get updated butivy-posframe still show with default value size.

Tested on both Emacs 26.3 and 27

(use-package ivy-posframe
  :ensure t
  :after ivy posframe
  :diminish ""
  :config
  (setq
   ivy-posframe-width 100
   ivy-posframe-height 20
   ivy-posframe-border-width 3
   ivy-posframe-parameters
   '((left-fringe . 8)
     (right-fringe . 8)))

  (setq ivy-posframe-display-functions-alist
        '((swiper              . nil)
          (t                   . ivy-posframe-display-at-frame-center))))

Thank you :)

tumashu commented 5 years ago

What about set ivy-posframe-width and ivy-posframe-height both?

dunkarooftop commented 5 years ago

I tried this in scratch buffer which has no effect. The value do get updated but ivy-posframe-get-size won't use it.

(setq ivy-posframe-width 110
      ivy-posframe-height 30)

Currently my workaround is add this to my config.

  (setq ivy-posframe-size-function
        (defun ivy-posframe-get-size+ ()
          (if (eq this-command
                  'counsel-bookmark)
              (list
               :height ivy-posframe-height
               :width 70)
            (list
             :height ivy-posframe-height
             :width 110))))

It kinda work but not perfect (The posframe is smaller but not to the size being set) (inspired by the reddit post which talked about the frame size issue) I also try remove my config about the width and hardcode in ivy-posframe.el and recompile it. I does not have effect either. Super strange. Here is a image to show

https://imgur.com/neteQm5

dunkarooftop commented 5 years ago

After poking around I found tweak the size of :min-width from 0.62 to 0.3 fix the problem. (I have a 30 inch wide monitor) The min-width number was larger then my setting which is not being used.

(defun ivy-posframe-get-size ()
  "The default functon used by `ivy-posframe-size-function'."
  (list
   :height ivy-posframe-height
   :width ivy-posframe-width
   :min-height (or ivy-posframe-min-height (+ ivy-height 1))
   :min-width (or ivy-posframe-min-width (round (* (frame-width) 0.62)))))