如上图,在Emacs启动之后会新建一个名为Startup Log的缓冲区,在其中显示ELisp扩展包的启动状态。代码如下:
(defmacro require-maybe (feature &optional file)
"*Try to require FEATURE, but don't signal an error if `require' fails."
`(let ((require-result (require ,feature ,file 'noerror)))
(with-current-buffer (get-buffer-create "*Startup Log*")
(let* ((startup-log-format-string-prefix "%-20s--------[")
(startup-log-format-string-postfix "%s")
(startup-status (if require-result "LOADED" "FAILED"))
(startup-status-face `(face (:foreground
,(if require-result "green" "red")))))
(insert (format startup-log-format-string-prefix ,feature))
(let ((start-pos (point)))
(insert (format startup-log-format-string-postfix startup-status))
(add-text-properties start-pos (point) startup-status-face)
(insert "]\n"))))
require-result))
(provide 'require-maybe)
在init.el
中首先require 'require-maybe
,然后其他包都以require-maybe 'name
的方式启动即可,如下图所示:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。