~magic_rb/dotfiles

93eb25815981008a84ee784b73a6f30ec9a0b66e — Magic_RB 8 months ago eacd150
emacs-rofi: make Emacs reuse the same frame

Signed-off-by: Magic_RB <magic_rb@redalder.org>
1 files changed, 21 insertions(+), 14 deletions(-)

M emacs-lisp/emacs_rofi.org
M emacs-lisp/emacs_rofi.org => emacs-lisp/emacs_rofi.org +21 -14
@@ 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.