completion/helm: refactor posframe support (again)
This commit is contained in:
parent
85e837e06a
commit
3d363d4cb1
2 changed files with 19 additions and 33 deletions
|
@ -17,36 +17,18 @@ bottom, which is easier on the eyes on big displays."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +helm-posframe-display (buffer &optional _resume)
|
(defun +helm-posframe-display (buffer &optional _resume)
|
||||||
"TODO"
|
"TODO"
|
||||||
(setq +helm--posframe-last-window (selected-window))
|
|
||||||
(require 'posframe)
|
(require 'posframe)
|
||||||
(setq helm--buffer-in-new-frame-p t)
|
(setq +helm--posframe-last-window (selected-window)
|
||||||
|
helm--buffer-in-new-frame-p t)
|
||||||
(posframe-show
|
(posframe-show
|
||||||
(setq +helm--posframe-buffer buffer)
|
(setq +helm--posframe-buffer buffer)
|
||||||
|
:position (point)
|
||||||
:poshandler +helm-posframe-handler
|
:poshandler +helm-posframe-handler
|
||||||
:internal-border-width +helm-posframe-border-width
|
:override-parameters +helm-posframe-parameters)
|
||||||
:respect-header-line t
|
(unless (or (null +helm-posframe-text-scale)
|
||||||
:respect-mode-line t
|
(= +helm-posframe-text-scale 0))
|
||||||
:width
|
|
||||||
(cond ((functionp helm-display-buffer-default-width)
|
|
||||||
(funcall helm-display-buffer-default-width))
|
|
||||||
((integerp helm-display-buffer-default-width)
|
|
||||||
helm-display-buffer-default-width)
|
|
||||||
((floatp helm-display-buffer-default-width)
|
|
||||||
(truncate (* (frame-width) helm-display-buffer-default-width)))
|
|
||||||
((min (max (truncate (* (frame-width) 0.8))
|
|
||||||
100)
|
|
||||||
140)))
|
|
||||||
:height
|
|
||||||
(cond ((functionp helm-display-buffer-default-height)
|
|
||||||
(funcall helm-display-buffer-default-height))
|
|
||||||
((integerp helm-display-buffer-default-height)
|
|
||||||
helm-display-buffer-default-height)
|
|
||||||
((floatp helm-display-buffer-default-height)
|
|
||||||
(truncate (* (frame-height) helm-display-buffer-default-height)))
|
|
||||||
((truncate (* (frame-height) 0.4)))))
|
|
||||||
(when +helm-posframe-font-scale
|
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(text-scale-set +helm-posframe-font-scale))))
|
(text-scale-set +helm-posframe-text-scale))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +helm|posframe-cleanup ()
|
(defun +helm|posframe-cleanup ()
|
||||||
|
@ -54,7 +36,10 @@ bottom, which is easier on the eyes on big displays."
|
||||||
;; Ensure the underlying window is switched to, to ensure that frame is given
|
;; Ensure the underlying window is switched to, to ensure that frame is given
|
||||||
;; proper focus; this gives the modeline a chance to refresh.
|
;; proper focus; this gives the modeline a chance to refresh.
|
||||||
(select-window +helm--posframe-last-window)
|
(select-window +helm--posframe-last-window)
|
||||||
(setq +helm--posframe-last-frame nil)
|
|
||||||
;;
|
;;
|
||||||
(posframe-delete +helm--posframe-buffer))
|
(posframe-delete +helm--posframe-buffer))
|
||||||
|
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +helm*fix-get-font-height (orig-fn position)
|
||||||
|
(ignore-errors (funcall orig-fn position)))
|
||||||
|
|
|
@ -20,13 +20,17 @@ This falls back to git-grep (then grep) if none of these available.")
|
||||||
a cons cell representing the X and Y coordinates. See
|
a cons cell representing the X and Y coordinates. See
|
||||||
`posframe-poshandler-frame-center' as a reference.")
|
`posframe-poshandler-frame-center' as a reference.")
|
||||||
|
|
||||||
(defvar +helm-posframe-font-scale 1
|
(defvar +helm-posframe-text-scale 1
|
||||||
"The text-scale to use in the helm childframe. Set to nil for no scaling. Can
|
"The text-scale to use in the helm childframe. Set to nil for no scaling. Can
|
||||||
be negative.")
|
be negative.")
|
||||||
|
|
||||||
(defvar +helm-posframe-border-width 8
|
(defvar +helm-posframe-parameters
|
||||||
"The text-scale to use in the helm childframe. Set to nil for no scaling. Can
|
'((internal-border-width . 8)
|
||||||
be negative.")
|
(min-width . 80)
|
||||||
|
(min-height . 16)
|
||||||
|
(width . 0.5)
|
||||||
|
(height . 0.55))
|
||||||
|
"TODO")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -78,11 +82,8 @@ be negative.")
|
||||||
|
|
||||||
(when (and EMACS26+ (featurep! +childframe))
|
(when (and EMACS26+ (featurep! +childframe))
|
||||||
(setq helm-display-function #'+helm-posframe-display
|
(setq helm-display-function #'+helm-posframe-display
|
||||||
helm-display-buffer-default-height 0.42
|
|
||||||
helm-echo-input-in-header-line t)
|
helm-echo-input-in-header-line t)
|
||||||
;; Fix "Specified window is not displaying the current buffer" error
|
;; Fix "Specified window is not displaying the current buffer" error
|
||||||
(defun +helm*fix-get-font-height (orig-fn position)
|
|
||||||
(ignore-errors (funcall orig-fn position)))
|
|
||||||
(advice-add #'posframe--get-font-height :around #'+helm*fix-get-font-height))
|
(advice-add #'posframe--get-font-height :around #'+helm*fix-get-font-height))
|
||||||
|
|
||||||
(let ((fuzzy (featurep! +fuzzy)))
|
(let ((fuzzy (featurep! +fuzzy)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue