我在Elisp寫我自己的模式。它基本上是一個簡單的crud應用程序,顯示可以通過minibuffer操縱的數據行。我想爲這些行創建一個看起來像emacs包管理器的視圖:數據列很好地對齊。實現這種觀點的最佳方式是什麼?如何在Emacs Lisp中創建列視圖?
13
A
回答
18
從菲爾斯的回答讓我走上軌道。雖然任何地方都沒有教程或簡單的例子,所以我創建了一個。這裏是一個具有靜態數據,並可以打印當前列的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))
1
如果您查看您提到的軟件包列表功能的代碼,您會發現它使用了package-menu-mode
,它源自tabulated-list-mode
。
- M-X
find-function
RETpackage-menu-mode
RET - C-H˚F
tabulated-list-mode
RET
0
我用組織模式爲這種任務的所有時間。
這應該是您開發的起點,因爲您已經有了很好的表格。
相關問題
- 1. 在Emacs Lisp中創建Windows路徑
- 2. 如何在lisp中創建對列表?
- 3. 如何在Emacs中創建一個臨時函數Lisp
- 4. 如何在emacs lisp函數中搜索
- 5. 如何在Emacs Lisp中連接模式?
- 6. 如何在SQL中創建視圖爲列名創建別名?
- 7. 在Emacs Lisp中字符串的列表
- 8. Lisp Box emacs如何配置?
- 9. LISP。創建對的列表
- 10. 在Emacs Lisp中,如何獲得單個散列鍵?
- 11. 在Emacs Lisp中解析
- 12. 如何使用Emacs Lisp在Emacs中添加日期?
- 13. Emacs Lisp中的PPRINT?
- 14. Emacs Lisp中的strpos
- 15. 如何在普通的lisp中創建一個空序列?
- 16. 如何在lisp中創建一對列表
- 17. Emacs lisp;如何從任何類型的變量中創建一個字符串?
- 18. Emacs Lisp中的GNU + Linux構建框架?
- 19. 如何在emacs中創建空文件?
- 20. 如何在emacs中創建標題行?
- 21. 如何擺脫Emacs Lisp中的maphash?
- 22. 我們如何在列表視圖中創建兩列每行
- 23. 如何在垂直列表視圖中創建水平列表視圖?
- 24. emacs lisp中空列表的乘法
- 25. 如何創建2D列表視圖
- 26. 如何創建2列SQL視圖?
- 27. 如何創建列表視圖onItemclicklistener
- 28. Common Lisp從列表中創建矩陣
- 29. 如何在PHP中創建樹視圖?
- 30. 如何在SmartInspect中創建視圖?