diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-07 15:09:21 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-07 15:48:31 -0200 |
commit | adbf1e311eaafbec2476fe08a5ba81672f25eb79 (patch) | |
tree | b3331be87ca24a97855a30d44ed7f19f8ccaaf29 | |
parent | d2e808eae7565cefb95becd05628ae69f2980e25 (diff) |
Fix some migration left-overs
-rw-r--r-- | sx-question-print.el | 20 | ||||
-rw-r--r-- | sx-user.el | 29 |
2 files changed, 27 insertions, 22 deletions
diff --git a/sx-question-print.el b/sx-question-print.el index 6ab7698..66ae922 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -34,8 +34,9 @@ :tag "SX Question Mode" :group 'sx) -(defgroup sx-question-mode-faces nil - "Customization group for the faces of `sx-question-mode'." +(defgroup sx-question-mode-faces '((sx-user custom-group)) + "Customization group for the faces of `sx-question-mode'. +Some faces of this mode might be defined in the `sx-user' group." :prefix "sx-question-mode-" :tag "SX Question Mode Faces" :group 'sx-question-mode) @@ -62,7 +63,7 @@ :type 'string :group 'sx-question-mode) -(defcustom sx-question-mode-header-author-format "\nAuthor: %n %r" +(defcustom sx-question-mode-header-author-format "\nAuthor: %d %r" "String used to display the question author at the header. % constructs have special meaning here. See `sx--user-format'." :type 'string @@ -191,10 +192,11 @@ DATA can represent a question or an answer." (sx--wrap-in-overlay '(sx-question-mode--section-content t) ;; Author - (sx--format-user - (propertize sx-question-mode-header-author-format - 'face 'sx-question-mode-header) - .owner) + (insert + (sx--user-format + (propertize sx-question-mode-header-author-format + 'face 'sx-question-mode-header) + .owner)) (sx-question-mode--insert-header ;; Date sx-question-mode-header-date @@ -203,7 +205,7 @@ DATA can represent a question or an answer." (when .last_edit_date (format sx-question-mode-last-edit-format (sx-time-since .last_edit_date) - (sx--format-user "%n" .last_editor)))) + (sx--user-format "%d" .last_editor)))) 'sx-question-mode-date) (sx-question-mode--insert-header sx-question-mode-header-score @@ -272,7 +274,7 @@ The comment is indented, filled, and then printed according to " ")) (insert (format sx-question-mode-comments-format - (sx--format-user "%n" .owner) + (sx--user-format "%d" .owner) (substring ;; We fill with three spaces at the start, so the comment is ;; slightly indented. @@ -25,9 +25,9 @@ (require 'sx-button) (defgroup sx-user nil - "Customization group for sx-question-mode." + "How users are displayed by SX." :prefix "sx-user-" - :tag "SX Question Mode" + :tag "SX User" :group 'sx) (defcustom sx-question-mode-fallback-user @@ -111,12 +111,14 @@ errors if you remove them." :group 'sx-user) (defvar sx--user-format-property-alist - '((?d face sx-question-mode-author) - (?r face sx-question-mode-reputation) - (?a face sx-question-mode-accept-rate)) + '((?d face sx-user-name) + (?r face sx-user-reputation) + (?a face sx-user-accept-rate)) "Alist relating % constructs with text properties. See `sx--user-format'.") + +;;; Formatting function (defun sx--user-format (format-string user) "Use FORMAT-STRING to format the user object USER. The value is a copy of FORMAT-STRING, but with certain constructs @@ -132,16 +134,17 @@ the `sx-button-user' category." (sx-assoc-let (append user sx-question-mode-fallback-user) (let* ((text (sx-format-replacements format-string - `((?d . ,.display_name) - (?l . ,.link) - (?r . ,.reputation) - (?a . ,.accept_rate)) - sx--format-user-property-alist))) - (if link + `((?d . ,\.display_name) + (?n . ,\.display_name) + (?l . ,\.link) + (?r . ,\.reputation) + (?a . ,\.accept_rate)) + sx--user-format-property-alist))) + (if (> 0 (string-width .link)) (insert-text-button text ;; For visiting and stuff. - 'sx-button-url link - 'sx-button-copy link + 'sx-button-url .link + 'sx-button-copy .link :type 'sx-button-user) text)))) |