From 5b255064ba6c73184cc7338914f917538f5b5bbb Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 10:24:58 -0200 Subject: Basic inbox fetching --- sx-inbox.el | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sx-inbox.el (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el new file mode 100644 index 0000000..f58bee4 --- /dev/null +++ b/sx-inbox.el @@ -0,0 +1,68 @@ +p;;; sx-inbox.el --- Base question logic. -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 Artur Malabarba + +;; Author: Artur Malabarba + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + + +;;; Code: + +(require 'sx) +(require 'sx-filter) +(require 'sx-method) + +(defvar sx-inbox-filter + '((inbox.answer_id + inbox.body + inbox.comment_id + inbox.creation_date + inbox.is_unread + inbox.item_type + inbox.link + inbox.question_id + inbox.site + inbox.title) + (site.logo_url + site.audience + site.icon_url + site.high_resolution_icon_url + site.site_state + site.launch_date + site.markdown_extensions + site.related_sites)) + "Filter used when retrieving inbox items.") + +(defun sx-inbox-get (&optional page keywords) + "Get an array of inbox items for the current user. +Return an list of items. Each item is an alist of properties +returned by the API. +See https://api.stackexchange.com/docs/types/inbox-item + +KEYWORDS are added to the method call along with PAGE. + +`sx-method-call' is used with `sx-inbox-filter'." + (sx-method-call 'inbox + :keywords keywords + :filter sx-inbox-filter)) + +(provide 'sx-inbox) +;;; sx-inbox.el ends here + +;; Local Variables: +;; indent-tabs-mode: nil +;; End: -- cgit v1.2.3 From d24a8b00341e207712ad0741b798491b378fe2c6 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 10:31:09 -0200 Subject: Typo --- sx-inbox.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index f58bee4..5fb3652 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -1,4 +1,4 @@ -p;;; sx-inbox.el --- Base question logic. -*- lexical-binding: t; -*- +;;; sx-inbox.el --- Base inbox logic. -*- lexical-binding: t; -*- ;; Copyright (C) 2014 Artur Malabarba -- cgit v1.2.3 From 9de79b2fe4c077f148f1f1ff7e16c3cf961cae8a Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 10:31:16 -0200 Subject: Generalize sx-inbox-get --- sx-inbox.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 5fb3652..3bc95c8 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -47,16 +47,19 @@ site.related_sites)) "Filter used when retrieving inbox items.") -(defun sx-inbox-get (&optional page keywords) +(defun sx-inbox-get (&optional notifications page keywords) "Get an array of inbox items for the current user. -Return an list of items. Each item is an alist of properties +If NOTIFICATIONS is non-nil, query from `notifications' method, +otherwise use `inbox' method. + +Return an array of items. Each item is an alist of properties returned by the API. See https://api.stackexchange.com/docs/types/inbox-item KEYWORDS are added to the method call along with PAGE. `sx-method-call' is used with `sx-inbox-filter'." - (sx-method-call 'inbox + (sx-method-call (if notifications 'notifications 'inbox) :keywords keywords :filter sx-inbox-filter)) -- cgit v1.2.3 From 4253db72eba6eee7c30962417c8092b1fb9f466b Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 10:32:05 -0200 Subject: Initial mode-line --- sx-inbox.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 3bc95c8..f01d90b 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -63,6 +63,23 @@ KEYWORDS are added to the method call along with PAGE. :keywords keywords :filter sx-inbox-filter)) + +;;; mode-line notification +(defvar sx-inbox--unread-inbox nil + "List of inbox items still unread.") + +(defvar sx-inbox--unread-notifications nil + "List of notifications items still unread.") + +(defvar sx-inbox--mode-line + '("[" + (sx-inbox--unread-inbox + ("i:" (:eval (length sx-inbox--unread-inbox)))) + (sx-inbox--unread-notifications + ("n:" (:eval (length sx-inbox--unread-notifications)))) + "]") + "") + (provide 'sx-inbox) ;;; sx-inbox.el ends here -- cgit v1.2.3 From 0a3a9540b3033e9e93927c92fb6df39a3785563d Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 10:48:41 -0200 Subject: Move mode-line logic to sx-notify --- sx-inbox.el | 17 ---------------- sx-notify.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 sx-notify.el (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index f01d90b..3bc95c8 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -63,23 +63,6 @@ KEYWORDS are added to the method call along with PAGE. :keywords keywords :filter sx-inbox-filter)) - -;;; mode-line notification -(defvar sx-inbox--unread-inbox nil - "List of inbox items still unread.") - -(defvar sx-inbox--unread-notifications nil - "List of notifications items still unread.") - -(defvar sx-inbox--mode-line - '("[" - (sx-inbox--unread-inbox - ("i:" (:eval (length sx-inbox--unread-inbox)))) - (sx-inbox--unread-notifications - ("n:" (:eval (length sx-inbox--unread-notifications)))) - "]") - "") - (provide 'sx-inbox) ;;; sx-inbox.el ends here diff --git a/sx-notify.el b/sx-notify.el new file mode 100644 index 0000000..bc88ceb --- /dev/null +++ b/sx-notify.el @@ -0,0 +1,66 @@ +;;; sx-notify.el --- Mode-line notifications. -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 Artur Malabarba + +;; Author: Artur Malabarba + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + + +;;; Code: + +(require 'sx) +(require 'sx-inbox) + + +;;; mode-line notification +(defvar sx-notify--unread-inbox nil + "List of inbox items still unread.") + +(defvar sx-notify--unread-notifications nil + "List of notifications items still unread.") + +(defvar sx-notify--mode-line + '((sx-notify--unread-inbox (sx-notify--unread-notifications "[")) + (sx-notify--unread-inbox + (:propertize + (:eval (format "i:%s" (length sx-notify--unread-inbox))) + face mode-line-buffer-id + mouse-face mode-line-highlight)) + (sx-notify--unread-inbox (sx-notify--unread-notifications ",")) + (sx-notify--unread-notifications + (:propertize + (:eval (format "n:%s" (length sx-notify--unread-notifications))) + mouse-face mode-line-highlight)) + (sx-notify--unread-inbox (sx-notify--unread-notifications "]"))) + "") +(put 'sx-notify--mode-line 'risky-local-variable t) + + +;;; minor-mode definition +(define-minor-mode sx-notify-mode nil nil "sx" nil + (if sx-notify-mode + (add-to-list 'global-mode-string '(t sx-notify--mode-line) 'append) + (setq global-mode-string + (delete '(t sx-notify--mode-line) global-mode-string)))) + + +(provide 'sx-notify) +;;; sx-notify.el ends here + +;; Local Variables: +;; indent-tabs-mode: nil +;; End: -- cgit v1.2.3 From 316829ed9414e96684ba2dd82100426d28d7215f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 19:59:50 -0200 Subject: Move unread lists to sx-inbox --- sx-inbox.el | 15 +++++++++++++++ sx-notify.el | 36 +++++++++++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 3bc95c8..9cdb959 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -63,6 +63,21 @@ KEYWORDS are added to the method call along with PAGE. :keywords keywords :filter sx-inbox-filter)) + +;;; Major-mode +(defvar sx-inbox--unread-inbox nil + "List of inbox items still unread.") + +(defvar sx-inbox--unread-notifications nil + "List of notifications items still unread.") + +(defvar sx-inbox--read-inbox nil + "List of inbox items which are read. +These are identified by their links.") + +(defvar sx-inbox--read-notifications nil + "List of notification items which are read. +These are identified by their links.") (provide 'sx-inbox) ;;; sx-inbox.el ends here diff --git a/sx-notify.el b/sx-notify.el index 05babad..c335427 100644 --- a/sx-notify.el +++ b/sx-notify.el @@ -27,33 +27,19 @@ ;;; mode-line notification -(defvar sx-notify--unread-inbox nil - "List of inbox items still unread.") - -(defvar sx-notify--unread-notifications nil - "List of notifications items still unread.") - -(defvar sx-notify--read-inbox nil - "List of inbox items which are read. -These are identified by their links.") - -(defvar sx-notify--read-notifications nil - "List of notification items which are read. -These are identified by their links.") - (defvar sx-notify--mode-line - '((sx-notify--unread-inbox (sx-notify--unread-notifications " [")) - (sx-notify--unread-inbox + '((sx-inbox--unread-inbox (sx-inbox--unread-notifications " [")) + (sx-inbox--unread-inbox (:propertize - (:eval (format "i:%s" (length sx-notify--unread-inbox))) + (:eval (format "i:%s" (length sx-inbox--unread-inbox))) face mode-line-buffer-id mouse-face mode-line-highlight)) - (sx-notify--unread-inbox (sx-notify--unread-notifications " ")) - (sx-notify--unread-notifications + (sx-inbox--unread-inbox (sx-inbox--unread-notifications " ")) + (sx-inbox--unread-notifications (:propertize - (:eval (format "n:%s" (length sx-notify--unread-notifications))) + (:eval (format "n:%s" (length sx-inbox--unread-notifications))) mouse-face mode-line-highlight)) - (sx-notify--unread-inbox (sx-notify--unread-notifications "]"))) + (sx-inbox--unread-inbox (sx-notify--unread-notifications "]"))) "") (put 'sx-notify--mode-line 'risky-local-variable t) @@ -83,13 +69,13 @@ These are identified by their links.") (defun sx-notify--update-unread () "Update the lists of unread notifications." - (setq sx-notify--unread-inbox + (setq sx-inbox--unread-inbox (cl-remove-if - (lambda (x) (member (cdr (assq 'link x)) sx-notify--read-inbox)) + (lambda (x) (member (cdr (assq 'link x)) sx-inbox--read-inbox)) (append (sx-inbox-get) nil))) - (setq sx-notify--unread-notifications + (setq sx-inbox--unread-notifications (cl-remove-if - (lambda (x) (member (cdr (assq 'link x)) sx-notify--read-notifications)) + (lambda (x) (member (cdr (assq 'link x)) sx-inbox--read-notifications)) (append (sx-inbox-get t) nil)))) (provide 'sx-notify) -- cgit v1.2.3 From 7f5c549a9d635bc31e35a9d8f117611fb4a679f8 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 20:00:36 -0200 Subject: Initial inbox-mode implementation --- sx-inbox.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 9cdb959..0961564 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -78,6 +78,79 @@ These are identified by their links.") (defvar sx-inbox--read-notifications nil "List of notification items which are read. These are identified by their links.") + +(defvar sx-inbox--header-line + '(" " + (:propertize "n p j k" face mode-line-buffer-id) + ": Navigate" + " " + (:propertize "RET" face mode-line-buffer-id) + ": View" + " " + (:propertize "v" face mode-line-buffer-id) + ": Visit externally" + " " + (:propertize "q" face mode-line-buffer-id) + ": Quit") + "Header-line used on the question list.") + +(define-derived-mode sx-inbox-mode + sx-question-list-mode "Question List" + "Mode used to list inbox and notification items." + (setq sx-question-list--print-function + #'sx-inbox--print-info) + (setq sx-question-list--dataset sx-inbox--unread-inbox) + (setq tabulated-list-format + [("Type" 30 t :right-align t) + ("Date" 10 t :right-align t) + ("Title" 0 sx-inbox--date-more-recent-p)]) + (setq header-line-format sx-inbox--header-line)) + + +;;; Keybinds +(mapc + (lambda (x) (define-key sx-inbox-mode-map + (car x) (cadr x))) + '( + ("t" nil) + ("a" nil) + ("u" nil) + ("d" nil) + ("h" nil) + ("m" sx-inbox-mark-read) + ([?\r] sx-display) + )) + + +;;; print-info +(defun sx-inbox--print-info (data) + "Convert `json-read' DATA into tabulated-list format. + +This is the default printer used by `sx-inbox'. It assumes DATA +is an alist containing the elements: + `answer_id', `body', `comment_id', `creation_date', `is_unread', + `item_type', `link', `question_id', `site', `title'. + +Also see `sx-question-list-refresh'." + (list + data + (sx-assoc-let data + (vector + (list + (concat (capitalize (replace-regexp-in-string "_" " " .item_type)) + (cond + (.answer_id " on Answer at:") + (.question_id " on:")))) + (list (propertize (concat (sx-time-since .last_activity_date) + sx-question-list-ago-string) + 'face 'sx-question-list-date)) + (list + (concat + (propertize " " 'display "\n") + .title + (propertize " " 'display "\n") + .body)))))) + (provide 'sx-inbox) ;;; sx-inbox.el ends here -- cgit v1.2.3 From e313ae05f86ed93dd7731fdb496bdf8b43bbf3e5 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 21:34:00 -0200 Subject: Fix filter --- sx-inbox.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 0961564..75a3d57 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -19,24 +19,26 @@ ;;; Commentary: - ;;; Code: (require 'sx) (require 'sx-filter) (require 'sx-method) +(require 'sx-question-list) + +;;; API (defvar sx-inbox-filter - '((inbox.answer_id - inbox.body - inbox.comment_id - inbox.creation_date - inbox.is_unread - inbox.item_type - inbox.link - inbox.question_id - inbox.site - inbox.title) + '((inbox_item.answer_id + inbox_item.body + inbox_item.comment_id + inbox_item.creation_date + inbox_item.is_unread + inbox_item.item_type + inbox_item.link + inbox_item.question_id + inbox_item.site + inbox_item.title) (site.logo_url site.audience site.icon_url @@ -44,7 +46,8 @@ site.site_state site.launch_date site.markdown_extensions - site.related_sites)) + site.related_sites + site.styling)) "Filter used when retrieving inbox items.") (defun sx-inbox-get (&optional notifications page keywords) -- cgit v1.2.3 From 5675fc89e2b06b1533cb588368c1ffa4e414d0f4 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 21 Dec 2014 21:35:21 -0200 Subject: Fix up the major-mode --- sx-inbox.el | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 75a3d57..00e5e9d 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -100,20 +100,18 @@ These are identified by their links.") (define-derived-mode sx-inbox-mode sx-question-list-mode "Question List" "Mode used to list inbox and notification items." - (setq sx-question-list--print-function - #'sx-inbox--print-info) - (setq sx-question-list--dataset sx-inbox--unread-inbox) + (toggle-truncate-lines 1) + (setq fill-column 40) + (setq sx-question-list--print-function #'sx-inbox--print-info) + (setq sx-question-list--dataset (sx-inbox-get)) (setq tabulated-list-format - [("Type" 30 t :right-align t) - ("Date" 10 t :right-align t) - ("Title" 0 sx-inbox--date-more-recent-p)]) - (setq header-line-format sx-inbox--header-line)) + [("Type" 30 t nil t) ("Date" 10 t :right-align t) ("Title" 0)]) + (setq header-line-format sx-inbox--header-line) + (tabulated-list-revert)) ;;; Keybinds -(mapc - (lambda (x) (define-key sx-inbox-mode-map - (car x) (cadr x))) +(mapc (lambda (x) (define-key sx-inbox-mode-map (car x) (cadr x))) '( ("t" nil) ("a" nil) @@ -132,27 +130,32 @@ These are identified by their links.") This is the default printer used by `sx-inbox'. It assumes DATA is an alist containing the elements: `answer_id', `body', `comment_id', `creation_date', `is_unread', - `item_type', `link', `question_id', `site', `title'. - -Also see `sx-question-list-refresh'." + `item_type', `link', `question_id', `site', `title'." (list data (sx-assoc-let data (vector (list (concat (capitalize (replace-regexp-in-string "_" " " .item_type)) - (cond - (.answer_id " on Answer at:") - (.question_id " on:")))) - (list (propertize (concat (sx-time-since .last_activity_date) - sx-question-list-ago-string) - 'face 'sx-question-list-date)) + (cond (.answer_id " on Answer at:") + (.question_id " on:"))) + 'face 'font-lock-keyword-face) + (list + (concat (sx-time-since .creation_date) + sx-question-list-ago-string) + 'face 'sx-question-list-date) (list - (concat - (propertize " " 'display "\n") - .title - (propertize " " 'display "\n") - .body)))))) + (propertize + " " 'display + (concat "\n " .title "\n" + (let ((col fill-column)) + (with-temp-buffer + (setq fill-column col) + (insert " " .body) + (fill-region (point-min) (point-max)) + (propertize (buffer-string) + 'face 'font-lock-function-name-face)))) + 'face 'default)))))) (provide 'sx-inbox) ;;; sx-inbox.el ends here -- cgit v1.2.3 From 431b2bcc4b25cae49a75bfaf6515460507c31634 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 22 Dec 2014 12:22:21 -0200 Subject: Further inbox-mode improvements --- sx-inbox.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 00e5e9d..31fab5d 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -28,7 +28,7 @@ ;;; API -(defvar sx-inbox-filter +(defvar sx-inbox-filter '((inbox_item.answer_id inbox_item.body inbox_item.comment_id @@ -50,6 +50,11 @@ site.styling)) "Filter used when retrieving inbox items.") +(defcustom sx-inbox-fill-column 40 + "`fill-column' used in `sx-inbox-mode'." + :type 'integer + :group 'sx) + (defun sx-inbox-get (&optional notifications page keywords) "Get an array of inbox items for the current user. If NOTIFICATIONS is non-nil, query from `notifications' method, @@ -68,6 +73,10 @@ KEYWORDS are added to the method call along with PAGE. ;;; Major-mode +(defvar sx-inbox--notification-p nil + "If non-nil, current buffer lists notifications, not inbox.") +(make-variable-buffer-local 'sx-inbox--notification-p) + (defvar sx-inbox--unread-inbox nil "List of inbox items still unread.") @@ -101,9 +110,10 @@ These are identified by their links.") sx-question-list-mode "Question List" "Mode used to list inbox and notification items." (toggle-truncate-lines 1) - (setq fill-column 40) + (setq fill-column sx-inbox-fill-column) (setq sx-question-list--print-function #'sx-inbox--print-info) - (setq sx-question-list--dataset (sx-inbox-get)) + (setq sx-question-list--next-page-function + (lambda (page) (sx-inbox-get sx-inbox--notification-p page))) (setq tabulated-list-format [("Type" 30 t nil t) ("Date" 10 t :right-align t) ("Title" 0)]) (setq header-line-format sx-inbox--header-line) @@ -115,8 +125,6 @@ These are identified by their links.") '( ("t" nil) ("a" nil) - ("u" nil) - ("d" nil) ("h" nil) ("m" sx-inbox-mark-read) ([?\r] sx-display) @@ -140,7 +148,7 @@ is an alist containing the elements: (cond (.answer_id " on Answer at:") (.question_id " on:"))) 'face 'font-lock-keyword-face) - (list + (list (concat (sx-time-since .creation_date) sx-question-list-ago-string) 'face 'sx-question-list-date) -- cgit v1.2.3 From 1fbab001d18fc73f14e235106c910131e16433e9 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 22 Dec 2014 13:21:20 -0200 Subject: Implement sx-inbox --- sx-inbox.el | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 31fab5d..575d181 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -116,8 +116,7 @@ These are identified by their links.") (lambda (page) (sx-inbox-get sx-inbox--notification-p page))) (setq tabulated-list-format [("Type" 30 t nil t) ("Date" 10 t :right-align t) ("Title" 0)]) - (setq header-line-format sx-inbox--header-line) - (tabulated-list-revert)) + (setq header-line-format sx-inbox--header-line)) ;;; Keybinds @@ -144,7 +143,9 @@ is an alist containing the elements: (sx-assoc-let data (vector (list - (concat (capitalize (replace-regexp-in-string "_" " " .item_type)) + (concat (capitalize + (replace-regexp-in-string + "_" " " (or .item_type .notification_type))) (cond (.answer_id " on Answer at:") (.question_id " on:"))) 'face 'font-lock-keyword-face) @@ -165,6 +166,35 @@ is an alist containing the elements: 'face 'font-lock-function-name-face)))) 'face 'default)))))) + +;;; Entry commands +(defvar sx-inbox--buffer nil + "Buffer being used to display inbox.") + +(defun sx-inbox (&optional notifications) + "Display a buffer listing inbox items. +With prefix NOTIFICATIONS, list notifications instead of inbox." + (interactive "P") + (setq sx-inbox--buffer (get-buffer-create "*sx-inbox*")) + (let ((inhibit-read-only t)) + (with-current-buffer sx-inbox--buffer + (erase-buffer) + (sx-inbox-mode) + (setq sx-inbox--notification-p notifications) + (tabulated-list-revert))) + (let ((w (get-buffer-window sx-inbox--buffer))) + (if (window-live-p w) + (select-window w) + (pop-to-buffer sx-inbox--buffer) + (enlarge-window + (- (+ fill-column 4) (window-width)) + 'horizontal)))) + +(defun sx-inbox-notifications () + "Display a buffer listing notification items." + (interactive) + (sx-inbox t)) + (provide 'sx-inbox) ;;; sx-inbox.el ends here -- cgit v1.2.3 From 756d92b9722d4ecebc4f7e223628cf008fb66188 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 22 Dec 2014 13:56:36 -0200 Subject: Add mode-line to inbox --- sx-inbox.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 575d181..07453d4 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -104,7 +104,16 @@ These are identified by their links.") " " (:propertize "q" face mode-line-buffer-id) ": Quit") - "Header-line used on the question list.") + "Header-line used on the inbox list.") + +(defvar sx-inbox--mode-line + '(" " + (:propertize + (sx-inbox--notification-p + "Notifications" + "Inbox") + face mode-line-buffer-id)) + "Mode-line used on the inbox list.") (define-derived-mode sx-inbox-mode sx-question-list-mode "Question List" @@ -116,7 +125,12 @@ These are identified by their links.") (lambda (page) (sx-inbox-get sx-inbox--notification-p page))) (setq tabulated-list-format [("Type" 30 t nil t) ("Date" 10 t :right-align t) ("Title" 0)]) - (setq header-line-format sx-inbox--header-line)) + (setq mode-line-format sx-inbox--mode-line) + (setq header-line-format sx-inbox--header-line) + ;; @TODO: This will no longer be necessary once we properly + ;; refactor sx-question-list-mode. + (remove-hook 'tabulated-list-revert-hook + #'sx-question-list--update-mode-line t)) ;;; Keybinds -- cgit v1.2.3 From 3f71435f4266ab770b296e07df650a8a3bcd3a79 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 25 Dec 2014 12:44:04 -0200 Subject: Slight face modifications --- sx-inbox.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sx-inbox.el') diff --git a/sx-inbox.el b/sx-inbox.el index 07453d4..d0be379 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -170,14 +170,13 @@ is an alist containing the elements: (list (propertize " " 'display - (concat "\n " .title "\n" + (concat "\n " (propertize .title 'face 'sx-question-list-date) "\n" (let ((col fill-column)) (with-temp-buffer (setq fill-column col) (insert " " .body) (fill-region (point-min) (point-max)) - (propertize (buffer-string) - 'face 'font-lock-function-name-face)))) + (buffer-string)))) 'face 'default)))))) -- cgit v1.2.3