emacs - 如何在 Emacs Lisp 中创建列 View ?

标签 emacs lisp elisp

我正在用 Elisp 编写自己的模式。它基本上是一个简单的 crud 应用程序,显示可以通过迷你缓冲区操作的数据行。我想为这些行创建一个 View ,它看起来像 emacs 包管理器:数据列很好地对齐。实现这种观点的最佳方式是什么?

最佳答案

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))

关于emacs - 如何在 Emacs Lisp 中创建列 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11272632/

相关文章:

emacs - 如何设置 Emacs 主题?

logging - Emacs 口齿不清 : How to use ad-get-arg and ad-get-args?

emacs - 围绕命令行程序构建 emacs 包装模式的秘诀?

c++ - 如何在 emacs 中使用 gcc-code-assist?

emacs - 根据 PWD 更新多项缓冲区名称

string - Lisp - 将输入拆分为单独的字符串

lisp - 使用 intern 时如何对结构的访问器执行 setf

emacs - 如何使用特定的序言将 Org 模式导出到 LaTeX?

emacs - 根据文件扩展名设置emacs注释样式

unicode - MIT Scheme 在解释器中使用特殊字符