emacs-rofi: make Emacs reuse the same frame

Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
Magic_RB 2023-05-28 12:59:35 +02:00
parent eacd15086c
commit 93eb258159
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -16,22 +16,29 @@ It is possible to make a fake rofi, from emacs ~completing-read~. This file faci
#+end_src
#+begin_src emacs-lisp
(defvar completing-read-frame nil)
(defun completing-read-frame-popup (prompt collection &rest args)
""
(let ((frame (make-frame `((minibuffer . only)
(name . "emacs-completing-read-float")
(unsplittable . t)
(no-other-frame . t)
(width . ,width)
(height . ,height)
(left . 0.5)
(top . 0.5)))))
(with-selected-frame frame
(unwind-protect
(let ((selection (apply #'completing-read prompt collection args)))
(delete-frame frame)
selection)
(delete-frame frame)))))
(unless completing-read-frame
(setq completing-read-frame
(make-frame `((minibuffer . only)
(name . "emacs-completing-read-float")
(unsplittable . t)
(no-other-frame . t)
(width . ,width)
(height . ,height)
(left . 0.5)
(top . 0.5))))
(make-frame-invisible completing-read-frame))
(make-frame-visible completing-read-frame)
(raise-frame completing-read-frame)
(with-selected-frame completing-read-frame
(unwind-protect
(let ((selection (apply #'completing-read prompt collection args)))
(make-frame-invisible completing-read-frame)
selection)
(make-frame-invisible completing-read-frame))))
#+end_src
Next a bash helper is needed.