aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-24 00:49:15 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-24 00:56:08 -0200
commit684d093b24c0c1bb4627176109611980afad6617 (patch)
treea834fde4286010fbdbfcab127582aee39594ff50
parent76bfce36a4808e71aec27fdc2f7f8cef8462500f (diff)
sx-question-mode--insert-link takes images too
-rw-r--r--sx-question-print.el30
1 files changed, 17 insertions, 13 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index b53b86a..7d1d69e 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -388,20 +388,24 @@ E.g.:
(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.
+(defun sx-question-mode--insert-link (text-or-image url)
+ "Return a link propertized version of TEXT-OR-IMAGE.
URL is used as 'help-echo and 'url properties."
- (insert-text-button
- text
- ;; Mouse-over
- 'help-echo
- (format sx-button--link-help-echo
- (propertize (sx--shorten-url url)
- 'face 'font-lock-function-name-face))
- ;; For visiting and stuff.
- 'sx-button-url url
- 'sx-button-copy url
- :type 'sx-button-link))
+ (let ((imagep (not (stringp text-or-image))))
+ (apply #'insert-text-button
+ (if imagep " " text-or-image)
+ ;; Mouse-over
+ 'help-echo
+ (format sx-button--link-help-echo
+ (propertize (sx--shorten-url url)
+ 'face 'font-lock-function-name-face))
+ ;; For visiting and stuff.
+ 'sx-button-url url
+ 'sx-button-copy url
+ :type 'sx-button-link
+ ;; The last argument of `apply' is a list.
+ (when imagep
+ `(face default display ,text-or-image)))))
(defun sx-question-mode-find-reference (id &optional fallback-id)
"Find url identified by reference ID in current buffer.