aboutsummaryrefslogtreecommitdiff
path: root/sx-tag.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-03-26 20:27:39 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-03-26 20:27:39 +0000
commit542bcc6a8be0dc5b28bfe43d7e954f4476c7f02a (patch)
tree1d0337b03364cfce2fd0b700d48c1200703c2e73 /sx-tag.el
parente73dcda1ea1ed044f1ed83192e7e7dd7e1ce59e4 (diff)
parentce6600296875e17009e2b85c769956cde55a2d53 (diff)
Merge branch 'master' into more-ordering
Diffstat (limited to 'sx-tag.el')
-rw-r--r--sx-tag.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/sx-tag.el b/sx-tag.el
index b2ad375..3c00ae2 100644
--- a/sx-tag.el
+++ b/sx-tag.el
@@ -23,6 +23,13 @@
(require 'sx)
(require 'sx-method)
+(require 'sx-button)
+
+(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
@@ -133,6 +140,37 @@ tags."
(push input list))
(reverse list)))
+
+;;; Printing
+(defun sx-tag--format (tag &optional meta)
+ "Format and return TAG for display.
+If META is non-nil, the tag is for the meta site."
+ (with-temp-buffer
+ (sx-tag--insert tag meta)
+ (buffer-string)))
+
+(defun sx-tag--insert (tag &optional meta)
+ "Insert TAG button.
+If META is non-nil, the tag is for the meta site."
+ (insert-text-button (concat "[" tag "]")
+ 'sx-button-copy tag
+ 'sx-tag tag
+ 'sx-tag-meta meta
+ :type 'sx-button-tag))
+
+(defun sx-tag--format-tags (tags &optional site)
+ "Format and concatenate a sequence of TAGS.
+Returns a string of all tags in TAGS, separated by a space.
+
+SITE is the site to which the tags refer, it is only used to
+decide whether they are main or meta tags. SITE can also be t or
+nil, which respectively indicate meta and main."
+ (let ((is-meta
+ (if (stringp site) (string-match (rx string-start "meta.") site)
+ site)))
+ (mapconcat (lambda (tag) (sx-tag--format tag is-meta))
+ tags " ")))
+
(provide 'sx-tag)
;;; sx-tag.el ends here