~niklaseklund/egerrit

2f5b35f76a37ae64b21bd6d3689950779c1762d3 — Niklas Eklund a month ago ca95020
Add command to publish draft comments
2 files changed, 29 insertions(+), 16 deletions(-)

M egerrit-comment.el
M egerrit-conversation.el
M egerrit-comment.el => egerrit-comment.el +24 -13
@@ 57,6 57,20 @@

;;;; Functions

(defun egerrit-send-draft-comments ()
  "Send comments as drafts."
  (let ((draft-comments
         (thread-last egerrit--current-entities
                      (seq-map #'egerrit--create-draft-comment)
                      (seq-remove #'null))))

    (seq-map (lambda (it)
               (egerrit-put-draft-comment
                egerrit--current-change
                egerrit--current-revision
                it))
             draft-comments)))

(defun egerrit-post-draft-comments (change revision)
  "Post draft comments on CHANGE's REVISION."
  (let ((url (egerrit-request-url


@@ 150,25 164,15 @@ This function will work both for review/feedback comments."
        (egerrit--goto-to-conversation new-location)
        (recenter)))))


;;;###autoload
(defun egerrit-publish-comments ()
  "Publish comments."
  (interactive)
  (let ((change egerrit--current-change)
        (revision egerrit--current-revision)
        (draft-comments
         (thread-last egerrit--current-entities
                      (seq-map #'egerrit--create-draft-comment)
                      (seq-remove #'null))))
        (revision egerrit--current-revision))

    ;; Send draft comments
    (seq-map (lambda (it)
               (egerrit-put-draft-comment
                egerrit--current-change
                egerrit--current-revision
                it))
             draft-comments)
    ;; Send comments as drafts
    (egerrit-publish-draft-comments)

    ;; Publish draft comments
    (run-with-timer


@@ 178,6 182,13 @@ This function will work both for review/feedback comments."
    (egerrit-quit-review-or-feedback)))

;;;###autoload
(defun egerrit-publish-draft-comments ()
  "Publish comments as drafts."
  (interactive)
  (egerrit-send-draft-comments)
  (egerrit-quit-review-or-feedback))

;;;###autoload
(defun egerrit-complete-comment ()
  "Finalize the comment and refresh the comments buffer."
  (interactive)

M egerrit-conversation.el => egerrit-conversation.el +5 -3
@@ 40,7 40,8 @@
(declare-function egerrit-create-comment "egerrit")
(declare-function egerrit-publish-review-label "egerrit")
(declare-function egerrit-download-change "egerrit")
(declare-function egerrit-publish-comments "egerrit")
(declare-function egerrit-publish-comments "egerrit-comment")
(declare-function egerrit-publish-draft-comments "egerrit-comment")
(declare-function egerrit-yank-url "egerrit")
(declare-function egerrit--create-range "egerrit")



@@ 575,6 576,8 @@ or previous revisions."
(let ((map egerrit-conversation-mode-map))
  (define-key map (kbd "<return>") #'egerrit-visit-conversation)
  (define-key map (kbd "S-<return>") #'egerrit-visit-conversation-source-code)
  (define-key map (kbd "M-n") #'egerrit-next-conversation)
  (define-key map (kbd "M-p") #'egerrit-previous-conversation)
  (define-key map (kbd "C-c '") #'egerrit-create-comment)
  (define-key map (kbd "C-c C-k") #'egerrit-kill-comment)
  (define-key map (kbd "C-c C-i") #'egerrit-open-info)


@@ 582,8 585,7 @@ or previous revisions."
  (define-key map (kbd "C-c C-y") #'egerrit-yank-url)
  (define-key map (kbd "C-c C-t") #'egerrit-toggle-conversation-status)
  (define-key map (kbd "C-c C-r") #'egerrit-publish-review-label)
  (define-key map (kbd "M-n") #'egerrit-next-conversation)
  (define-key map (kbd "M-p") #'egerrit-previous-conversation)
  (define-key map (kbd "C-c C-p") #'egerrit-publish-draft-comments)
  (define-key map (kbd "C-c C-s") #'egerrit-publish-comments))

(provide 'egerrit-conversation)