用来显示一个简单的列表, 类似于dired的文件列表, 或者ibuffer的列表
可以用内置的tabulated-list-mode
Example
(define-derived-mode my/tab-list-mode tabulated-list-mode "Modules"
(setq tabulated-list-padding 0)
(setq tabulated-list-format
`[("Name" 20 nil)
("Age" 20 nil)
("Gender" 20 nil)])
(tabulated-list-init-header)
(add-hook 'tabulated-list-revert-hook 'my/tab-do-refresh nil t))
(defun my/tab-do-refresh ()
(setq tabulated-list-entries '((1 ["John" "20" "Male"])
(2 ["Mary" "18" "Female"])
(3 ["Michael" "33" "Male"]))))
(defun my/show-tab ()
(interactive)
(let ((buf (get-buffer-create "*My tab*")))
(switch-to-buffer buf)
(my/tab-list-mode)
(my/tab-do-refresh)
(tabulated-list-print)))
3 个赞
看上去不错, 能实现单选或多选的功能吗?
可以参照 M-x list-packages 的特性,它用的就是这个 Mode,选项应该是用 Marker 表示,跟 Dired 类似。
- Table component for Emacs Lisp GitHub - kiwanami/emacs-ctable: Table Component for elisp
- Implementation of javax.swing.JTable for Emacs GitHub - Fuco1/ETable: An implementation of JTable for emacs.
- Library to create and display hierarchy structures GitHub - DamienCassou/hierarchy: Emacs library to create, query, navigate and display hierarchy structures
- a library of user interface components Top (The Emacs Widget Library)
1 个赞
可以用 text property 保存选择信息,然后用 at-point 函数提取
1 个赞
好, 学习一下.
上面列出来的都不算「简单易用」,包括自带的 tabulated-list-mode 也不非常容易使用。
最好说一下希望有什么功能,毕竟只是显示列表的话,找一个空buffer打印出来就行。
跟dired和ibuffer接近,可以标记选择,然后批量操作,比如删除。可动态更新单个项内容。主要就这些。比较通用的操作。
用来管理工程项目列表的。