summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-27 06:39:26 -0700
committerFranck Cuny <franck@fcuny.net>2021-10-27 06:39:26 -0700
commitc22a1094945d8e93781adfb86108e1087d5bcc24 (patch)
treea3208447fca947957a3788209b3dc19f227e7914 /emacs
parentaspell: words (diff)
downloademacs.d-c22a1094945d8e93781adfb86108e1087d5bcc24.tar.gz
emacs: different magit setup for work/personal
Work's monorepo is extremely large which is causing performance issues
for magit. But there's magit features that I want to use when working on
personal projects.

Split the configuration between work/personal so that I can still use
what I want when working on my projects.
Diffstat (limited to '')
-rw-r--r--emacs/custom/fcuny-git.el101
1 files changed, 61 insertions, 40 deletions
diff --git a/emacs/custom/fcuny-git.el b/emacs/custom/fcuny-git.el
index b2671c6..5425bb8 100644
--- a/emacs/custom/fcuny-git.el
+++ b/emacs/custom/fcuny-git.el
@@ -17,46 +17,67 @@
   :custom
   (vc-follow-symlinks t)
   :config
-  ;; if we're on darwin, we're on a work laptop, so let's make sure we
-  ;; use the proper `git' binary.
-  (when (string= system-type "darwin")
-    (setq magit-git-executable "/opt/twitter_mde/bin/git"))
-  ;; I want to see these things by default
-  (add-to-list 'magit-section-initial-visibility-alist '(untracked . show))
-  (add-to-list 'magit-section-initial-visibility-alist '(unstaged . show))
-  (add-to-list 'magit-section-initial-visibility-alist '(unpulled . show))
-  (add-to-list 'magit-section-initial-visibility-alist '(unpushed . show))
-  (add-to-list 'magit-section-initial-visibility-alist '(stashes . show))
-  ;; no need to show the last 10 commits, 5 is enough.
-  (setq magit-log-section-commit-count 5)
-  ;; when working with source, some of the hooks are extremely
-  ;; expensive and don't add much values (i.e tags). Let's reduce the
-  ;; list to things that are actually useful. This still takes ~10
-  ;; seconds when running `magit-status'.
-  (setq git-commit-setup-hook
-        '(git-commit-save-message
-          git-commit-turn-on-auto-fill
-          git-commit-turn-on-flyspell
-          git-commit-propertize-diff
-          with-editor-usage-message))
-  (setq magit-refs-sections-hook
-      '(magit-insert-error-header
-        magit-insert-branch-description
-        magit-insert-local-branches))
-  (setq magit-status-sections-hook
-        '(magit-insert-status-headers
-          magit-insert-merge-log
-          magit-insert-rebase-sequence
-          magit-insert-am-sequence
-          magit-insert-sequencer-sequence
-          magit-insert-untracked-files
-          magit-insert-unstaged-changes
-          magit-insert-staged-changes
-          magit-insert-stashes))
-  (setq magit-status-headers-hook
-      '(magit-insert-error-header
-        magit-insert-diff-filter-header
-        magit-insert-head-branch-header)))
+  (defun fcuny/magit-settings-for-work ()
+    "Settings to apply for work. The main monorepo at work is too large for most of the default settings with magit."
+    ;; if we're on darwin, we're on a work laptop, so let's make sure we
+    ;; use the proper `git' binary.
+    (setq magit-git-executable "/opt/twitter_mde/bin/git")
+
+    ;; no need to show the last 10 commits, 5 is enough.
+    (setq magit-log-section-commit-count 5)
+
+    ;; when working with source, some of the hooks are extremely
+    ;; expensive and don't add much values (i.e tags). Let's reduce the
+    ;; list to things that are actually useful. This still takes ~10
+    ;; seconds when running `magit-status'.
+    (setq git-commit-setup-hook
+          '(git-commit-save-message
+            git-commit-turn-on-auto-fill
+            git-commit-turn-on-flyspell
+            git-commit-propertize-diff
+            with-editor-usage-message))
+    (setq magit-refs-sections-hook
+        '(magit-insert-error-header
+          magit-insert-branch-description
+          magit-insert-local-branches))
+    (setq magit-status-sections-hook
+          '(magit-insert-status-headers
+            magit-insert-merge-log
+            magit-insert-rebase-sequence
+            magit-insert-am-sequence
+            magit-insert-sequencer-sequence
+            magit-insert-untracked-files
+            magit-insert-unstaged-changes
+            magit-insert-staged-changes
+            magit-insert-stashes))
+    (setq magit-status-headers-hook
+        '(magit-insert-error-header
+          magit-insert-diff-filter-header
+          magit-insert-head-branch-header)))
+
+  (defun fcuny/magit-settings ()
+    ;; Add a "latest commits" section
+    (magit-add-section-hook 'magit-status-sections-hook
+                            'magit-insert-recent-commits
+                            nil t)
+    (magit-add-section-hook 'magit-status-sections-hook
+                            'magit-insert-unpushed-to-upstream
+                            'magit-insert-unpushed-to-upstream-or-recent
+                            'replace))
+
+  (when (fcuny/check-work-machine-p)
+    (fcuny/magit-settings-for-work)
+    (fcuny/magit-settings))
+
+  :custom
+  (magit-completing-read-function 'ivy-completing-read)
+  (magit-section-initial-visibility-alist
+   '((stashes . show)
+     (unpushed . how)
+     (unpulled . show)
+     (recent . show)
+     (untracked . show)
+     (unstaged . show))))
 
 (use-package magit-repos
   :ensure nil