diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-21 10:27:53 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-21 10:27:53 -0200 |
commit | 546f30134df637e912ea947aac942f940c275faf (patch) | |
tree | cc699167a3ff901babde186931e25f6c35508fcd /sx-tag.el | |
parent | 2f398913b77d190f2e0c96ba15296c231ba21e18 (diff) | |
parent | ca121c0c65e0e689af2ee859fdd8ebea8bc44bc5 (diff) |
Merge branch 'master' into small-improvements
Diffstat (limited to 'sx-tag.el')
-rw-r--r-- | sx-tag.el | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -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 |