diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-21 10:43:00 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-21 16:26:11 -0200 |
commit | 755322c4ba96c6ce5a836cfa601da993f8031ac1 (patch) | |
tree | 4a1b204c8600e8bf92ee177878cf57e01164d752 | |
parent | 546f30134df637e912ea947aac942f940c275faf (diff) |
Configure question-mode mode-line
-rw-r--r-- | sx-question-mode.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el index 6125416..2d06e5b 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -69,6 +69,7 @@ Returns the question buffer." (defun sx-question-mode--erase-and-print-question (data) "Erase contents of buffer and print question given by DATA. Also marks the question as read with `sx-question--mark-read'." + (sx--ensure-site data) (sx-question--mark-read data) (let ((inhibit-read-only t)) (erase-buffer) @@ -183,6 +184,34 @@ property." ": Quit") "Header-line used on the question list.") +(defconst sx-question-mode--mode-line + '(" " + ;; `sx-question-mode--data' is guaranteed to have through + ;; `sx--ensure-site' already, so we use `let-alist' instead of + ;; `sx-assoc-let' to improve performance (since the mode-line is + ;; updated a lot). + (:propertize + (:eval (let-alist sx-question-mode--data .site_par)) + face mode-line-buffer-id) + " " mode-name + " [" + "Answers: " + (:propertize + (:eval (number-to-string (let-alist sx-question-mode--data .answer_count))) + face mode-line-buffer-id) + ", " + "Stars: " + (:propertize + (:eval (number-to-string (or (let-alist sx-question-mode--data .favorite_count) 0))) + face mode-line-buffer-id) + ", " + "Views: " + (:propertize + (:eval (number-to-string (let-alist sx-question-mode--data .view_count))) + face mode-line-buffer-id) + "] ") + "Mode-line construct to use in `sx-question-mode' buffers.") + (define-derived-mode sx-question-mode special-mode "Question" "Major mode to display and navigate a question and its answers. Letters do not insert themselves; instead, they are commands. @@ -190,6 +219,7 @@ Letters do not insert themselves; instead, they are commands. \\<sx-question-mode> \\{sx-question-mode}" (setq header-line-format sx-question-mode--header-line) + (setq header-line-format sx-question-mode--mode-line) ;; Determine how to close this window. (unless (window-parameter nil 'quit-restore) (set-window-parameter |