meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.09k stars 127 forks source link

How do I get rid of the "Frame is too narrow for KEYPAD popup" message? #409

Closed SequentialDesign closed 1 year ago

SequentialDesign commented 1 year ago

How do I get rid of the "Frame is too narrow for KEYPAD popup" message?

I don't want to see it, and I don't want to change my font size.

TIA.

PS I don't care about seeing my hotkeys.

SequentialDesign commented 1 year ago

The following worked for me.

(defun meow-describe-keymap (keymap)
  (when (and keymap (not defining-kbd-macro) (not meow--keypad-help))
    (let* ((rst))
      (setq rst (reverse rst))
      (let ((msg (meow--describe-keymap-format rst)))
    (let ((message-log-max)
          (max-mini-window-height 1.0))
      (save-window-excursion
        (with-temp-message
        (format "%sKEYPAD: %s%s"
            msg
            (let ((pre (meow--keypad-format-prefix)))
              (if (string-blank-p pre)
                  ""
                (propertize pre 'face 'font-lock-comment-face)))
            (propertize (meow--keypad-format-keys nil) 'face 'font-lock-string-face))
          (sit-for 1000000 t))))))))

forgot this:

(defun meow--describe-keymap-format (pairs &optional width)
  (let* ((fw (or width (frame-width)))
         (cnt (length pairs))
         (best-col-w nil)
         (best-rows nil))
    (cl-loop for col from 5 downto 2  do
             (let* ((row (1+ (/ cnt col)))
                    (v-parts (seq-partition pairs row))
                    (rows (meow--transpose-lists v-parts))
                    (col-w (thread-last
                             v-parts
                             (mapcar
                              (lambda (col)
                                (cons (seq-max (or (mapcar (lambda (it) (length (car it))) col) '(0)))
                                      (seq-max (or (mapcar (lambda (it) (length (cdr it))) col) '(0))))))))
                    ;; col-w looks like:
                    ;; ((3 . 2) (4 . 3))
                    (w (thread-last
                         col-w
                         ;; 4 is for the width of arrow(3) between key and command
                         ;; and the end tab or newline(1)
                         (mapcar (lambda (it) (+ (car it) (cdr it) 4)))
                         (meow--sum))))
               (when (<= w fw)
                 (setq best-col-w col-w
                       best-rows rows)
                 (cl-return nil))))
    (if best-rows
        (thread-last
          best-rows
          (mapcar
           (lambda (row)
             (thread-last
               row
               (seq-map-indexed
                (lambda (it idx)
                  (let* ((key-str (car it))
                         (def-str (cdr it))
                         (l-r (nth idx best-col-w))
                         (l (car l-r))
                         (r (cdr l-r))
                         (key (meow--string-pad key-str l 32 t))
                         (def (meow--string-pad def-str r 32)))
                    (format "%s%s%s"
                            key
                            (propertize " → " 'face 'font-lock-comment-face)
                            def))))
               (meow--string-join " "))))
          (meow--string-join "\n"))
      (propertize "" 'face 'meow-keypad-cannot-display))))
DogLooksGood commented 1 year ago

Additional information, you can use which-key as well.

SequentialDesign commented 1 year ago

Additional information, you can use which-key as well.

Are you saying that I can use which-key with Meow? How? It doesn't work in the keypad state.

DogLooksGood commented 1 year ago

Just enable which-key.

SequentialDesign commented 1 year ago

oops, you are correct. thanks for the tip. I don't know why it didn't work the first time.

montchr commented 5 months ago

This is still an issue.

DogLooksGood commented 5 months ago

I recommend to use which-key as it has more features and well adopted.

montchr commented 5 months ago

If that is the case, should Meow's internal implementation be removed/deprecated? Because technically, the issue here still exists until it is either fixed or removed.