1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-27 18:30:47 -08:00

Add which-key-show-prefix 'mode-line option

See #157
This commit is contained in:
Justin Burkett 2016-12-22 15:21:37 -05:00
parent a3a989e804
commit 49ab7afd93

View file

@ -240,6 +240,7 @@ and nil. Nil turns the feature off."
(const :tag "In the first line" top)
(const :tag "In the last line" bottom)
(const :tag "In the echo area" echo)
(const :tag "In the mode-line" mode-line)
(const :tag "Hide" nil)))
(defcustom which-key-popup-type 'side-window
@ -1825,9 +1826,17 @@ and a page count."
nil))
(`echo
(cons page
(concat full-prefix (when prefix-keys " ")
status-line (when status-line " ")
nxt-pg-hint)))
(lambda ()
(which-key--echo
(concat full-prefix (when prefix-keys " ")
status-line (when status-line " ")
nxt-pg-hint)))))
(`mode-line
(cons page
(lambda ()
(with-current-buffer which-key--buffer
(setq-local mode-line-format
(concat " " full-prefix " " status-line " " nxt-pg-hint))))))
(_ (cons page nil)))))
(defun which-key--show-page (n)
@ -1839,8 +1848,8 @@ and a page count."
(if (= 0 n-pages)
(message "%s- which-key can't show keys: There is not \
enough space based on your settings and frame size." prefix-keys)
(setq page-n (mod n n-pages)
which-key--current-page-n page-n)
(setq page-n (mod n n-pages))
(setq which-key--current-page-n page-n)
(when (= n-pages (1+ n)) (setq which-key--on-last-page t))
(let ((page-echo (which-key--process-page page-n which-key--pages-plist))
(height (plist-get which-key--pages-plist :page-height))
@ -1852,7 +1861,7 @@ enough space based on your settings and frame size." prefix-keys)
(erase-buffer)
(insert (car page-echo))
(goto-char (point-min)))
(when (cdr page-echo) (which-key--echo (cdr page-echo)))
(when (cdr page-echo) (funcall (cdr page-echo)))
(which-key--show-popup (cons height width)))))
;; used for paging at top-level
(if (fboundp 'set-transient-map)