ソースを参照

Implement revert

master
10sr 5年前
コミット
e2ff5f39e7
署名者: 10sr GPGキーID: 7BEC428194130EB2
1個のファイルの変更35行の追加28行の削除
  1. +35
    -28
      emacs.el

+ 35
- 28
emacs.el ファイルの表示

@@ -2120,35 +2120,40 @@ initializing."
(bname (format "*GitWorktree<%s>*" name)))
(with-current-buffer (get-buffer-create bname)
(cd root)
(let ((trees (git-worktree-get-current-trees)))
(setq tabulated-list-entries
(mapcar (lambda (e)
(list e
(vector
(concat (file-relative-name (plist-get e :worktree))
"/")
(or (plist-get e :branch) "")
(plist-get e :head)
)))
trees))
(let ((branch-max-size
(apply 'max
(cl-loop for e in tabulated-list-entries
collect (length (elt (cadr e) 1)))))
(worktree-max-size
(apply 'max
(length "Worktree")
(cl-loop for e in tabulated-list-entries
collect (length (elt (cadr e) 0))))))
(setq tabulated-list-format
`[
("Worktree" ,worktree-max-size t)
("Branch" ,branch-max-size t)
("Head" -1 t)
])))
(git-worktree--set-tabulated-list-mmode-variables)
(git-worktree-mode)
(current-buffer))))
;; ((:worktree "/Users/10sr/.dotfiles" :head "5e7457a8d49ef6a517cdf39d038ba5fdf98dc68e" :branch "refs/heads/master") (:worktree "/Users/10sr/.dotfiles/b1" :head "fa7d868076d807692e35f82ae23596c903fd1117" :branch "refs/heads/b1"))

(defun git-worktree--set-tabulated-list-mmode-variables ()
"Set variables for `tabulated-list-mode'."
(let ((trees (git-worktree-get-current-trees)))
(setq tabulated-list-entries
(mapcar (lambda (e)
(list e
(vector
(concat (file-relative-name (plist-get e :worktree))
"/")
(or (plist-get e :branch) "")
(plist-get e :head)
)))
trees))
(let ((branch-max-size
(apply 'max
(cl-loop for e in tabulated-list-entries
collect (length (elt (cadr e) 1)))))
(worktree-max-size
(apply 'max
(length "Worktree")
(cl-loop for e in tabulated-list-entries
collect (length (elt (cadr e) 0))))))
(setq tabulated-list-format
`[
("Worktree" ,worktree-max-size t)
("Branch" ,branch-max-size t)
("Head" -1 t)
]))))

(defun git-worktree-open (&optional directory)
"Open git worktree list buffer.

@@ -2198,8 +2203,10 @@ initializing."
(define-derived-mode git-worktree-mode tabulated-list-mode "Git-Worktrees"
"Major mode for browsing recently opened files and directories."
(setq tabulated-list-padding 2)
;; TODO: Implement revert
;; (add-hook 'tabulated-list-revert-hook 'git-worktree-mode-reload nil t)
(add-hook 'tabulated-list-revert-hook
'git-worktree--set-tabulated-list-mmode-variables
nil
t)
(tabulated-list-init-header)
(tabulated-list-print nil nil))



読み込み中…
キャンセル
保存