aboutsummaryrefslogtreecommitdiff
path: root/sx-interaction.el
diff options
context:
space:
mode:
Diffstat (limited to 'sx-interaction.el')
-rw-r--r--sx-interaction.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/sx-interaction.el b/sx-interaction.el
index 4d71c17..97c68b6 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -272,7 +272,7 @@ TEXT is a string. Interactively, it is read from the minibufer."
(setq text (read-string
"Comment text: "
(when .comment_id
- (concat (sx--user-@name .owner) " "))))
+ (substring-no-properties (sx-user--format "%@ " .owner)))))
(while (not (sx--comment-valid-p text 'silent))
(setq text (read-string "Comment text (between 16 and 600 characters): " text))))
;; If non-interactive, `text' could be anything.
@@ -291,10 +291,8 @@ TEXT is a string. Interactively, it is read from the minibufer."
;; The api returns the new DATA.
(when (> (length result) 0)
(sx--add-comment-to-object
- (elt result 0)
- (if .post_id
- (sx--get-post .post_type .site_par .post_id)
- data))
+ (sx--ensure-owner-in-object (list (cons 'display_name "(You)")) (elt result 0))
+ (if .post_id (sx--get-post .post_type .site_par .post_id) data))
;; Display the changes in `data'.
(sx--maybe-update-display)))))
@@ -344,7 +342,15 @@ OBJECT can be a question or an answer."
(list comment)))))
;; No previous comments, add it manually.
(setcdr object (cons (car object) (cdr object)))
- (setcar object `(comments . [,comment])))))
+ (setcar object `(comments . [,comment]))))
+ object)
+
+(defun sx--ensure-owner-in-object (owner object)
+ "Add `owner' property with value OWNER to OBJECT."
+ (unless (cdr-safe (assq 'owner object))
+ (setcdr object (cons (car object) (cdr object)))
+ (setcar object `(owner . ,owner)))
+ object)
;;; Editing
@@ -439,7 +445,8 @@ context at point. "
(append (cdr cell) (list answer))))
;; No previous comments, add it manually.
(setcdr question (cons (car question) (cdr question)))
- (setcar question `(answers . [,answer])))))
+ (setcar question `(answers . [,answer])))
+ question))
(provide 'sx-interaction)
;;; sx-interaction.el ends here