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