diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2021-05-07 17:52:01 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2021-05-07 17:52:01 +0200 |
| commit | 1fb0435bf50ce9025ca15632ebeab10f60c2cef1 (patch) | |
| tree | 956c460c3a0f6f434204f9e2f6c6e2e6671f2c1a | |
| parent | 1f317e88a1e4a2c6831e1b4d329e20f4ef9fccbf (diff) | |
Lookup 'child-frame-border-width to ensure correct alignment
| -rw-r--r-- | corfu.el | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -174,14 +174,13 @@ Set to nil in order to disable confirmation." corfu--extra-properties) "Buffer-local state variables used by Corfu.") -(defvar corfu--child-frame-params +(defvar corfu--frame-parameters '((no-accept-focus . t) (min-width . t) (min-height . t) (width . 0) (height . 0) (border-width . 0) - (internal-border-width . 1) (child-frame-border-width . 1) (left-fringe . 0) (right-fringe . 0) @@ -201,7 +200,7 @@ Set to nil in order to disable confirmation." "Default child frame parameters.") ;; Function adapted from posframe.el by tumashu -(defun corfu--child-frame (x y width height content) +(defun corfu--make-frame (x y width height content) "Show child frame at X/Y with WIDTH/HEIGHT and CONTENT." (let* ((window-min-height 1) (window-min-width 1) @@ -221,7 +220,9 @@ Set to nil in order to disable confirmation." (edge (window-inside-pixel-edges)) (fr face-remapping-alist) (lh (default-line-height)) - (x (max 0 (min (+ (car edge) x -1) (- (frame-pixel-width) width)))) + (x (max 0 (min (+ (car edge) x + (- (alist-get 'child-frame-border-width corfu--frame-parameters))) + (- (frame-pixel-width) width)))) (yb (+ (cadr edge) y lh)) (y (if (> (+ yb height lh lh) (frame-pixel-height)) (- yb height lh 1) @@ -252,7 +253,10 @@ Set to nil in order to disable confirmation." (setq corfu--frame (make-frame `((parent-frame . ,(window-frame)) (line-spacing . ,line-spacing) - ,@corfu--child-frame-params)))) + ;; Set `internal-border-width' for Emacs 27 + (internal-border-width + . ,(alist-get 'child-frame-border-width corfu--frame-parameters)) + ,@corfu--frame-parameters)))) (set-face-background (if (facep 'child-frame-border) 'child-frame-border 'internal-border) (face-attribute 'corfu-border :background) corfu--frame) @@ -285,7 +289,7 @@ Set to nil in order to disable confirmation." (mapcar #'string-width lines)))) (row 0) (pos (posn-x-y (posn-at-point pos)))) - (corfu--child-frame + (corfu--make-frame (- (or (car pos) 0) mw) (or (cdr pos) 0) (+ (* width cw) mw mw) (* (length lines) ch) (mapconcat (lambda (line) |
