diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-26 23:17:14 -0300 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-26 23:17:14 -0300 |
commit | ee0e79475ed49f0e28c530994beebbafd1d77ca8 (patch) | |
tree | 4366b16ccefd389b401734e385e2fb44d5a8c370 /sx-tag.el | |
parent | e19068da5bc6ab29b3a0cd21daed3cf98708df39 (diff) | |
parent | be15643b64b64e5fcbcdc213c90a5fa9cd41e9df (diff) |
Merge branch 'handle-html-tags' into print-question-without-temp-buffer
Diffstat (limited to 'sx-tag.el')
-rw-r--r-- | sx-tag.el | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -142,19 +142,35 @@ 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)) +(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 |