我在Elisp中编写自己的模式.它基本上是一个简单的crud应用程序,显示可以通过迷你缓冲区操作的数据行.我想为这些行创建一个看起来像emacs包管理器的视图:数据列很好地对齐.实现这种观点的最佳方法是什么?
aur*_*amo 21
phils的答案让我走上正轨.虽然在任何地方都没有教程或简单的例子,所以我创建了一个.以下是具有静态数据并可打印当前列ID的列表列表模式衍生的示例:
(define-derived-mode mymode tabulated-list-mode "mymode" "Major mode My Mode, just a test"
(setq tabulated-list-format [("Col1" 18 t)
("Col2" 12 nil)
("Col3" 10 t)
("Col4" 0 nil)])
(setq tabulated-list-padding 2)
(setq tabulated-list-sort-key (cons "Col3" nil))
(tabulated-list-init-header))
(defun print-current-line-id ()
(interactive)
(message (concat "current line ID is: " (tabulated-list-get-id))))
(defun my-listing-command ()
(interactive)
(pop-to-buffer "*MY MODE*" nil)
(mymode)
(setq tabulated-list-entries (list
(list "1" ["1" "2" "3" "4"])
(list "2" ["a" "b" "c" "d"])))
(tabulated-list-print t))
Run Code Online (Sandbox Code Playgroud)