怎么让 overlay 的字符串不是插入,而是覆盖于文本上?

效果就像 company 那样,怎么让下面这个hehe显示在某个(point)正下方呢?

(with-temp-buffer
  (insert "hehe")
  (add-text-properties (point-min) (point-max) `(face (:background ,bc :foreground ,fc)))
  (overlay-put overlay 'before-string (buffer-string)))

在m-x info中搜索display

或是直接看company的代码

1 个赞

原来是把before-string换成display。同时还要注意 point 的范围,这个范围会被整个替换。如果要达到 company 的效果,下一行不够应该还需要先填充。