Skip to content

Commit

Permalink
Fix slowness of posframe
Browse files Browse the repository at this point in the history
Fixes #192
  • Loading branch information
notmgsk authored and abo-abo committed Sep 6, 2022
1 parent 751bd32 commit e3e6ec1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ace-window-posframe.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@

(defun aw--lead-overlay-posframe (path leaf)
(let* ((wnd (cdr leaf))
(str (apply #'string path))
(bufname (format "*aw-posframe-buffer-%s*" (gensym))))
(str (format "%s" (apply #'string path)))
;; It's important that buffer names are not unique across
;; multiple invocations: posframe becomes very slow when
;; creating new frames, and so being able to reuse old ones
;; makes a huge difference. What defines "able to reuse" is
;; something like: a frame exists which hasn't been deleted
;; (with posframe-delete) and has the same configuration as
;; the requested new frame.
(bufname (format "*aw-posframe-buffer-%s*" path)))
(with-selected-window wnd
(push bufname aw--posframe-frames)
(posframe-show bufname
Expand All @@ -16,7 +23,9 @@
:background-color (face-background 'aw-leading-char-face)))))

(defun aw--remove-leading-chars-posframe ()
(map nil #'posframe-delete aw--posframe-frames))
;; Hide rather than delete. See aw--lead-overlay-posframe for why.
(map nil #'posframe-hide aw--posframe-frames)
(setq aw--posframe-frames '()))

(defun ace-window-posframe-enable ()
(setq aw--lead-overlay-fn #'aw--lead-overlay-posframe
Expand Down

0 comments on commit e3e6ec1

Please sign in to comment.