补全列表的图形图标无法显示

最近在 Mac 上直接编译的 master 分支 Emacs,只加了 --with-xwiget。但是启动的时候补全列表显示的是文字图标,以前是图形的图标。请问编译时还需要加什么选项吗?

目前是这个效果:

希望得到的是下面这个效果:
image

是不是没安装 all-the-icons 需要的字体?

这个图标好像是不需要 all-the-icons 支持的,我之前用 nix 安装 Emacs 的时候也没装这个字体,都是正常的。我在 Windows 下卸载了 all-the-icons 还是能正常显示。

试试 emacsq,看是否跟配置有关:

emacsq.sh -P company -M company-mode

image

用你的脚本尝试了,还是没有效果。

我记得这个功能是 Emacs 28 加入的。 因为我刚删了 Nix 系统,不知道少了什么库才造成没法显示。

没开启 svg 支持?

image

https://emacsformacosx.com/ 下载的版本可以复现你的问题。

没加特别的参数,我这样编译的:

$ brew install autoconf automake texinfo gnutls pkg-config libxml2
$ cd ./emacs && ./autogen.sh

$ export LDFLAGS="-L/usr/local/opt/libxml2/lib"
$ export CPPFLAGS="-I/usr/local/opt/libxml2/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

$ ./configure  --with-xwidget
$ make && make install
  1. 你现在 (image-type-available-p 'svg) 结果应该是 nil
  2. configure 加参数 --with-rsvg 重新编译。

这个是 fallback 到了 text-icons 了

(defun company-detect-icons-margin (candidate selected)
  "Margin function which picks the appropriate icon set automatically."
  (if (and (display-graphic-p)
           (image-type-available-p 'svg))
      (cl-case (frame-parameter nil 'background-mode)
        ('light (company-vscode-light-icons-margin candidate selected))
        (t (company-vscode-dark-icons-margin candidate selected)))
    (company-text-icons-margin candidate selected)))

对照一下这个逻辑看下哪里有问题吧。

回一下楼上, --with-rsvg 默认就会启用,除非显式指定 --with-rsvg=no.

或者你可能缺少 librsvg 的库, brew search librsvg 然后再安装一下。

这我倒没太注意。那么楼主应该是没安装 librsvg:

brew install librsvg

这个确实是 nil,但我执行 (require 'svg) 也是成功,也安装了 svg。

@Youmu 多谢,我按你的思路分析一下。

@twlz0ne 估计就是你说的问题。 因为执行(image-type-available-p 'svg) 是 nil,所以 fallback 了。

这只是加载了 svg.el 这个包,并不等于 Emacs 支持 svg。甚至终端下也能加载:

⋊> emacs --batch --eval "(print (and (require 'svg) t))"

t

多谢。我重新编译一次试试看。

:+1: 安装好 librsvg 然后重新编译一次就好了,多谢大佬指点。