From 33461aa545bb722f575969339c2dfb97e7744647 Mon Sep 17 00:00:00 2001 From: James Nguyen Date: Sun, 7 Nov 2021 13:31:41 -0500 Subject: [PATCH] Add support for forge --- evil-collection.el | 1 + modes/forge/evil-collection-forge.el | 101 +++++++++++++++++++++++++++ modes/magit/evil-collection-magit.el | 11 --- 3 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 modes/forge/evil-collection-forge.el diff --git a/evil-collection.el b/evil-collection.el index d462937..531672a 100644 --- a/evil-collection.el +++ b/evil-collection.el @@ -165,6 +165,7 @@ This will bind additional find-* type commands, e.g. usages, assignments, etc.." finder flycheck flymake + forge free-keys geiser ggtags diff --git a/modes/forge/evil-collection-forge.el b/modes/forge/evil-collection-forge.el new file mode 100644 index 0000000..64186d5 --- /dev/null +++ b/modes/forge/evil-collection-forge.el @@ -0,0 +1,101 @@ +;;; evil-collection-forge.el --- Evil-based key bindings for forge + +;; Copyright (C) 2021 James Nguyen + +;; Author: James Nguyen +;; Maintainer: James Nguyen +;; Package-Requires: ((emacs "25.1") (evil "1.2.3")) +;; Homepage: https://github.com/emacs-evil/evil-collection +;; Version: 0.4.1 + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation; either version 3, or (at your +;; option) any later version. +;; +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; For a full copy of the GNU General Public License +;; see . + +;;; Commentary: + +;; This library configures Magit and Evil to play well with each +;; other. For some background see: +;; https://github.com/emacs-evil/evil-collection/issues/543. + +;;; Code: + +(require 'evil-collection) +(require 'forge nil t) +(require 'transient nil t) + +(defcustom evil-collection-forge-use-y-for-yank t + "View `evil-collection-magit-state' for more information." + :group 'magit + :type 'boolean) + +(defcustom evil-collection-forge-state + (if evil-collection-forge-use-y-for-yank 'normal 'motion) + "State to use for forge." + :group 'magit + :type 'symbol) + +;;;###autoload +(defun evil-collection-forge-setup () + "Set up `evil' bindings for `magit'." + (let ((states (if evil-collection-forge-use-y-for-yank + `(,evil-collection-forge-state visual) + `(,evil-collection-forge-state)))) + (dolist (state states) + (evil-collection-define-key state 'magit-mode-map "@" 'forge-dispatch) + + (evil-collection-define-key + state 'magit-commit-section-map + [remap magit-browse-thing] 'forge-browse-dwim) + (evil-collection-define-key + state 'magit-remote-section-map + [remap magit-browse-thing] 'forge-browse-remote) + (evil-collection-define-key + state 'magit-branch-section-map + [remap magit-browse-thing] 'forge-browse-branch) + + (evil-collection-define-key + state 'magit-commit-section-map (kbd "C-c C-v") 'forge-visit-topic) + (evil-collection-define-key + state 'magit-branch-section-map (kbd "C-c C-v") 'forge-visit-topic))) + + ;; https://github.com/magit/forge/blob/master/lisp/forge.el + + (transient-append-suffix 'magit-dispatch "!" + '("@" "Forge" forge-dispatch)) ;; N -> @ + + (transient-append-suffix 'magit-fetch "m" + '("n" "forge topics" forge-pull)) + (transient-append-suffix 'magit-fetch "n" + '("N" "forge notifications" forge-pull-notifications)) + (transient-append-suffix 'magit-pull "m" + '("n" "forge topics" forge-pull)) + (transient-append-suffix 'magit-pull "n" + '("N" "forge notifications" forge-pull-notifications)) + (transient-append-suffix 'magit-branch "w" + '("n" "pull-request" forge-checkout-pullreq)) + (transient-append-suffix 'magit-branch "W" + '("N" "from pull-request" forge-branch-pullreq)) + (transient-append-suffix 'magit-worktree "c" + '("n" "pull-request worktree" forge-checkout-worktree)) + (transient-append-suffix 'magit-status-jump "w" + '("Np" "pull-requests" forge-jump-to-pullreqs)) + (transient-append-suffix 'magit-status-jump "Np" + '("Ni" "issues" forge-jump-to-issues)) + (transient-append-suffix 'magit-merge "a" + '(7 "M" "Merge using API" forge-merge))) + +;;; evil-collection-forge.el ends soon +(provide 'evil-collection-forge) +;; Local Variables: +;; End: +;;; evil-collection-forge.el ends here diff --git a/modes/magit/evil-collection-magit.el b/modes/magit/evil-collection-magit.el index 3f788b6..28eca6c 100644 --- a/modes/magit/evil-collection-magit.el +++ b/modes/magit/evil-collection-magit.el @@ -294,7 +294,6 @@ When this option is enabled, the stash popup is available on \"Z\"." (,states magit-mode-map "'" magit-submodule "o") (,states magit-mode-map "\"" magit-subtree "O") (,states magit-mode-map "=" magit-diff-less-context "-") - (,states magit-mode-map "@" forge-dispatch) (,states magit-mode-map "j" evil-next-line) (,states magit-mode-map "k" evil-previous-line) (,states magit-mode-map "gg" evil-goto-first-line) @@ -600,16 +599,6 @@ evil-collection-magit affects.") (unless evil-collection-magit-popup-keys-changed (dolist (change evil-collection-magit-popup-changes) (apply #'evil-collection-magit-change-popup-key change)) - (with-eval-after-load 'forge - ;; When `forge' is loaded, it maps `forge-dispatch' to ' key which is - ;; set for `magit-submodule', wiping it so we add it back after `forge' - ;; loads. - (transient-append-suffix 'magit-dispatch "M" - '("'" "Submodule" magit-submodule)) - ;; Clear `forge' key and re-add back in as "@". - (transient-remove-suffix 'magit-dispatch 'forge-dispatch) - (transient-append-suffix 'magit-dispatch "!" - '("@" "Forge" forge-dispatch))) (setq evil-collection-magit-popup-keys-changed t))) (defun evil-collection-magit-revert-popups ()