From 14409012011d389c70ff79baf6dc3e228b08584c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 16 Nov 2014 10:45:46 +0000 Subject: Call sx-initialize on list-questions Addresses #63 --- sx-question-list.el | 1 + 1 file changed, 1 insertion(+) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index b220097..72eabd3 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -323,6 +323,7 @@ focus the relevant window." (defun list-questions (no-update) "Display a list of StackExchange questions." (interactive "P") + (sx-initialize) (unless (buffer-live-p sx-question-list--buffer) (setq sx-question-list--buffer (generate-new-buffer "*question-list*"))) -- cgit v1.2.3 From 4eb4c2fc612e10c6a2c92bfc89a688ebce1a36e1 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 18 Nov 2014 16:44:17 +0000 Subject: Hidden question functionality implemented in the question list --- sx-question-list.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 72eabd3..0639f3c 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -132,8 +132,20 @@ Letters do not insert themselves; instead, they are commands. ("g" sx-question-list-refresh) (":" sx-question-list-switch-site) ("v" sx-question-list-visit) + ("h" sx-question-list-hide) ([?\r] sx-question-list-display-question))) +(defun sx-question-list-hide (data) + "Hide question under point. +Non-interactively, DATA is a question alist." + (interactive + (list (if (derived-mode-p 'sx-question-list-mode) + (tabulated-list-get-id) + (user-error "Not in `sx-question-list-mode'")))) + (sx-question--mark-hidden data) + (when (called-interactively-p 'any) + (sx-question-list-refresh 'redisplay 'noupdate))) + (defvar sx-question-list--current-page "Latest" ;; Other values (once we implement them) are "Top Voted", ;; "Unanswered", etc. @@ -197,7 +209,8 @@ a new list before redisplaying." (setq sx-question-list--current-dataset question-list) ;; Print the result. (setq tabulated-list-entries - (mapcar #'sx-question-list--print-info question-list))) + (mapcar #'sx-question-list--print-info + (cl-remove-if #'sx-question--hidden-p question-list)))) (when redisplay (tabulated-list-print 'remember))) (defun sx-question-list-visit (&optional data) -- cgit v1.2.3 From d0be11905aea5d86705e86c6b5eed57d2f6bc218 Mon Sep 17 00:00:00 2001 From: Jonathan Leech-Pepin Date: Tue, 18 Nov 2014 12:40:26 -0500 Subject: Implements indication of starred questions in question-list `sx-question-list-favorite` inherits face from `sx-question-list-score-upvoted` Favorite is displayed using char \x2b26 WHITE MEDIUM DIAMOND. --- sx-question-list.el | 64 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 72eabd3..dead68f 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -28,6 +28,7 @@ (require 'sx-site) (require 'sx-question) (require 'sx-question-mode) +(require 'sx-favorites) ;;; Customization @@ -86,6 +87,11 @@ "" :group 'sx-question-list-faces) +(defface sx-question-list-favorite + '((t :inherit sx-question-list-score-upvoted)) + "" + :group 'sx-question-list-faces) + ;;; Mode Definition (define-derived-mode sx-question-list-mode tabulated-list-mode "Question List" @@ -219,32 +225,38 @@ Used in the questions list to indicate a question was updated \"4d ago\"." (defun sx-question-list--print-info (data) "Convert `json-read' DATA into tabulated-list format." (sx-assoc-let data - (list - data - (vector - (list (int-to-string .score) - 'face (if .upvoted 'sx-question-list-score-upvoted - 'sx-question-list-score)) - (list (int-to-string .answer_count) - 'face (if (sx-question--accepted-answer-id data) - 'sx-question-list-answers-accepted - 'sx-question-list-answers)) - (concat - (propertize - .title - 'face (if (sx-question--read-p data) - 'sx-question-list-read-question - ;; Increment `sx-question-list--unread-count' for the mode-line. - (cl-incf sx-question-list--unread-count) - 'sx-question-list-unread-question)) - (propertize " " 'display "\n ") - (propertize (concat (sx-time-since .last_activity_date) - sx-question-list-ago-string) - 'face 'sx-question-list-date) - " " - (propertize (mapconcat #'sx-question--tag-format .tags " ") - 'face 'sx-question-list-tags) - (propertize " " 'display "\n")))))) + (let ((favorite (if (member .question_id + (assoc .site + sx-favorites--user-favorite-list)) + (if (char-displayable-p ?\x2b26) "\x2b26" "*") " "))) + (list + data + (vector + (list (int-to-string .score) + 'face (if .upvoted 'sx-question-list-score-upvoted + 'sx-question-list-score)) + (list (int-to-string .answer_count) + 'face (if (sx-question--accepted-answer-id data) + 'sx-question-list-answers-accepted + 'sx-question-list-answers)) + (concat + (propertize + .title + 'face (if (sx-question--read-p data) + 'sx-question-list-read-question + ;; Increment `sx-question-list--unread-count' for the mode-line. + (cl-incf sx-question-list--unread-count) + 'sx-question-list-unread-question)) + (propertize " " 'display "\n ") + (propertize favorite 'face 'sx-question-list-favorite) + " " + (propertize (concat (sx-time-since .last_activity_date) + sx-question-list-ago-string) + 'face 'sx-question-list-date) + " " + (propertize (mapconcat #'sx-question--tag-format .tags " ") + 'face 'sx-question-list-tags) + (propertize " " 'display "\n"))))))) (defun sx-question-list-view-previous (n) "Hide this question, move to previous one, display it." -- cgit v1.2.3 From cc9e7d491808dda40a0f3f34f0b941f08ed460d8 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 19 Nov 2014 00:00:25 +0000 Subject: Mark as read with "m" Fixes #61 --- sx-question-list.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 7dd0d00..be088c8 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -139,6 +139,7 @@ Letters do not insert themselves; instead, they are commands. (":" sx-question-list-switch-site) ("v" sx-question-list-visit) ("h" sx-question-list-hide) + ("m" sx-question-list-mark-read) ([?\r] sx-question-list-display-question))) (defun sx-question-list-hide (data) @@ -152,6 +153,18 @@ Non-interactively, DATA is a question alist." (when (called-interactively-p 'any) (sx-question-list-refresh 'redisplay 'noupdate))) +(defun sx-question-list-mark-read (data) + "Mark as read question under point. +Non-interactively, DATA is a question alist." + (interactive + (list (if (derived-mode-p 'sx-question-list-mode) + (tabulated-list-get-id) + (user-error "Not in `sx-question-list-mode'")))) + (sx-question--mark-read data) + (sx-question-list-next 1) + (when (called-interactively-p 'any) + (sx-question-list-refresh 'redisplay 'noupdate))) + (defvar sx-question-list--current-page "Latest" ;; Other values (once we implement them) are "Top Voted", ;; "Unanswered", etc. -- cgit v1.2.3