~niklaseklund/egerrit

42fe8fe4c15aa91d75c3f436c428456b7fd405b8 — Niklas Eklund a month ago 987c6da
Add display-buffer action for comment buffer
1 files changed, 27 insertions(+), 9 deletions(-)

M egerrit-comment.el
M egerrit-comment.el => egerrit-comment.el +27 -9
@@ 44,7 44,16 @@

;;;; Variables

(defvar egerrit-comment-hooks nil "Hooks to run when opening a comment.")
(defcustom egerrit-comment-display-buffer-action
  '(display-buffer-in-side-window
    (side . bottom)
    (dedicated . t))
  "The action used to display the comment popup buffer."
  :group 'egerrit
  :type 'list)

(defvar egerrit-comment-hooks nil
  "Hooks to run when opening a comment.")

;;;; Functions



@@ 88,16 97,18 @@ This function will work both for review/feedback comments."
              (egerrit--diff-review-comment)
            (seq-find (lambda (it)
                        (string= (egerrit--conversation-id it) (symbol-name conversation-id)))
                      egerrit--current-entities))))
    (with-current-buffer (egerrit-get-buffer "egerrit-comment")
                      egerrit--current-entities)))
         (buffer (egerrit-get-buffer "egerrit-comment"))
         (window (display-buffer buffer egerrit-comment-display-buffer-action)))
    (with-selected-window window
      (erase-buffer)
      (run-hooks 'egerrit-comment-hooks)
      (egerrit-comment-mode)
      (setq egerrit--current-conversation conversation)
      (when-let ((reply
                  (alist-get "Reply" (egerrit--conversation-comments conversation) nil nil #'string=)))
        (insert (substring-no-properties reply 0 (length reply))))
      (pop-to-buffer (current-buffer)))))
        (insert (substring-no-properties reply 0 (length reply)))))
    (select-window window)))

;;;###autoload
(defun egerrit-kill-comment ()


@@ 182,7 193,8 @@ This function will work both for review/feedback comments."
      (setq comments `(,@comments ("Reply" . ,message))))
    (setf (egerrit--conversation-comments conversation) comments)

    (kill-buffer-and-window)
    (quit-restore-window)

    (with-current-buffer (egerrit-get-buffer "egerrit-conversations")
      ;; Update conversation
      (setq egerrit--current-entities


@@ 203,8 215,14 @@ This function will work both for review/feedback comments."
      (read-only-mode)
      (egerrit--goto-to-conversation (intern id))
      (when (window-live-p (get-buffer-window (current-buffer)))
        (recenter)
        (select-window (get-buffer-window (current-buffer)))))))
        (select-window (get-buffer-window (current-buffer)))
        (recenter)))))

;;;###autoload
(defun egerrit-quit-comment ()
  "Quit the comment."
  (interactive)
  (quit-restore-window))

;;;; Support functions



@@ 351,7 369,7 @@ This comment is based on highlight in diff buffer."
  :lighter " Egerrit Comment"
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map (kbd "C-c C-c") #'egerrit-complete-comment)
            (define-key map (kbd "C-c C-k") #'kill-buffer-and-window)
            (define-key map (kbd "C-c C-k") #'egerrit-quit-comment)
            map))

(provide 'egerrit-comment)