闲着没事又造了一个轮子,:smile:
maple-explorer 是一个用于快速创建类似neotree文件浏览,或者类似maple-imenu的变量函数浏览的侧边栏的插件,让每个人都能写一个属于自己的侧边栏
-
快速创建一个侧边栏: 只需要定义一个
maple-explorer-NAME-list
的函数,并且返回一个列表(list :name name :value value :face face :click click :status 'close ;; or 'open :children '((child1 child2 ...))
其中child1,child2格式与父列表格式一致,child1中也可以嵌套下一组children,比如我定义一个名为aaa的list的函数:
(defun maple-explorer-aaa-list(&optional isroot) "Get recentf file list ISROOT mean first call." (list :name "aaa" :value "aaa" :face 'font-lock-constant-face :click 'maple-explorer-fold :status 'open :children (list (list :name "aaa_child1" :face 'font-lock-keyword-face :click (lambda() (interactive) (message "bbb"))) (list :name "aaa_child2" :face 'font-lock-comment-face :click (lambda() (interactive) (message "aaaa"))))))
定义好后只要使用
(maple-explorer-define aaa)
就能快速创建一个maple-explorer-aaa
的函数,使用它就能打开一个侧边栏,效果是这样的 -
自定义内容显示: maple-explorer提供了一个
maple-explorer-NAME-name-function
的变量,可用于自定义内容的显示,比如对于一个文件列表,我可以增加自定义图标(defun maple-explorer-icon (str icon) "The ICON of maple-explorer STR." (format "%s %s" (propertize "\t" 'display icon) str)) (defun maple-explorer-icon-file-name(info) "Custom maple-explorer-file INFO icon name." (let ((name (plist-get info :name)) (value (plist-get info :value))) (plist-put info :indent 5) (cond ((or (string= name ".") (string= name "..")) (maple-explorer-icon name (all-the-icons-faicon "folder"))) ((file-directory-p value) (maple-explorer-icon name (if (maple-explorer--is-open info) (all-the-icons-faicon "folder-open") (all-the-icons-faicon "folder")))) (t (maple-explorer-icon name (all-the-icons-icon-for-file value)))))) (setq maple-explorer-file-name-function 'maple-explorer-icon-file-name)
自定义之前是这样的
-
更多信息 maple-explorer目前已实现了
maple-explorer-file ;; 文件浏览 maple-explorer-imenu ;; 函数变量名浏览 maple-explorer-buffer ;; 已打开buffer浏览 maple-explorer-recentf ;; 最近文件浏览 maple-explorer-project ;; 已打开的项目浏览
欢迎各位emacs同道测试