Refactor code to update magit's repository list to separate function

This allows easier updates of this list, without having resort to executing the
corresponding code manually.  In the future, we could even update that list
automatically by attaching the new function to some of projectile's hooks or
something.
This commit is contained in:
Daniel - 2021-01-17 09:15:01 +01:00
parent 123c72664b
commit e4f02647a2
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
2 changed files with 19 additions and 13 deletions

15
init.el
View File

@ -617,7 +617,8 @@
db/switch-to-light-theme
keyboard-quit-context+
db/convert-lf-to-crlf-in-buffer
db/convert-crlf-to-lf-in-buffer))
db/convert-crlf-to-lf-in-buffer
db/sync-magit-repos-from-projectile))
(use-package db-hydras
:commands (hydra-toggle/body
@ -1408,17 +1409,7 @@
(global-magit-file-mode -1))
(global-git-commit-mode +1)
(with-demoted-errors "Non-Fatal Error: %s"
(require 'projectile)
(setq magit-repository-directories
(mapcar
(lambda (dir)
(cons (substring dir 0 -1) 0))
(cl-remove-if-not
(lambda (project)
(unless (file-remote-p project)
(file-exists-p (concat project "/.git"))))
projectile-known-projects))))))
(db/sync-magit-repos-from-projectile)))
(use-package magit-repos
:commands (magit-list-repositories))

View File

@ -424,6 +424,21 @@ Does not replace CRLF with CRCRLF, and so on."
(while (re-search-forward "\r\n" nil 'noerror)
(replace-match "\n")))))
(defun db/sync-magit-repos-from-projectile ()
"Update repositories known to magit from projectile's."
(interactive)
(require 'projectile)
(require 'magit)
(setq magit-repository-directories
(mapcar
(lambda (dir)
(cons (substring dir 0 -1) 0))
(cl-remove-if-not
(lambda (project)
(unless (file-remote-p project)
(file-exists-p (concat project "/.git"))))
projectile-known-projects))))
;;; Extend Input Methods