Skip to content

Instantly share code, notes, and snippets.

@nxtr
Last active January 29, 2021 18:19
Show Gist options
  • Save nxtr/a606d4b15dcb2adec3dcb26969b97ab8 to your computer and use it in GitHub Desktop.
Save nxtr/a606d4b15dcb2adec3dcb26969b97ab8 to your computer and use it in GitHub Desktop.
A dynamic and adaptive function used by `ivy-posframe-size-function'
(ivy-posframe-size-function
(lambda ()
(list
:height (or ivy-posframe-height ivy-height)
:width ivy-posframe-width
:min-height (or ivy-posframe-min-height ivy-height)
:min-width (or ivy-posframe-min-width
(let* ((buf-rows (split-string
(with-current-buffer ivy-posframe-buffer
(buffer-string))
"\n"))
(prompt (split-string
(with-temp-buffer
(ivy--insert-prompt)
(buffer-string))
"\n"))
(max-prompt-col (seq-max (seq-map #'length prompt))))
(max (seq-max (seq-map #'length buf-rows))
(+ max-prompt-col (length ivy-text) 2)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment