From 2ee72cc4361031f3ab34e312fca191125ce18bfc Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 20:04:24 -0200 Subject: Move tag-format to sx-tag.el --- sx-question-list.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 884f994..306d39f 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -170,7 +170,7 @@ Also see `sx-question-list-refresh'." " " ;; @TODO: Make this width customizable. (Or maybe just make ;; the whole thing customizable) - (propertize (format "%-40s" (mapconcat #'sx-question--tag-format .tags " ")) + (propertize (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) 'face 'sx-question-list-tags) " " (sx-user--format "%15d %4r" .owner) -- cgit v1.2.3 From 74fce2c36f803abe232eebe9f542696b8d0fac23 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 22:07:48 -0200 Subject: Always use sx-tag face for tags --- sx-question-list.el | 8 +------- sx-question-print.el | 7 +------ sx-tag.el | 6 ++++++ 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 306d39f..256bdb4 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -81,11 +81,6 @@ "" :group 'sx-question-list-faces) -(defface sx-question-list-tags - '((t :inherit sx-question-mode-tags)) - "" - :group 'sx-question-list-faces) - (defface sx-question-list-date '((t :inherit font-lock-comment-face)) "" @@ -170,8 +165,7 @@ Also see `sx-question-list-refresh'." " " ;; @TODO: Make this width customizable. (Or maybe just make ;; the whole thing customizable) - (propertize (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) - 'face 'sx-question-list-tags) + (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) " " (sx-user--format "%15d %4r" .owner) (propertize " " 'display "\n"))))))) diff --git a/sx-question-print.el b/sx-question-print.el index 0ae0f04..6791222 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -79,11 +79,6 @@ Some faces of this mode might be defined in the `sx-user' group." :type 'string :group 'sx-question-mode) -(defface sx-question-mode-tags - '((t :underline nil :inherit font-lock-function-name-face)) - "Face used on the question tags in the question buffer." - :group 'sx-question-mode-faces) - (defface sx-question-mode-score '((t)) "Face used for the score in the question buffer." @@ -224,7 +219,7 @@ DATA can represent a question or an answer." (sx-question-mode--insert-header sx-question-mode-header-tags (mapconcat #'sx-tag--format .tags " ") - 'sx-question-mode-tags)) + nil)) ;; Body (insert "\n" (propertize sx-question-mode-separator diff --git a/sx-tag.el b/sx-tag.el index ba32544..d9e2877 100644 --- a/sx-tag.el +++ b/sx-tag.el @@ -24,6 +24,12 @@ (require 'sx) (require 'sx-method) +(defface sx-tag + '((t :underline nil :inherit font-lock-function-name-face)) + "Face used on the question tags in the question buffer." + :group 'sx-question-mode-faces + :group 'sx-question-list-faces) + ;;; Getting the list from a site (defconst sx-tag-filter -- cgit v1.2.3 From 21d1b2594efaff4089d2bab736e0a18a1ee1a9db Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 14:16:50 -0200 Subject: Get rid of sx-question-list--update-mode-line --- sx-inbox.el | 6 +----- sx-question-list.el | 24 ++++-------------------- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-inbox.el b/sx-inbox.el index 21589fb..3048509 100644 --- a/sx-inbox.el +++ b/sx-inbox.el @@ -127,11 +127,7 @@ These are identified by their links.") (setq tabulated-list-format [("Type" 30 t nil t) ("Date" 10 t :right-align t) ("Title" 0)]) (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)) + (setq header-line-format sx-inbox--header-line)) ;;; Keybinds diff --git a/sx-question-list.el b/sx-question-list.el index 7757503..de15704 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -308,7 +308,8 @@ into consideration. The same holds for `sx-question-list--order'. \\{sx-question-list-mode-map}" (hl-line-mode 1) - (sx-question-list--update-mode-line) + (setq mode-line-format + sx-question-list--mode-line-format) (setq sx-question-list--pages-so-far 0) (setq tabulated-list-format [(" V" 3 t :right-align t) @@ -320,8 +321,6 @@ into consideration. The same holds for `sx-question-list--order'. (setq tabulated-list-sort-key nil) (add-hook 'tabulated-list-revert-hook #'sx-question-list-refresh nil t) - (add-hook 'tabulated-list-revert-hook - #'sx-question-list--update-mode-line nil t) (setq header-line-format sx-question-list--header-line)) (defcustom sx-question-list-date-sort-method 'last_activity_date @@ -400,14 +399,8 @@ Non-interactively, DATA is a question alist." ;; "Unanswered", etc. "Variable describing current tab being viewed.") -(defvar sx-question-list--total-count 0 - "Holds the total number of questions in the current buffer.") -(make-variable-buffer-local 'sx-question-list--total-count) - (defconst sx-question-list--mode-line-format - '(" " - mode-name - " " + '(" " mode-name ": " (:propertize sx-question-list--current-tab face mode-line-buffer-id) " [" @@ -418,7 +411,7 @@ Non-interactively, DATA is a question alist." ", " "Total: " (:propertize - (:eval (int-to-string sx-question-list--total-count)) + (:eval (int-to-string (length tabulated-list-entries))) face mode-line-buffer-id) "] ") "Mode-line construct to use in question-list buffers.") @@ -429,15 +422,6 @@ Non-interactively, DATA is a question alist." (cl-count-if-not #'sx-question--read-p sx-question-list--dataset))) -(defun sx-question-list--update-mode-line () - "Fill the mode-line with useful information." - ;; All the data we need is right in the buffer. - (when (derived-mode-p 'sx-question-list-mode) - (setq mode-line-format - sx-question-list--mode-line-format) - (setq sx-question-list--total-count - (length tabulated-list-entries)))) - (defvar sx-question-list--site nil "Site being displayed in the *question-list* buffer.") (make-variable-buffer-local 'sx-question-list--site) -- cgit v1.2.3 From 1f73185f411de81a5e26152377c499498d732d8c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 21:26:03 -0200 Subject: require 'sx-tag --- 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 07355d0..333fd83 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -27,6 +27,7 @@ (require 'sx) (require 'sx-time) +(require 'sx-tag) (require 'sx-site) (require 'sx-question) (require 'sx-question-mode) -- cgit v1.2.3 From b8124d4056632ae3eb1381b19db743625a715548 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 14 Feb 2015 15:58:17 -0200 Subject: Use sx-tag--format-tags --- sx-question-list.el | 2 +- sx-question-print.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 333fd83..6bae225 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -166,7 +166,7 @@ Also see `sx-question-list-refresh'." " " ;; @TODO: Make this width customizable. (Or maybe just make ;; the whole thing customizable) - (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) + (format "%-40s" (sx-tag--format-tags .tags sx-question-list--site)) " " (sx-user--format "%15d %4r" .owner) (propertize " " 'display "\n"))))))) diff --git a/sx-question-print.el b/sx-question-print.el index 190c924..e535091 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -223,7 +223,7 @@ DATA can represent a question or an answer." ;; Tags (sx-question-mode--insert-header sx-question-mode-header-tags - (mapconcat #'sx-tag--format .tags " ") + (sx-tag--format-tags .tags .site_par) nil)) ;; Body (insert "\n" -- cgit v1.2.3 From 2f398913b77d190f2e0c96ba15296c231ba21e18 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 14 Feb 2015 16:44:01 -0200 Subject: Show the site name on the mode-lien --- sx-question-list.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index de15704..06af161 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -400,7 +400,13 @@ Non-interactively, DATA is a question alist." "Variable describing current tab being viewed.") (defconst sx-question-list--mode-line-format - '(" " mode-name ": " + '(" " + (:propertize + (:eval (mapconcat #'capitalize + (split-string sx-question-list--site "\\.") + " ")) + face mode-line-buffer-id) + " " mode-name ": " (:propertize sx-question-list--current-tab face mode-line-buffer-id) " [" -- cgit v1.2.3 From d73ba0621e1e73df155a09126ecef8df8c2d232a Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 21 Feb 2015 10:48:28 -0200 Subject: Standardize prettification of site names. --- sx-question-list.el | 4 +--- sx-question-mode.el | 9 +++++++-- sx.el | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index def490b..32bc140 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -397,9 +397,7 @@ Non-interactively, DATA is a question alist." (defconst sx-question-list--mode-line-format '(" " (:propertize - (:eval (mapconcat #'capitalize - (split-string sx-question-list--site "\\.") - " ")) + (:eval (sx--pretty-site-parameter sx-question-list--site)) face mode-line-buffer-id) " " mode-name ": " (:propertize sx-question-list--current-tab diff --git a/sx-question-mode.el b/sx-question-mode.el index 2d06e5b..d4b7f8d 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -191,7 +191,8 @@ property." ;; `sx-assoc-let' to improve performance (since the mode-line is ;; updated a lot). (:propertize - (:eval (let-alist sx-question-mode--data .site_par)) + (:eval (sx--pretty-site-parameter + (let-alist sx-question-mode--data .site_par))) face mode-line-buffer-id) " " mode-name " [" @@ -216,10 +217,14 @@ property." "Major mode to display and navigate a question and its answers. Letters do not insert themselves; instead, they are commands. +Don't activate this mode directly. Instead, to print a question +on the current buffer use +`sx-question-mode--erase-and-print-question'. + \\ \\{sx-question-mode}" (setq header-line-format sx-question-mode--header-line) - (setq header-line-format sx-question-mode--mode-line) + (setq mode-line-format sx-question-mode--mode-line) ;; Determine how to close this window. (unless (window-parameter nil 'quit-restore) (set-window-parameter diff --git a/sx.el b/sx.el index 73d874f..fc0af92 100644 --- a/sx.el +++ b/sx.el @@ -187,6 +187,12 @@ If ALIST doesn't have a `site' property, one is created using the ,(macroexpand `(let-alist ,alist ,@body)))) +(defun sx--pretty-site-parameter (site) + "Returned a pretty and capitalized version of string SITE." + (mapconcat #'capitalize + (split-string site "\\.") + " ")) + ;;; Utility Functions (defun sx-completing-read (&rest args) -- cgit v1.2.3 From f46b4c3efddf15b76fcafdd0d35969dadc2881f4 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 21 Feb 2015 17:35:03 -0200 Subject: Define and use sx-question-list--key-definitions --- sx-question-list.el | 76 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 6bae225..6786ca2 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -210,19 +210,39 @@ and thus not displayed in the list of questions. This is ignored if `sx-question-list--refresh-function' is set.") (make-variable-buffer-local 'sx-question-list--dataset) +(defconst sx-question-list--key-definitions + '( + ;; S-down and S-up would collide with `windmove'. + ("" sx-question-list-next) + ("" sx-question-list-previous) + ("RET" sx-display "Display") + ("n" sx-question-list-next "Navigate") + ("p" sx-question-list-previous "Navigate") + ("j" sx-question-list-view-next "Navigate") + ("k" sx-question-list-view-previous "Navigate") + ("N" sx-question-list-next-far) + ("P" sx-question-list-previous-far) + ("J" sx-question-list-next-far) + ("K" sx-question-list-previous-far) + ("g" sx-question-list-refresh) + ("t" sx-tab-switch "tab") + ("a" sx-ask "ask") + ("S" sx-search "Search") + ("s" sx-switchto-map "switch-to") + ("v" sx-visit-externally "visit") + ("u" sx-upvote) + ("d" sx-downvote) + ("h" sx-question-list-hide "hide") + ("m" sx-question-list-mark-read "mark-read") + ("*" sx-favorite) + ) + "List of key definitions for `sx-question-list-mode'. +This list must follow the form described in +`sx--key-definitions-to-header-line'.") + (defconst sx-question-list--header-line - '(" " - (:propertize "n p j k" face mode-line-buffer-id) - ": Navigate" - " " - (:propertize "RET" face mode-line-buffer-id) - ": View question" - " " - (:propertize "v" face mode-line-buffer-id) - ": Visit externally" - " " - (:propertize "q" face mode-line-buffer-id) - ": Quit") + (sx--key-definitions-to-header-line + sx-question-list--key-definitions) "Header-line used on the question list.") (defconst sx-question-list--order-methods @@ -333,34 +353,10 @@ into consideration. The same holds for `sx-question-list--order'. ;;; Keybinds -(mapc - (lambda (x) (define-key sx-question-list-mode-map - (car x) (cadr x))) - '( - ;; S-down and S-up would collide with `windmove'. - ([down] sx-question-list-next) - ([up] sx-question-list-previous) - ("n" sx-question-list-next) - ("p" sx-question-list-previous) - ("j" sx-question-list-view-next) - ("k" sx-question-list-view-previous) - ("N" sx-question-list-next-far) - ("P" sx-question-list-previous-far) - ("J" sx-question-list-next-far) - ("K" sx-question-list-previous-far) - ("g" sx-question-list-refresh) - ("t" sx-tab-switch) - ("a" sx-ask) - ("S" sx-search) - ("s" sx-switchto-map) - ("v" sx-visit-externally) - ("u" sx-upvote) - ("d" sx-downvote) - ("h" sx-question-list-hide) - ("m" sx-question-list-mark-read) - ("*" sx-favorite) - ([?\r] sx-display) - )) +;; We need this quote+eval combo because `kbd' was a macro in 24.2. +(mapc (lambda (x) (eval `(define-key sx-question-list-mode-map + (kbd ,(car x)) #',(cadr x)))) + sx-question-list--key-definitions) (defun sx-question-list-hide (data) "Hide question under point. -- cgit v1.2.3