Extract :ui posframe packages into other modules

This commit is contained in:
Henrik Lissner 2018-05-08 21:47:40 +02:00
parent 8d936f2d0b
commit 317b556bde
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
10 changed files with 77 additions and 84 deletions

View file

@ -0,0 +1,16 @@
;;; completion/ivy/autoload/posframe.el -*- lexical-binding: t; -*-
;;;###if (featurep! +childframe)
;;;###autoload
(defun +ivy-display-at-frame-center-near-bottom (str)
"TODO"
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom))
;;;###autoload
(defun +ivy-poshandler-frame-center-near-bottom (info)
"TODO"
(let ((parent-frame (plist-get info :parent-frame))
(pos (posframe-poshandler-frame-center info)))
(cons (car pos)
(truncate (/ (frame-pixel-height parent-frame) 1.6)))))

View file

@ -187,3 +187,37 @@ immediately runs it on the current candidate (ending the ivy session)."
(def-package! wgrep
:commands (wgrep-setup wgrep-change-to-wgrep-mode)
:config (setq wgrep-auto-save-buffer t))
(def-package! ivy-posframe
:when EMACS26+
:when (featurep! +childframe)
:hook (ivy-mode . ivy-posframe-enable)
:preface
;; This function searches the entire `obarray' just to populate
;; `ivy-display-functions-props'. There are 15k entries in mine! This is
;; wasteful, so...
(advice-add #'ivy-posframe-setup :override #'ignore)
:config
;; ... let's do it manually
(dolist (fn (list 'ivy-posframe-display-at-frame-bottom-left
'ivy-posframe-display-at-frame-center
'ivy-posframe-display-at-point
'ivy-posframe-display-at-frame-bottom-window-center
'ivy-posframe-display
'ivy-posframe-display-at-window-bottom-left
'ivy-posframe-display-at-window-center
'+ivy-display-at-frame-center-near-bottom))
(push (list fn :cleanup 'ivy-posframe-cleanup) ivy-display-functions-props))
(push '(t . +ivy-display-at-frame-center-near-bottom) ivy-display-functions-alist)
;; posframe doesn't work well with async sources
(dolist (fn '(swiper counsel-rg counsel-ag counsel-pt counsel-grep counsel-git-grep))
(push (cons fn nil) ivy-display-functions-alist))
(setq ivy-height 16
ivy-fixed-height-minibuffer nil
ivy-posframe-parameters `((min-width . 90)
(min-height . ,ivy-height)
(internal-border-width . 10))))

View file

@ -0,0 +1,4 @@
;;; completion/ivy/doctor.el -*- lexical-binding: t; -*-
(when (and (not EMACS26+) (featurep! +childframe))
(error! "The +childframe feature requires Emacs 26+"))

View file

@ -9,3 +9,6 @@
(package! ivy-hydra)
(package! ivy-rich)
(package! wgrep)
(when (and EMACS26+ (featurep! +childframe))
(package! ivy-posframe))