Skip to content

Commit

Permalink
[wip] dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Oct 12, 2023
1 parent 922a059 commit 42a2167
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 31 deletions.
50 changes: 22 additions & 28 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,27 @@ Takes the pull-request as only argument and must return a directory."
;;;###autoload (autoload 'forge-dispatch "forge-commands" nil t)
(transient-define-prefix forge-dispatch ()
"Dispatch a forge command."
[["Fetch"
:if forge-get-repository-p
("f f" "all topics" forge-pull)
("f t" "one topic" forge-pull-topic)
("f n" "notifications" forge-pull-notifications)
"""Create"
("c i" "issue" forge-create-issue)
("c p" "pull-request" forge-create-pullreq)
("c u" "pull-request from issue" forge-create-pullreq-from-issue
[:if forge-get-repository-p
["Create"
("c i" "issue" forge-create-issue)
("c p" "pull-request" forge-create-pullreq)
("c u" "pull-request from issue"
forge-create-pullreq-from-issue
:if forge-get-github-repository-p)
("c f" "fork or remote" forge-fork)
"""Merge"
(7 "M " "merge using API" forge-merge)]
("c f" "fork or remote" forge-fork)]]
[:if forge-get-repository-p
["List"
("l t" "topics..." forge-list-topics-menu
:transient transient--do-exit)
("l n" "notifications..." forge-list-notifications)
("l r" "repositories" forge-list-repositories)]
["Fetch"
("f f" "all topics " forge-pull)
("f t" "one topic" forge-pull-topic)
("f n" "notifications" forge-pull-notifications)]
["API Commands"
:if forge-get-repository-p
("l t" "topics" forge-list-topics)
("l i" "issues" forge-list-issues)
("l p" "pull-requests" forge-list-pullreqs)
("l n" "notifications" forge-list-notifications)
("l r" "repositories" forge-list-repositories)
(7 "l a" "awaiting review" forge-list-requested-reviews)
(7 "n i" "labeled issues" forge-list-labeled-issues)
(7 "n p" "labeled pull-requests" forge-list-labeled-pullreqs)
(7 "m i" "authored issues" forge-list-authored-issues)
(7 "m p" "authored pull-requests" forge-list-authored-pullreqs)
(7 "o i" "owned issues" forge-list-owned-issues)
(7 "o p" "owned pull-requests" forge-list-owned-pullreqs)
(7 "o r" "owned repositories" forge-list-owned-repositories)]]
(7 "M " "merge" forge-merge)]]
[:if forge-get-repository-p
[:description (lambda () (forge-dispatch--format-description "Visit"))
("v t" "topic" forge-visit-topic)
Expand All @@ -109,9 +102,10 @@ Takes the pull-request as only argument and must return a directory."
"Forge doesn't know about this Git repository yet"
"Not inside a Git repository"))
:if-not forge-get-repository-p
("a" "add repository to database" forge-add-repository)
("f" "fetch notifications" forge-pull-notifications)
("l" "list notifications" forge-list-notifications)]])
("a" "add this repository to database" forge-add-repository
:inapt-if-not forge-get-repository-p)
("f" "fetch notifications" forge-pull-notifications)
("l" "list notifications" forge-list-notifications)]])

(defun forge-dispatch--format-description (action)
(concat
Expand Down
52 changes: 50 additions & 2 deletions lisp/forge-list.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,18 @@ This is a list of package names. Used by the commands
"RET" #'forge-visit-this-topic
"<return>" #'forge-visit-this-topic
"o" #'forge-browse-this-topic
"L" #'forge-list-topics-menu
"'" #'forge-dispatch
"?" #'magit-dispatch)

(defvar-keymap forge-issue-list-mode-map
:doc "Local keymap for Forge-Topic-List mode buffers."
:parent forge-topic-list-mode-map)

(defvar-keymap forge-pullreq-list-mode-map
:doc "Local keymap for Forge-Topic-List mode buffers."
:parent forge-topic-list-mode-map)

(define-derived-mode forge-topic-list-mode tabulated-list-mode
"Topics"
"Major mode for browsing a list of topics."
Expand All @@ -133,7 +142,8 @@ This is a list of package names. Used by the commands
(topdir (magit-toplevel)))
(with-current-buffer
(get-buffer-create
(or buffer-name
(or "*TOPICS*" ;TODO
buffer-name
(format "*%s: %s/%s*"
(substring (symbol-name mode) 0 -5)
(oref repo owner)
Expand Down Expand Up @@ -231,6 +241,44 @@ This is a list of package names. Used by the commands
args))))

;;; Commands
;;;; Refresh

;;;###autoload (autoload 'forge-list-topics-menu "forge-list" nil t)
(transient-define-prefix forge-list-topics-menu ()
"TODO"
:transient-suffix t
:transient-non-suffix t
[
["Type"
("*" "topics" forge-list-topics-menu :inapt-if-non-nil t)
("n" "notifications" forge-list-notifications)
("r" "repositories" forge-list-repositories)
;; ("m" "owned repositories" forge-list-owned-repositories)
]
["Subtype"
("t" "topics" forge-list-topics)
("i" "issues" forge-list-issues)
("p" "pull-requests" forge-list-pullreqs)
]
["Scope" ;TODO actual scope switching
("o i" "per-repository" forge-list-owned-issues)
("o p" "global" forge-list-owned-pullreqs)
;;("o i" "owned issues" forge-list-owned-issues)
;;("o p" "owned pull-requests" forge-list-owned-pullreqs)
]
["Selection"
("l i" "labeled issues" forge-list-labeled-issues
;;:inapt-if
)
("l p" "labeled pull-requests" forge-list-labeled-pullreqs)
("a i" "authored issues" forge-list-authored-issues)
("a p" "authored pull-requests" forge-list-authored-pullreqs)
("R " "awaiting review" forge-list-requested-reviews)
]]
[["Set notification state"
("d" forge-toggle-done)
("x" forge-toggle-read)]])

;;;; Topic

;;;###autoload
Expand Down Expand Up @@ -339,7 +387,7 @@ Only Github is supported for now."
"List notifications."
(interactive)
(forge-notifications-setup-buffer)
(call-interactively #'forge-notifications-menu))
(call-interactively #'forge-notifications-menu)) ;TODO

;;;; Repository

Expand Down
2 changes: 1 addition & 1 deletion lisp/forge.el
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If you want to disable this, then you must set this to nil before

;;;###autoload
(defvar forge-add-default-bindings t
"Whether to add Forge's bindings to various Magit keymaps.
s "Whether to add Forge's bindings to various Magit keymaps.
If you want to disable this, then you must set this to nil before
`magit' is loaded. If you do it before `forge' but after `magit'
Expand Down

0 comments on commit 42a2167

Please sign in to comment.