diff options
author | Sean Allred <code@seanallred.com> | 2014-11-27 11:21:02 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-27 11:21:02 -0500 |
commit | 92ec323425057284de93c90b7ae0e8f5e96611b6 (patch) | |
tree | 65112f05a72c0ba4ac74076d1c53f6612deeb1cd /sx-interaction.el | |
parent | 9c2df708ac4dc62c34882b7978761cf1f73e063f (diff) | |
parent | 6848008b60938100d04cda96c093a24cb3370f9a (diff) |
Merge branch 'master' into issue-100
Diffstat (limited to 'sx-interaction.el')
-rw-r--r-- | sx-interaction.el | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index 404fb56..e4234b0 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -51,16 +51,25 @@ Only fields contained in TO are copied." (setcar to (car from)) (setcdr to (cdr from))) -(defun sx-visit (data) +(defun sx-visit (data &optional copy-as-kill) "Visit DATA in a web browser. DATA can be a question, answer, or comment. Interactively, it is derived from point position. + +If copy-as-kill is non-nil, do not call `browse-url'. +Instead, copy the link as a new kill with `kill-new'. +Interactively, this is specified with a prefix argument. + If DATA is a question, also mark it as read." - (interactive (list (sx--data-here))) + (interactive (list (sx--data-here) current-prefix-arg)) (sx-assoc-let data - (when (stringp .link) - (browse-url .link)) - (when .title + (let ((link + (when (stringp .link) + (funcall (if copy-as-kill #'kill-new #'browse-url) + .link)))) + (when (and (called-interactively-p 'any) copy-as-kill) + (message "Copied: %S" link))) + (when (and .title (not copy-as-kill)) (sx-question--mark-read data) (sx--maybe-update-display)))) @@ -123,7 +132,7 @@ TEXT is a string. Interactively, it is read from the minibufer." (setq text (read-string "Comment text: " (when .comment_id - (sx--user-@name .owner)))) + (concat (sx--user-@name .owner) " ")))) (while (< (string-width text) 15) (setq text (read-string "Comment text (at least 15 characters): " text)))) ;; If non-interactive, `text' could be anything. |