From 2ee72cc4361031f3ab34e312fca191125ce18bfc Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 20:04:24 -0200 Subject: Move tag-format to sx-tag.el --- sx-question-print.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-question-print.el') diff --git a/sx-question-print.el b/sx-question-print.el index 9a51efb..b258fde 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -223,7 +223,7 @@ DATA can represent a question or an answer." ;; Tags (sx-question-mode--insert-header sx-question-mode-header-tags - (mapconcat #'sx-question--tag-format .tags " ") + (mapconcat #'sx-tag--format .tags " ") 'sx-question-mode-tags)) ;; Body (insert "\n" -- cgit v1.2.3 From 1dfa97db27a72f0121001b1d85c13d1cdee37f31 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 22:07:09 -0200 Subject: sx-question-mode--insert-header accepts a nil face as third arg --- sx-question-print.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sx-question-print.el') diff --git a/sx-question-print.el b/sx-question-print.el index b258fde..0ae0f04 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -299,7 +299,10 @@ where `value' is given `face' as its face. (while args (insert (propertize (pop args) 'face 'sx-question-mode-header) - (propertize (pop args) 'face (pop args))))) + (let ((header (pop args)) + (face (pop args))) + (if face (propertize header 'face face) + header))))) ;;;; Printing and Font-locking the content (body) -- cgit v1.2.3 From 74fce2c36f803abe232eebe9f542696b8d0fac23 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 22:07:48 -0200 Subject: Always use sx-tag face for tags --- sx-question-list.el | 8 +------- sx-question-print.el | 7 +------ sx-tag.el | 6 ++++++ 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'sx-question-print.el') diff --git a/sx-question-list.el b/sx-question-list.el index 306d39f..256bdb4 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -81,11 +81,6 @@ "" :group 'sx-question-list-faces) -(defface sx-question-list-tags - '((t :inherit sx-question-mode-tags)) - "" - :group 'sx-question-list-faces) - (defface sx-question-list-date '((t :inherit font-lock-comment-face)) "" @@ -170,8 +165,7 @@ Also see `sx-question-list-refresh'." " " ;; @TODO: Make this width customizable. (Or maybe just make ;; the whole thing customizable) - (propertize (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) - 'face 'sx-question-list-tags) + (format "%-40s" (mapconcat #'sx-tag--format .tags " ")) " " (sx-user--format "%15d %4r" .owner) (propertize " " 'display "\n"))))))) diff --git a/sx-question-print.el b/sx-question-print.el index 0ae0f04..6791222 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -79,11 +79,6 @@ Some faces of this mode might be defined in the `sx-user' group." :type 'string :group 'sx-question-mode) -(defface sx-question-mode-tags - '((t :underline nil :inherit font-lock-function-name-face)) - "Face used on the question tags in the question buffer." - :group 'sx-question-mode-faces) - (defface sx-question-mode-score '((t)) "Face used for the score in the question buffer." @@ -224,7 +219,7 @@ DATA can represent a question or an answer." (sx-question-mode--insert-header sx-question-mode-header-tags (mapconcat #'sx-tag--format .tags " ") - 'sx-question-mode-tags)) + nil)) ;; Body (insert "\n" (propertize sx-question-mode-separator diff --git a/sx-tag.el b/sx-tag.el index ba32544..d9e2877 100644 --- a/sx-tag.el +++ b/sx-tag.el @@ -24,6 +24,12 @@ (require 'sx) (require 'sx-method) +(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 (defconst sx-tag-filter -- cgit v1.2.3 From b4c850e313e51f27196de473e1bcfc546c0abb6a Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 22:31:53 -0200 Subject: Turn tags inside body into buttons. Fix #229 --- sx-question-print.el | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'sx-question-print.el') diff --git a/sx-question-print.el b/sx-question-print.el index 6791222..d7c2a20 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -315,7 +315,8 @@ E.g.: (defconst sx-question-mode--link-regexp ;; Done at compile time. - (rx (or (and "[" (group-n 1 (1+ (not (any "]")))) "]" + (rx (or (and "[tag:" (group-n 5 (+ (not (any " ]")))) "]") + (and "[" (group-n 1 (1+ (not (any "]")))) "]" (or (and "(" (group-n 2 (1+ (not (any ")")))) ")") (and "[" (group-n 3 (1+ (not (any "]")))) "]"))) (group-n 4 (and (and "http" (opt "s") "://") "" @@ -363,18 +364,24 @@ E.g.: (save-excursion (goto-char (point-min)) (while (search-forward-regexp sx-question-mode--link-regexp nil t) - (let* ((text (match-string-no-properties 1)) - (url (or (match-string-no-properties 2) - (match-string-no-properties 4) - (sx-question-mode-find-reference - (match-string-no-properties 3) - text))) - (full-text (match-string-no-properties 0))) - (when (stringp url) - (replace-match "") - (sx-question-mode--insert-link - (or (if sx-question-mode-pretty-links text full-text) url) - url)))))) + ;; Tags are tag-buttons. + (let ((tag (match-string-no-properties 5))) + (if (and tag (> (length tag) 0)) + (progn (replace-match "") + (sx-tag--insert tag)) + ;; Other links are link-buttons. + (let* ((text (match-string-no-properties 1)) + (url (or (match-string-no-properties 2) + (match-string-no-properties 4) + (sx-question-mode-find-reference + (match-string-no-properties 3) + text))) + (full-text (match-string-no-properties 0))) + (when (stringp url) + (replace-match "") + (sx-question-mode--insert-link + (or (if sx-question-mode-pretty-links text full-text) url) + url)))))))) (defun sx-question-mode--insert-link (text url) "Return a link propertized version of string TEXT. -- cgit v1.2.3