diff --git a/sx-inbox.el b/sx-inbox.el index 1f0f2271..e854b478 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -56,6 +56,15 @@ :type 'integer :group 'sx) +(defface sx-inbox-item-type + '((t :inherit font-lock-keyword-face)) "") + +(defface sx-inbox-item-type-unread + '((t :inherit font-lock-keyword-face :weight bold)) "") + +(defface sx-inbox-link + '((t :inherit link)) "") + (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, @@ -161,23 +170,33 @@ is an alist containing the elements: (cond (.answer_id " on Answer at:") (.question_id " on:") (t ":"))) - 'face 'font-lock-keyword-face) + 'face (if .is_unread 'sx-inbox-item-type-unread 'sx-inbox-item-type)) (list (concat (sx-time-since .creation_date) sx-question-list-ago-string) 'face 'sx-question-list-date) (list - (propertize - " " 'display - (concat "\n " (propertize (or .title "") 'face 'sx-question-list-date) "\n" - (when .body - (let ((col fill-column)) - (with-temp-buffer - (setq fill-column col) - (insert " " .body) - (fill-region (point-min) (point-max)) - (buffer-string)))) - 'face 'default))))))) + (propertize " " 'display + (concat " " (propertize (or .title "") 'face 'sx-question-list-date) "\n" + (when .body + (let (end-1 start-2 text) + (while (and + (string-match "]+>" .body) + (setq end-1 (match-end 0)) + (string-match "]*>" .body) + (setq start-2 (match-beginning 0))) + (setq .body (replace-regexp-in-string "\\(]*>\\).*\\'" + (setq text (substring .body end-1 start-2)) .body nil nil 1)) + (when (string-match text .body) + (add-face-text-property + (match-beginning 0) (match-end 0) 'sx-inbox-link nil .body)))) + (let ((col fill-column)) + (with-temp-buffer + (setq fill-column col) + (insert " " .body) + (fill-region (point-min) (point-max)) + (buffer-string)))) + "\n" ) 'face (if .is_unread 'bold 'default) )))))) ;;; Entry commands