yanghaoxie / which-key-posframe

Let emacs-which-key use posframe to show its popup.
GNU General Public License v3.0
51 stars 10 forks source link

which-key-posframe-height #5

Open mclearc opened 5 years ago

mclearc commented 5 years ago

thanks for this package. I'm having trouble adjusting the height of the which-key posframe. None of the height settings I add seem to have any effect. Everything else works fine though. Here's my setup:

(use-package which-key-posframe
  :if (and (window-system) (version<= "26.1" emacs-version))
  :hook (after-init . which-key-posframe-mode)
  :config
  (setq which-key-posframe-border-width 15)
  (setq which-key-posframe-poshandler 'posframe-poshandler-frame-center))

Right now when the frame is maximized the posframe is often too long (nearly the whole frame) and not high enough (the bottom key options are cut off). I'd rather it just be taller and less wide. I've tried setting the height via both custom interface and in the use package declaration but have seen no change. Any ideas as to what I'm doing incorrectly?

yanghaoxie commented 5 years ago

I just read some code of which-key, it seems like that which-key determines the height and width according to the information it displays. This will align the information properly.

If we simply change the height and width of which-key-posframe, the display will be destroyed, therefore which-key-posframe just inherit the height and width from which-key.

I do not know whether it needs a lot of work to do this right. I will investigate this later.

sandinmyjoints commented 5 years ago

In case its helpful, I got changes to height and width to take effect by using posframe's default arghandler:

(setq posframe-arghandler #'wjb/posframe-arghandler)
(defun wjb/posframe-arghandler (buffer-or-name arg-name value)
  (let ((info '(:internal-border-width 2 :width 90 :height 12)))
    (or (plist-get info arg-name) value)))

It doesn't actually look good since the width and height are not tailored to the which-key content, but I'm sharing in case this is helpful in getting which-key-posframe to inherit height and width from which-key.

yanghaoxie commented 5 years ago

@sandinmyjoints Thanks! However, it is very simple to make it is feasible to customize which-key-posframe height and width, what I have not figured out is how to align the display if we do not inherit height and width from which-key.