refactor(helm): use helm-posframe

The old, in-house implementation no longer works (and reportedly causes
crashes).

Ref: #6676
Co-authored-by: johanwiden <johanwiden@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2023-02-23 22:37:36 -05:00
parent fcf587fbe8
commit 928902213f
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 16 additions and 64 deletions

View file

@ -1,56 +0,0 @@
;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +helm-poshandler-frame-center-near-bottom-fn (info)
"Display the child frame in the center of the frame, slightly closer to the
bottom, which is easier on the eyes on big displays."
(let ((parent-frame (plist-get info :parent-frame))
(pos (posframe-poshandler-frame-center info)))
(cons (car pos)
(truncate (/ (frame-pixel-height parent-frame)
2)))))
(defvar +helm--posframe-buffer nil)
;;;###autoload
(defun +helm-posframe-display-fn (buffer &optional _resume)
"TODO"
(setq helm--buffer-in-new-frame-p t)
(let ((params (copy-sequence +helm-posframe-parameters)))
(let-alist params
(require 'posframe)
(posframe-show
(setq +helm--posframe-buffer buffer)
:position (point)
:poshandler +helm-posframe-handler
:respect-header-line helm-echo-input-in-header-line
:min-width
(max (cl-typecase .width
(integer .width)
(float (truncate (* (frame-width) .width)))
(function (funcall .width))
(t 0))
.min-width)
:min-height
(max (cl-typecase .height
(integer .height)
(float (truncate (* (frame-height) .height)))
(function (funcall .height))
(t 0))
.min-height)
:override-parameters
(dolist (p '(width height min-width min-height) params)
(setq params (delq (assq p params) params)))))
;;
(unless (or (null +helm-posframe-text-scale)
(= +helm-posframe-text-scale 0))
(with-current-buffer buffer
(text-scale-set +helm-posframe-text-scale)))))
;;;###autoload
(defun +helm-posframe-cleanup-h ()
"TODO"
;; Ensure focus is properly returned to the underlying window. This gives the
;; modeline a chance to refresh.
(switch-to-buffer +helm--posframe-buffer t))
(add-hook 'helm-cleanup-hook #'+helm-posframe-cleanup-h)

View file

@ -66,12 +66,6 @@ Can be negative.")
(setq helm-default-prompt-display-function #'+helm--set-prompt-display))
:init
(when (modulep! +childframe)
;; If this is set to 'iconify-top-level then Emacs will be minimized upon
;; helm completion.
(setq iconify-child-frame 'make-invisible)
(setq helm-display-function #'+helm-posframe-display-fn))
(let ((fuzzy (modulep! +fuzzy)))
(setq helm-apropos-fuzzy-match fuzzy
helm-bookmark-show-location fuzzy
@ -106,6 +100,19 @@ Can be negative.")
(dolist (fn '(helm-describe-variable helm-describe-function))
(advice-add fn :around #'doom-use-helpful-a)))
(use-package! helm-posframe
:when (modulep! +childframe)
:hook (helm-mode . helm-posframe-enable)
:config
(setq helm-posframe-poshandler #'posframe-poshandler-frame-center
helm-posframe-width 0.65
helm-posframe-height 0.35
helm-posframe-min-width 80
helm-posframe-min-height 16
helm-posframe-border-width 8))
(use-package! helm-flx
:when (modulep! +fuzzy)
:hook (helm-mode . helm-flx-mode)

View file

@ -10,10 +10,11 @@
:pin "11fb36af119b784539d31c6160002de1957408aa")
(package! helm-projectile :pin "35a2111d00c0c0c9d8743280d3f1243bb217118a")
(package! swiper-helm :pin "93fb6db87bc6a5967898b5fd3286954cc72a0008")
(when (modulep! +childframe)
(package! helm-posframe :pin "87461b52b6f3f378c63642a33f584d4a4ba28351"))
(when (modulep! +fuzzy)
(package! helm-flx :pin "5220099e695a3586dba2d59640217fe378e66310"))
(when (modulep! +childframe)
(package! posframe :pin "06b939cfb06168782fc378043ff35bd7fec203b8"))
(when (modulep! :lang org)
(package! helm-org :pin "d67186d3a64e610c03a5f3d583488f018fb032e4"))
(when (modulep! +icons)