From 9140a717b13b2e4919164b249f6d4b83b47ba53e Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 14 Feb 2015 15:48:53 -0200 Subject: Add an sx-tag-meta property to tags. --- sx-tag.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sx-tag.el') diff --git a/sx-tag.el b/sx-tag.el index 316226b..a59e0d7 100644 --- a/sx-tag.el +++ b/sx-tag.el @@ -142,17 +142,20 @@ tags." ;;; Printing -(defun sx-tag--format (tag) - "Format and return TAG for display." +(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) + (sx-tag--insert tag meta) (buffer-string))) -(defun sx-tag--insert (tag) - "Insert TAG button." +(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)) (provide 'sx-tag) -- cgit v1.2.3 From ded9c419cbbbe77446681460e4352168a8b33e80 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 14 Feb 2015 15:58:01 -0200 Subject: Define sx-tag--format-tags to format multiple tags. --- sx-tag.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sx-tag.el') diff --git a/sx-tag.el b/sx-tag.el index a59e0d7..3c00ae2 100644 --- a/sx-tag.el +++ b/sx-tag.el @@ -158,6 +158,19 @@ If META is non-nil, the tag is for the meta site." '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 -- cgit v1.2.3