diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-07 19:12:44 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-07 19:12:44 -0200 |
commit | 726b372ee56a367fd2dc366e05667bbd80282962 (patch) | |
tree | c9381aa8b8101ec91ab8fa7b5e1ee240d4cac8ec | |
parent | ad81dcacfe9ddf57f7e4a113fc14b0a1dce0dcdd (diff) |
Fix unkown owner after creating a comment.
-rw-r--r-- | sx-interaction.el | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index 9e96228..6ecfa38 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -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--add-owner-to-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--add-owner-to-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 |