|
143 | 143 | ((topic)
|
144 | 144 | (magit-checkout info)))
|
145 | 145 |
|
146 |
| -(add-hook 'magit-after-insert-stashes-hook 'magit-insert-topics) |
147 |
| - |
148 |
| -(add-hook 'magit-create-branch-command-hook 'magit-topgit-create-branch) |
149 |
| -(add-hook 'magit-pull-command-hook 'magit-topgit-pull) |
150 |
| -(add-hook 'magit-remote-update-command-hook 'magit-topgit-remote-update) |
151 |
| -(add-hook 'magit-push-command-hook 'magit-topgit-push) |
152 |
| - |
153 | 146 | (defun magit-topgit-get-top-bases-color (suffix)
|
154 | 147 | (list nil nil))
|
155 | 148 |
|
156 | 149 | (defun magit-topgit-get-remote-top-bases-color (suffix)
|
157 | 150 | (when (string-match "^\\(?:[^/]+\\)/top-bases" suffix)
|
158 | 151 | (list nil nil)))
|
159 | 152 |
|
160 |
| -;; hide refs in the top-bases namespace, as they're not meant for the user |
161 |
| -(add-to-list 'magit-refs-namespaces |
162 |
| - '("top-bases" magit-topgit-get-top-bases-color)) |
163 |
| - |
164 |
| -;; same thing for top-bases namespace in any remote |
165 |
| -(add-hook 'magit-log-remotes-color-hook |
166 |
| - 'magit-topgit-get-remote-top-bases-color) |
| 153 | +(defconst magit-topgit-ignored-namespace |
| 154 | + '("top-bases" magit-topgit-get-top-bases-color)) |
| 155 | + |
| 156 | +;;;###autoload |
| 157 | +(define-minor-mode magit-topgit-mode "Topgit support for Magit" |
| 158 | + :lighter " Topgit" :require 'magit-topgit |
| 159 | + (or (derived-mode-p 'magit-mode) |
| 160 | + (error "This mode only makes sense with magit")) |
| 161 | + (if magit-topgit-mode |
| 162 | + (progn |
| 163 | + (add-hook 'magit-after-insert-stashes-hook 'magit-insert-topics nil t) |
| 164 | + (add-hook 'magit-create-branch-command-hook 'magit-topgit-create-branch nil t) |
| 165 | + (add-hook 'magit-pull-command-hook 'magit-topgit-pull nil t) |
| 166 | + (add-hook 'magit-remote-update-command-hook 'magit-topgit-remote-update nil t) |
| 167 | + (add-hook 'magit-push-command-hook 'magit-topgit-push nil t) |
| 168 | + ;; hide refs for top-bases namespace in any remote |
| 169 | + (add-hook 'magit-log-remotes-color-hook |
| 170 | + 'magit-topgit-get-remote-top-bases-color) |
| 171 | + ;; hide refs in the top-bases namespace, as they're not meant for the user |
| 172 | + (add-to-list 'magit-refs-namespaces magit-topgit-ignored-namespace)) |
| 173 | + (progn |
| 174 | + (remove-hook 'magit-after-insert-stashes-hook 'magit-insert-topics t) |
| 175 | + (remove-hook 'magit-create-branch-command-hook 'magit-topgit-create-branch t) |
| 176 | + (remove-hook 'magit-pull-command-hook 'magit-topgit-pull t) |
| 177 | + (remove-hook 'magit-remote-update-command-hook 'magit-topgit-remote-update t) |
| 178 | + (remove-hook 'magit-push-command-hook 'magit-topgit-push t) |
| 179 | + (remove-hook 'magit-log-remotes-color-hook |
| 180 | + 'magit-topgit-get-remote-top-bases-color) |
| 181 | + (delete magit-topgit-ignored-namespace magit-refs-namespaces))) |
| 182 | + (when (called-interactively-p 'any) |
| 183 | + (magit-refresh))) |
| 184 | + |
| 185 | +;;;###autoload |
| 186 | +(defun turn-on-magit-topgit () |
| 187 | + "Unconditionally turn on `magit-topgit-mode'." |
| 188 | + (magit-topgit-mode 1)) |
167 | 189 |
|
168 | 190 | (provide 'magit-topgit)
|
169 | 191 | ;;; magit-topgit.el ends here
|
0 commit comments