aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-07 17:59:51 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-07 17:59:51 -0200
commit7ea2edd6e54cf4dd257a32555fec4489d510eaf6 (patch)
tree6507bd71e9a647c5a75cf380417c4d0affa2869e
parent1509d09a5ed073688a316660b5e3a2222dbebfca (diff)
Only display_name and @name are turned into buttons
-rw-r--r--sx-button.el2
-rw-r--r--sx-user.el23
2 files changed, 15 insertions, 10 deletions
diff --git a/sx-button.el b/sx-button.el
index 8309543..a459eb4 100644
--- a/sx-button.el
+++ b/sx-button.el
@@ -155,7 +155,7 @@ usually part of a code-block."
'action #'sx-button-follow-link
'help-echo sx-button--user-help-echo
;; We use different faces on diferent parts of the user button.
- 'face nil
+ 'face 'sx-user-name
:supertype 'sx-button)
(define-button-type 'sx-button-comment
diff --git a/sx-user.el b/sx-user.el
index 44456a0..c0f3a78 100644
--- a/sx-user.el
+++ b/sx-user.el
@@ -95,6 +95,8 @@ errors if you remove them."
(website_url string)))
:group 'sx-user)
+
+;;; Text properties
(defface sx-user-name
'((t :inherit font-lock-builtin-face))
"Face used for user names."
@@ -111,7 +113,9 @@ errors if you remove them."
:group 'sx-user)
(defvar sx-user--format-property-alist
- '((?d face sx-user-name)
+ `((?d button ,(list t) category ,(button-category-symbol 'sx-button-user))
+ (?n button ,(list t) category ,(button-category-symbol 'sx-button-user))
+ (?@ button ,(list t) category ,(button-category-symbol 'sx-button-user))
(?r face sx-user-reputation)
(?a face sx-user-accept-rate))
"Alist relating % constructs with text properties.
@@ -130,8 +134,10 @@ replaced by text that describes the specified USER:
%r is the reputation.
%a is the accept rate.
-The returned string is additionally propertized as a button with
-the `sx-button-user' category."
+The string replaced in each of these construct is also given the
+text-properties specified in `sx-user--format-property-alist'.
+Specially, %d and %@ are turned into buttons with the
+`sx-button-user' category."
(sx-assoc-let (append user sx-question-mode-fallback-user)
(let* ((text (sx-format-replacements
format-string
@@ -144,12 +150,11 @@ the `sx-button-user' category."
(sx-user--@name .display_name)))
)
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
- :type 'sx-button-user)
+ (if (< 0 (string-width .link))
+ (propertize text
+ ;; For visiting and stuff.
+ 'sx-button-url .link
+ 'sx-button-copy .link)
text))))