Skip to content

Commit

Permalink
Clean-up "comment" functions
Browse files Browse the repository at this point in the history
In the code all the "comment" are treated as a post object.
A post object can be found in a pull-request or an issue for eg.

To avoid confusion it makes more sense to use "post" instead of
"comment" in the function name when handling post object.

Also forge-comment-at-point function has been removed since it's not
used.

Signed-off-by: Julien Masson <[email protected]>
  • Loading branch information
JulienMasson committed Feb 5, 2021
1 parent 23501c4 commit 4179bcb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,12 @@ topic N and modify that instead."

;;; Delete

(defun forge-delete-comment (comment)
"Delete the comment at point."
(interactive (list (or (forge-comment-at-point)
(user-error "There is no comment at point"))))
(when (yes-or-no-p "Do you really want to delete the selected comment? ")
(forge--delete-comment (forge-get-repository t) comment)))
(defun forge-delete-post (post)
"Delete the post at point."
(interactive (list (or (forge-post-at-point)
(user-error "There is no post at point"))))
(when (yes-or-no-p "Do you really want to delete the selected post ? ")
(forge--delete-post (forge-get-repository t) post)))

;;; Branch

Expand Down
2 changes: 1 addition & 1 deletion lisp/forge-github.el
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@
:payload labels
:callback (forge--set-field-callback)))

(cl-defmethod forge--delete-comment
(cl-defmethod forge--delete-post
((_repo forge-github-repository) post)
(forge--ghub-delete post "/repos/:owner/:repo/issues/comments/:number")
(closql-delete post)
Expand Down
2 changes: 1 addition & 1 deletion lisp/forge-gitlab.el
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@
(forge--set-topic-field repo topic 'assignee_ids
(--map (caddr (assoc it users)) assignees))))))

(cl-defmethod forge--delete-comment
(cl-defmethod forge--delete-post
((_repo forge-gitlab-repository) post)
(forge--glab-delete post
(cl-etypecase post
Expand Down
7 changes: 0 additions & 7 deletions lisp/forge-post.el
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@
(defun forge-post-at-point ()
(magit-section-value-if '(issue pullreq post)))

(defun forge-comment-at-point ()
(and (magit-section-value-if '(post))
(let ((post (oref (magit-current-section) value)))
(and (or (forge-pullreq-post-p post)
(forge-issue-post-p post))
post))))

(defun forge-topic-at-point ()
(or (magit-section-value-if '(issue pullreq))
(when-let ((branch (magit-branch-at-point)))
Expand Down
2 changes: 1 addition & 1 deletion lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ identifier."
(let ((map (make-sparse-keymap)))
(define-key map [remap magit-browse-thing] 'forge-browse-post)
(define-key map [remap magit-edit-thing] 'forge-edit-post)
(define-key map (kbd "C-c C-k") 'forge-delete-comment)
(define-key map (kbd "C-c C-k") 'forge-delete-post)
(define-key map (kbd "C-c C-r") 'forge-reply-post)
map))

Expand Down

0 comments on commit 4179bcb

Please sign in to comment.