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

fixed window size and number of candidates mismatch #37

Closed conao3 closed 5 years ago

conao3 commented 5 years ago

Hi @tumashu!

I wanted to change the height when ivy-posframe is enabled but use default value on normal ivy. We probably want to set more widths than usual when ivy-posframe is on.

I set it this way and expect that the height of ivy would change, but in reality only the height of posframe would change and there would be more blank areas.

In practice, this is the result of two packages fulfilling their respective responsibilities. ivy created a candidate for ivy-height, and ivy-posframe displayed the string that ivy passed.

This is a policy issue. Do you want to fix this? At first glance, the source looks like it's changing globally, but as I mentioned in the comment, it's actually changing the let variables here, so there's no global impact.

If you do not change this behavior, it is recommended that we annotate the README.

Capture 2019-04-27 9 50 39

init.el

(leaf ivy
  :ensure t
  :config
  (leaf *ivy-ui-requirements
    :config
    (leaf swiper :ensure t)
    (leaf counsel :ensure t))

  (leaf *other-ivy-packages
    :config
    (leaf ivy-posframe
      :doc "Using posframe to show Ivy"
      :when window-system
      :ensure t
      :custom ((ivy-display-function    . #'ivy-posframe-display-at-frame-center)
               (ivy-posframe-min-height . 40)
               (ivy-posframe-parameters . '((left-fringe . 10))))
      :config
      (let ((inhibit-message t))
        (ivy-posframe-enable))))

  (leaf *ivy-settings
    :config
    (ivy-mode 1)
    (counsel-mode 1)))
tumashu commented 5 years ago

ivy-posframe is an ivy extension, so it should no change ivy's custom variable only if must.

if user want to use different height, maybe write a toggle function is good idea: in this function, set ivy-height.

tumashu commented 5 years ago

for example

(defun my-ivy-posframe-toggle ()
  (interactive)
  (ivy-posframe-enable)
  (let ((config '(t . ivy-posframe-display-at-frame-center)))
    (if (member config ivy-display-functions-alist)
        (progn
          (setq ivy-height 10)
          (setq ivy-display-functions-alist
                (remove config ivy-display-functions-alist))
          (message "Ivy-posframe: Demo is disabled."))
      (setq ivy-height 20)
      (push config ivy-display-functions-alist)
      (message "Ivy-posframe: Demo is enabled."))))
conao3 commented 5 years ago

That added function was intended that way. I'll use that solution. Thanks!