Emacs的all-the-Icons插件
序言
在某篇文章中,看到别人提到一个叫做org-agenda-category-icons
的东西。
搜了一下发现原来这是一个 Emacs 的第三方插件,用来给 org-mode 中的分类添加图标的。而之所以可以这么做,得益于 org-mode 本身提供了一个叫做org-agenda-category-icon-alist
的变量,可以定义分类名字和图标之间的关系,并在 agenda 的视图中显示出来。在 org-agenda-category-icons 的页面中,它又提到了另外一个插件 all-the-icons 中,它内置了许多图标,我们可以直接使用,而不需要逐个去寻找图片文件并下载下来。
安装 all-the-icons
先找个地方将 all-the-icons 下载下来
git clone 'https://github.com/domtronn/all-the-icons.el.git'
然后在 Emacs 的启动配置中加载它
(add-to-list 'load-path "/Users/liutos/Projects/all-the-icons.el/")
(when (display-graphic-p)
(require 'all-the-icons))
成功调用require
后,还要让 all-the-icons 帮我们下载字体。在 Emacs 中运行如下命令
M-x all-the-icons-install-fonts
运行完毕输出如下信息
使用 all-the-icons 作为 org-mode 的分类图标
使用C-h v
可以看到变量org-agenda-category-icon-alist
中接收的图标的参数有两种
尽管没有找到资料说明string containing image data
到底是什么格式,但幸好网上有其他人在不为人知的角落中提供了一则参考例子
依葫芦画瓢,我给自己设置了如下的分类图标
(setq org-agenda-category-icon-alist
(list
`("^me$" ,(list (all-the-icons-faicon "user" :height 1.2)))
`("编程爱好者" ,(list (all-the-icons-material "code" :height 1.2)))
`("电影" ,(list (all-the-icons-material "movie" :height 1.2)))
`("家庭" ,(list (all-the-icons-faicon "bed" :height 1.2)))
`("技术写作" ,(list (all-the-icons-material "publish" :height 1.2)))
`("漫画" ,(list (all-the-icons-faicon "book" :height 1.2)))
`("优化电脑使用体验" ,(list (all-the-icons-material "computer" :height 1.2)))
`("战舰少女" ,(list (all-the-icons-material "games" :height 1.2)))))
效果如下图所示
全文完。