mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 19:46:17 +01:00
8e9f6e6334
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2.2 KiB
2.2 KiB
Emacs Rofi
It is possible to make a fake rofi, from emacs completing-read
. This file facilitates that. First we define some LISP functions.
(defun completing-read-frame-popup-file (prompt file display width height &rest args)
""
(with-temp-buffer
(insert-file-contents file)
(apply #'auxmenu-popup-frame prompt (string-lines (substring-no-properties (buffer-string))) display width height args)))
(defvar auxmenu-frame-alist nil)
(defun auxmenu-popup-frame (prompt collection display width height &rest args)
""
(let ((frame (alist-get display auxmenu-frame-alist)))
(when (equal frame nil)
(when (equal display nil)
(error "Must specify display"))
(push `(,display . ,(make-frame
`((minibuffer . only)
(name . "emacs-completing-read-float")
(unsplittable . t)
(no-other-frame . t)
(width . ,width)
(height . ,height)
(display . ,display)
(left . 0.5)
(top . 0.5))))
auxmenu-frame-alist)
(setq frame (alist-get display auxmenu-frame-alist)))
(make-frame-visible frame)
(raise-frame frame)
(with-selected-frame frame
(unwind-protect
(let ((selection (apply #'completing-read prompt collection args)))
(make-frame-invisible frame)
selection)
(make-frame-invisible frame)))))
Next a bash helper is needed.
function emacs-rofi()
{
tmp=$(mktemp)
tee > $tmp
emacs -Q --batch --eval $"(progn (require 'server) (princ (format \"%s\\n\" (server-eval-at \"server\" '(completing-read-frame-popup-file \"$1\" \"$tmp\" \"$DISPLAY\" $2 $3)))))"
rm $tmp
}
Which then ought to be used like so.
echo -e "test1\ntest2\ntest3" | emacs-rofi "test"