From e56a0996a2b4ccee873143369b9723ff0971e060 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 30 Jan 2024 08:57:51 -0500 Subject: Add some magit repolist bindings --- emacs/.config/emacs-v2/lisp/kj-bindings.el | 4 ++-- emacs/.config/emacs-v2/lisp/kj-init.el | 34 +++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) (limited to 'emacs/.config/emacs-v2') diff --git a/emacs/.config/emacs-v2/lisp/kj-bindings.el b/emacs/.config/emacs-v2/lisp/kj-bindings.el index 0c0ba47..e01b659 100644 --- a/emacs/.config/emacs-v2/lisp/kj-bindings.el +++ b/emacs/.config/emacs-v2/lisp/kj-bindings.el @@ -9,6 +9,7 @@ ("C-c c" . org-capture) ("M-o" . other-window) ("C-c a m" . notmuch) + ("C-c a g" . magit-list-repositories) ("C-c M" . smerge-ediff) ("C-c b r" . revert-buffer) ("C-c r l" . consult-flymake) @@ -28,7 +29,6 @@ (defvar kj/flymake-repeat-map (make-sparse-keymap "flymake")) (define-repeating-key kj/flymake-repeat-map "n" flymake-goto-next-error "next error") (define-repeating-key kj/flymake-repeat-map "p" flymake-goto-prev-error "prev error") - (define-key kj/flymake-repeat-map (kbd "C-g") '("quit" . ignore)) - ) + (define-key kj/flymake-repeat-map (kbd "C-g") '("quit" . ignore))) (provide 'kj-bindings) diff --git a/emacs/.config/emacs-v2/lisp/kj-init.el b/emacs/.config/emacs-v2/lisp/kj-init.el index 25448f6..e42da4e 100644 --- a/emacs/.config/emacs-v2/lisp/kj-init.el +++ b/emacs/.config/emacs-v2/lisp/kj-init.el @@ -409,7 +409,39 @@ (setq transient-levels-file (expand-file-name "transient/levels.el" kj/cache-dir) transient-values-file (expand-file-name "transient/values.el" kj/cache-dir) transient-history-file (expand-file-name "transient/history.el" kj/cache-dir))) -(use-package magit) + +(defconst kj/git-directory (expand-file-name "~/git")) +(defun kj/read-repository () + (let ((repos + (thread-last + (directory-files "/ssh:dragon.orbekk.com:/storage/projects") + (seq-filter (lambda (f) (not (string-match (rx bol (or "." "..") eol) f))))))) + (thread-last + (completing-read "Repository: " repos) + (concat "ssh://dragon.orbekk.com:/storage/projects/")))) + +(use-package magit + :bind (:map magit-repolist-mode-map + ("c" . magit-clone) + ("i" . magit-init) + ("C" . kj/clone-project)) + :custom + (magit-repository-directories `((,kj/git-directory . 1)) "My git repositories") + (magit-repolist-columns '(("Name" 25 magit-repolist-column-ident nil) + ("Version" 25 magit-repolist-column-version + ((:sort magit-repolist-version<))) + ("BU" 3 magit-repolist-column-unpushed-to-upstream + ((:right-align t) (:sort <))) + ("F" 3 magit-repolist-column-flag + ((:right-align t) (:sort <))) + ("Path" 99 magit-repolist-column-path nil))) + :config + (defun kj/clone-project () + (interactive) + (let ((magit-clone-set-remote.pushDefault t)) + (magit-clone-regular (kj/read-repository) kj/git-directory nil)))) (use-package mixed-pitch :hook -- cgit v1.2.3