1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-04 21:12:23 -08:00

Reorganize code a little

This commit is contained in:
justbur 2015-07-04 11:10:20 -04:00
parent 17b5f3dfd9
commit ffbdc2a3ca

View file

@ -93,6 +93,8 @@ currently disabled.")
(setq-local cursor-in-non-selected-windows nil))
(setq which-key--setup-p t))
;; Helper functions
(defsubst which-key/truncate-description (desc)
"Truncate DESC description to `which-key-max-description-length'."
(if (> (length desc) which-key-max-description-length)
@ -159,6 +161,8 @@ longest key and description in the buffer, respectively."
padded-key padded-desc)))
unformatted))
;; "Core" functions
(defun which-key/get-formatted-key-bindings (buffer key)
(let ((max-len-key 0) (max-len-desc 0)
(key-str-qt (regexp-quote (key-description key)))
@ -234,6 +238,18 @@ Finally, show the buffer."
;; command finished maybe close the window
(which-key/hide-buffer))))
;; Timers
(defun which-key/start-open-timer ()
"Activate idle timer."
(when which-key--open-timer (cancel-timer which-key--open-timer)); start over
(setq which-key--open-timer
(run-with-idle-timer which-key-idle-delay t 'which-key/update)))
(defun which-key/stop-open-timer ()
"Deactivate idle timer."
(cancel-timer which-key--open-timer))
;; Display functions
(defun which-key/show-buffer-display-buffer (height width)
@ -271,16 +287,6 @@ Finally, show the buffer."
(intern (concat "which-key/hide-buffer-" (symbol-name method)))))
(t (error "error: Invalid choice for which-key-display-method"))))
(defun which-key/start-open-timer ()
"Activate idle timer."
(when which-key--open-timer (cancel-timer which-key--open-timer)); start over
(setq which-key--open-timer
(run-with-idle-timer which-key-idle-delay t 'which-key/update)))
(defun which-key/stop-open-timer ()
"Deactivate idle timer."
(cancel-timer which-key--open-timer))
(provide 'which-key)
;;; which-key.el ends here