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

Set a max width #23

Open lrustand opened 2 months ago

lrustand commented 2 months ago

I have a super ultrawide monitor (aspect ratio 32:9), which is VERY wide. When displaying which-key in a posframe across the entire width of the monitor it gets pretty uncomfortable to read it. It would be nicet to add a customizable variable where the user could set a max width for the posframe.

Maybe something like this:

(defvar which-key-posframe-max-width nil
  "The maximum width of the posframe. If nil, fill the frame width.")

(defun which-key-posframe--max-dimensions (_)
  "Return max-dimensions of posframe.
The returned value has the form (HEIGHT . WIDTH) in lines and
characters respectably."
  (cons (- (frame-height) 2) ; account for mode-line and minibuffer
        (if which-key-posframe-max-width
            (min which-key-posframe-max-width (frame-width))
          (frame-width))))