浏览代码

Add tabulated

master
10sr 6 年前
父节点
当前提交
2c90c7836d
签署人:: 10sr GPG 密钥 ID: 7BEC428194130EB2
共有 1 个文件被更改,包括 36 次插入1 次删除
  1. +36
    -1
      emacs.el

+ 36
- 1
emacs.el 查看文件

@@ -2202,7 +2202,7 @@ files to choose from. It defaults to the whole recent list.
If optional argument BUFFER-NAME is non-nil, it is a buffer name to
use for the buffer. It defaults to \"*recetf-show*\"."
(interactive)
(let ((bf (recently-show-create-buffer files buffer-name)))
(let ((bf (recently-show--create-buffer-tabulated files buffer-name)))
(if bf
(progn
;; (recently-save-list)
@@ -2214,6 +2214,41 @@ use for the buffer. It defaults to \"*recetf-show*\"."
(shrink-window-if-larger-than-buffer (selected-window)))
(message "No recent file!"))))

(defun recently-show--create-buffer-tabulated (&optional files buffer-name)
"Create buffer listing recently files FILES."
(let ((bname (or buffer-name
"*recently-show-tabulated*"))
(list (or files
(progn
(recently-reload)
recently-list))))
(when list
(when (get-buffer bname)
(kill-buffer bname))
(with-current-buffer (get-buffer-create bname)
(setq tabulated-list-format
`[("Name" 30 t)
("Full Path" 0 t)])
;; (setq tabulated-list-sort-key (cons "Name" nil))
(setq tabulated-list-entries
(mapcar (lambda (f)
(list f
(vector (file-name-nondirectory f) f)))
;; list
recently-list
))
(recently-show-tabulated-mode)
(current-buffer)))))

(define-derived-mode recently-show-tabulated-mode tabulated-list-mode "Recently Show"
"Major mode for browsing recently opened files and directories."
(setq tabulated-list-padding 2)
;; TODO: Implement revert
;; (add-hook 'tabulated-list-revert-hook 'recently-reload nil t)
;; TODO: Implement open
(tabulated-list-init-header)
(tabulated-list-print nil nil))

(defun recently-show-create-buffer (&optional files buffer-name)
"Create buffer listing recently files."
(let ((bname (or buffer-name


正在加载...
取消
保存