vertico-posframe, 喜欢的同学拿去

已纠正写法,谢谢 @Voleking 大佬~

楼歪了,让我扶正过来。目前已实现结果框的边缘大小与company-mode的margin大小一致,即一个字符宽度;两者与高亮行字符对齐一致:

  (setq selectrum-display-action '(selectrum-posframe))
  
  (defcustom selectrum-posframe-fringe 1
    "The width of selectrum-posframe-fringe."
    :type 'number)

  (defun posframe-poshandler-point-bottom-left-corner-fringe (info)
    "Poshandler looks like company-posframe."
    (let* ((parent-window (plist-get info :parent-window))
           (point (with-current-buffer (window-buffer parent-window)
                    (max (line-beginning-position)
			 (- (plist-get info :position) selectrum-posframe-fringe))))
           (info (plist-put info :position-info (posn-at-point point parent-window))))
      (posframe-poshandler-point-bottom-left-corner info)))

  (defun selectrum-posframe (buffer _alist)
    "Function used by `selectrum-display-action."
    (frame-root-window
     (posframe-show buffer
		    :min-height 10
                    :min-width 30
		    :background-color "#b4eeb4" ;; hl-line background color
                    :left-fringe (* (frame-char-width) selectrum-posframe-fringe)
                    :right-fringe (* (frame-char-width) selectrum-posframe-fringe)
                    :poshandler 'posframe-poshandler-point-bottom-left-corner-fringe
		    :lines-truncate t
		    )))
  (set-face-attribute 'fringe nil :background 'unspecified :inherit 'hl-line)
  (add-hook 'minibuffer-exit-hook 'posframe-delete-all)

TODO:

1、隐藏 “25 M-x”,即 candidates count 和 minibuffer-prompt ;

2、调整“结果框posframe”的宽高使之随candidaes长短多少而变化;

3、fringe背景色与“select-candidate”背景色不一致,可以考虑去掉finge,取而代之的是给每个candidate双侧加上一个字符宽度。

非IT专业,搞不动了……希望各位大佬出手相助 :pray: :pray: :pray: