mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-22 08:04:20 +01:00
Refactor ~emacs-auxmenu~ to be a tad more general
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
931b5aa764
commit
8e9f6e6334
|
@ -7,38 +7,43 @@
|
||||||
It is possible to make a fake rofi, from emacs ~completing-read~. This file facilitates that. First we define some LISP functions.
|
It is possible to make a fake rofi, from emacs ~completing-read~. This file facilitates that. First we define some LISP functions.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun completing-read-frame-popup-file (prompt file width height &rest args)
|
(defun completing-read-frame-popup-file (prompt file display width height &rest args)
|
||||||
""
|
""
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents file)
|
(insert-file-contents file)
|
||||||
(message "%s" (string-lines (buffer-string)))
|
(apply #'auxmenu-popup-frame prompt (string-lines (substring-no-properties (buffer-string))) display width height args)))
|
||||||
(apply #'completing-read-frame-popup prompt (string-lines (substring-no-properties (buffer-string))) args)))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defvar completing-read-frame nil)
|
(defvar auxmenu-frame-alist nil)
|
||||||
|
|
||||||
(defun completing-read-frame-popup (prompt collection &rest args)
|
(defun auxmenu-popup-frame (prompt collection display width height &rest args)
|
||||||
""
|
""
|
||||||
(unless completing-read-frame
|
(let ((frame (alist-get display auxmenu-frame-alist)))
|
||||||
(setq completing-read-frame
|
(when (equal frame nil)
|
||||||
(make-frame `((minibuffer . only)
|
(when (equal display nil)
|
||||||
(name . "emacs-completing-read-float")
|
(error "Must specify display"))
|
||||||
(unsplittable . t)
|
|
||||||
(no-other-frame . t)
|
(push `(,display . ,(make-frame
|
||||||
(width . ,width)
|
`((minibuffer . only)
|
||||||
(height . ,height)
|
(name . "emacs-completing-read-float")
|
||||||
(left . 0.5)
|
(unsplittable . t)
|
||||||
(top . 0.5))))
|
(no-other-frame . t)
|
||||||
(make-frame-invisible completing-read-frame))
|
(width . ,width)
|
||||||
(make-frame-visible completing-read-frame)
|
(height . ,height)
|
||||||
(raise-frame completing-read-frame)
|
(display . ,display)
|
||||||
(with-selected-frame completing-read-frame
|
(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
|
(unwind-protect
|
||||||
(let ((selection (apply #'completing-read prompt collection args)))
|
(let ((selection (apply #'completing-read prompt collection args)))
|
||||||
(make-frame-invisible completing-read-frame)
|
(make-frame-invisible frame)
|
||||||
selection)
|
selection)
|
||||||
(make-frame-invisible completing-read-frame))))
|
(make-frame-invisible frame)))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Next a bash helper is needed.
|
Next a bash helper is needed.
|
||||||
|
@ -48,7 +53,7 @@ Next a bash helper is needed.
|
||||||
{
|
{
|
||||||
tmp=$(mktemp)
|
tmp=$(mktemp)
|
||||||
tee > $tmp
|
tee > $tmp
|
||||||
emacs -Q --batch --eval $"(progn (require 'server) (princ (format \"%s\\n\" (server-eval-at \"server\" '(completing-read-frame-popup-file \"$1\" \"$tmp\" $2 $3)))))"
|
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
|
rm $tmp
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
Loading…
Reference in a new issue