From cc95f9125f083df984143a442724ea4ac0eb092f Mon Sep 17 00:00:00 2001 From: justbur Date: Thu, 2 Jul 2015 08:27:29 -0400 Subject: [PATCH] Reorganize main update function --- which-key.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/which-key.el b/which-key.el index c93340891b9..b3ca76f5232 100644 --- a/which-key.el +++ b/which-key.el @@ -121,8 +121,8 @@ replace and the cdr is the replacement text. " (bottom-or-top (member which-key-buffer-position '(top bottom))) (max-len-key 0) (max-len-desc 0) key-match desc-match unformatted formatted buffer-height buffer-width vertical-buffer-width) - (with-current-buffer (get-buffer which-key-buffer) - (erase-buffer) + ;; get keybindings + (with-temp-buffer (describe-buffer-bindings buf key) (goto-char (point-max)) (while (re-search-backward @@ -135,18 +135,18 @@ replace and the cdr is the replacement text. " (cl-pushnew (cons key-match desc-match) unformatted :test (lambda (x y) (string-equal (car x) (car y))))) (setq max-len-desc (if (> max-len-desc which-key-max-description-length) - (+ 2 which-key-max-description-length) + (+ 2 which-key-max-description-length) ; for the .. max-len-desc)) (setq formatted (mapcar (lambda (str) (which-key/format-matches str max-len-key max-len-desc)) - unformatted)) + unformatted))) + (with-current-buffer (get-buffer which-key-buffer) (erase-buffer) (setq vertical-buffer-width (which-key/get-vertical-buffer-width max-len-desc max-len-key)) (setq buffer-line-breaks (which-key/insert-keys formatted (unless bottom-or-top vertical-buffer-width))) (goto-char (point-min)) (which-key/replace-strings-from-alist which-key-description-replacement-alist) - ;; (message "%s" which-key-vertical-buffer-width) (if bottom-or-top (setq buffer-height (+ 2 buffer-line-breaks)) (setq buffer-width vertical-buffer-width)))