From 1509d09a5ed073688a316660b5e3a2222dbebfca Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 17:20:57 -0200 Subject: Fix outdated references --- sx-interaction.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 4d71c17..e444248 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) " ")))) + (concat (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. -- cgit v1.2.3 From 39dbc7379da010cc3bae479fa70d9724acf169f5 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 18:01:25 -0200 Subject: Don't propertize when composing a comment --- sx-interaction.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index e444248..9e96228 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--format "%@" .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. -- cgit v1.2.3 From 726b372ee56a367fd2dc366e05667bbd80282962 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 19:12:44 -0200 Subject: Fix unkown owner after creating a comment. --- sx-interaction.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sx-interaction.el') 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 -- cgit v1.2.3 From ae3e8ee9d9f792ff8c543c249f6d26fb22ec7965 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 20:30:34 -0200 Subject: Rename add to ensure --- sx-interaction.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 6ecfa38..8b72ea5 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -291,7 +291,7 @@ 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 - (sx--add-owner-to-object (list (cons 'display_name "(You)")) (elt result 0)) + (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))))) @@ -345,7 +345,7 @@ OBJECT can be a question or an answer." (setcar object `(comments . [,comment])))) object) -(defun sx--add-owner-to-object (owner 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))) -- cgit v1.2.3 From a16341cdf93224a399d3b64a8d50c32ce4323f08 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 20:53:34 -0200 Subject: sx--add-answer-to-question-object returns the question --- sx-interaction.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 8b72ea5..97c68b6 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -445,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 -- cgit v1.2.3