diff --git a/README.org b/README.org index bbd9a95..bcd34d1 100644 --- a/README.org +++ b/README.org @@ -215,6 +215,7 @@ The [[info:emacs#Init File][init file (info)]] does not load the ~custom-file~ a embark ; act on any buffer selection htmlize ; convert buffer contents to HTML iedit ; simultaneous multi-entity editing + keycast ; show current command with binding magit ; Git Text-based User Interface marginalia ; minibuffer margin notes no-littering ; keep `user-emacs-directory' clean @@ -705,12 +706,43 @@ Listing [[lst:configure-keycast]] configures =keycast=. #+caption: Configure =keycast=. #+name: lst:configure-keycast #+begin_src emacs-lisp - (when (ensure-package-installation 'keycast) - ;; TODO: make `keycast-log-update-buffer' use a buffer similar to - ;; the control buffer `ediff-setup-windows-plain' returns. - (with-eval-after-load 'keycast - (custom-set-variables - '(keycast-mode-line-window-predicate 'keycast-bottom-right-window-p)))) + ;; Make `keycast-log-update-buffer' use a buffer similar to the + ;; control buffer `ediff-setup-windows-plain' returns. + (when (require 'keycast nil 'noerror) + (custom-set-variables + '(keycast-mode-line-window-predicate 'keycast-bottom-right-window-p)) + + (defun keycast-log-update-buffer-plain () + (let ((buffer (get-buffer keycast-log-buffer-name))) + (unless (buffer-live-p buffer) + (setq buffer (get-buffer-create keycast-log-buffer-name)) + (with-current-buffer buffer + (setq buffer-read-only t))) + (unless (get-buffer-window buffer) + (display-buffer buffer '(display-buffer-at-bottom + (dedicated . t) + (window-height . 10)))) + (when-let ((output (keycast--format keycast-log-format))) + (with-current-buffer buffer + (goto-char (if keycast-log-newest-first (point-min) (point-max))) + (let ((inhibit-read-only t)) + (when (and (> keycast--command-repetitions 0) + (string-match-p "%[rR]" keycast-log-format)) + (unless keycast-log-newest-first + (backward-char)) + (ignore-errors + (delete-region (line-beginning-position) + (1+ (line-end-position))))) + (insert output)) + (goto-char (if keycast-log-newest-first (point-min) (point-max))))))) + + (defun toggle-keycast-log-update-buffer-override () + "Toggle `keycast-log-update-buffer' advice." + (interactive) + (toggle-advice 'keycast-log-update-buffer + :override #'keycast-log-update-buffer-plain)) + + (toggle-keycast-log-update-buffer-override)) #+end_src * [[info:emacs#Emacs Server][Using Emacs as a server (info)]]