branch: externals/corfu commit 1fb0435bf50ce9025ca15632ebeab10f60c2cef1 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Lookup 'child-frame-border-width to ensure correct alignment --- corfu.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/corfu.el b/corfu.el index 3c925b3..0bfc143 100644 --- a/corfu.el +++ b/corfu.el @@ -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)