From 1738ccae4c54cfa8e7ff60ef07b053d9ae75b359 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 20 Dec 2018 09:27:01 -0500 Subject: [PATCH] Support max width/height to be functions --- eldoc-box.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eldoc-box.el b/eldoc-box.el index 579fbe8..62b9958 100644 --- a/eldoc-box.el +++ b/eldoc-box.el @@ -90,11 +90,15 @@ you moved the point to somewhere else (that doesn't have a doc to show)") (defvar eldoc-box-max-pixel-width 800 "Maximum width of doc childframw in pixel. -Consider your machine's screen's resolution when setting this variable.") +Consider your machine's screen's resolution when setting this variable. +Set it to a function with no argument +if you want to dynamically change the maximum width.") (defvar eldoc-box-max-pixel-height 700 "Maximum height of doc childframw in pixel. -Consider your machine's screen's resolution when setting this variable.") +Consider your machine's screen's resolution when setting this variable. +Set it to a function with no argument +if you want to dynamically change the maximum height.") ;;;;; Function (defvar eldoc-box--frame nil ;; A backstage variable @@ -172,8 +176,9 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." (let* ((size (window-text-pixel-size window nil nil - eldoc-box-max-pixel-width - eldoc-box-max-pixel-height t)) + (if (functionp eldoc-box-max-pixel-width) (funcall eldoc-box-max-pixel-width) eldoc-box-max-pixel-width) + (if (functionp eldoc-box-max-pixel-height) (funcall eldoc-box-max-pixel-height) eldoc-box-max-pixel-height) + t)) (width (car size)) (height (cdr size)) (width (+ width (frame-char-width frame))) ; add margin