aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-12-17 12:36:11 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-12-22 10:46:41 -0200
commit3de378c215fdfa82df821df1339b0f1504d4a469 (patch)
tree224947e940b385e74b9d2b7b317e9ad1e2422ba9
parent8dc020031b0472d8fc5b50037fcc257422f7544f (diff)
Support editing comments.
-rw-r--r--sx-compose.el18
-rw-r--r--sx-interaction.el1
2 files changed, 13 insertions, 6 deletions
diff --git a/sx-compose.el b/sx-compose.el
index 96f47f3..af9d861 100644
--- a/sx-compose.el
+++ b/sx-compose.el
@@ -146,19 +146,22 @@ respectively added locally to `sx-compose-before-send-hook' and
(error "Invalid PARENT"))
(let ((is-question
(and (listp parent)
- (null (cdr (assoc 'answer_id parent))))))
+ (cdr (assoc 'title parent)))))
(with-current-buffer (sx-compose--get-buffer-create site parent)
(sx-compose-mode)
(setq sx-compose--send-function
(if (consp parent)
(sx-assoc-let parent
- (lambda () (sx-method-call (if .title 'questions 'answers)
+ (lambda () (sx-method-call (cond
+ (.title 'questions)
+ (.comment_id 'comments)
+ (t 'answers))
:auth 'warn
:url-method "POST"
:filter sx-browse-filter
:site site
:keywords (sx-compose--generate-keywords is-question)
- :id (or .answer_id .question_id)
+ :id (or .comment_id .answer_id .question_id)
:submethod 'edit)))
(lambda () (sx-method-call 'questions
:auth 'warn
@@ -256,8 +259,13 @@ the id property."
site data)))
(t
(get-buffer-create
- (format "*sx draft edit %s %s*"
- site (sx-assoc-let data (or .answer_id .question_id)))))))
+ (sx-assoc-let data
+ (format "*sx draft edit %s %s %s*"
+ site
+ (cond (.title "question")
+ (.comment_id "comment")
+ (t "answer"))
+ (or .comment_id .answer_id .question_id)))))))
(provide 'sx-compose)
;;; sx-compose.el ends here
diff --git a/sx-interaction.el b/sx-interaction.el
index ea494eb..da08581 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -304,7 +304,6 @@ from context at point."
;; If we ever make an "Edit" button, first arg is a marker.
(when (markerp data) (setq data (sx--data-here)))
(sx-assoc-let data
- (when .comment_id (sx-user-error "Editing comments is not supported yet"))
(let ((buffer (current-buffer)))
(pop-to-buffer
(sx-compose-create