diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-29 03:36:29 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-29 03:36:29 +0000 |
commit | 9d39b0d1bcaa3186e21171f656b807fde2611b53 (patch) | |
tree | 037417936d90d32c3922fadc2d5bc5ad4fabeaf4 | |
parent | 771bcf75deb0596331a539a57dcf37c278e34910 (diff) |
Improve button-copy
-rw-r--r-- | sx-button.el | 14 | ||||
-rw-r--r-- | sx-question-print.el | 25 | ||||
-rw-r--r-- | sx.el | 2 |
3 files changed, 25 insertions, 16 deletions
diff --git a/sx-button.el b/sx-button.el index 3f532bb..aa77086 100644 --- a/sx-button.el +++ b/sx-button.el @@ -40,11 +40,14 @@ This is usually a link's URL, or the content of a code block." (interactive) (let ((content - (get-text-property - (point) 'sx-button-copy-content))) - (if content - (kill-new content) - (sx-message "Nothing to copy here.")))) + (get-text-property (point) 'sx-button-copy))) + (if (null content) + (sx-message "Nothing to copy here.") + (kill-new content) + (sx-message "Copied %s to kill ring." + (or (get-text-property + (point) 'sx-button-copy-type) + content))))) (defun sx-button-follow-link (&optional pos) "Follow link at POS. If POS is nil, use `point'." @@ -63,6 +66,7 @@ This is usually a link's URL, or the content of a code block." 'face 'sx-question-mode-title 'action #'sx-question-mode-hide-show-section 'help-echo 'sx-question-mode--section-help-echo + 'sx-button-copy-type "Share Link" :supertype 'sx-button) (define-button-type 'sx-button-link diff --git a/sx-question-print.el b/sx-question-print.el index 3b2f141..5b6c5be 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -199,6 +199,7 @@ DATA can represent a question or an answer." (or .title sx-question-mode-answer-title) ;; Section level 'sx-question-mode--section (if .title 1 2) + 'sx-button-copy .share_link :type 'sx-question-mode-title) ;; Sections can be hidden with overlays (sx--wrap-in-overlay @@ -251,6 +252,7 @@ DATA can represent a question or an answer." sx-question-mode-comments-title 'face 'sx-question-mode-title-comments 'sx-question-mode--section 3 + 'sx-button-copy .share_link :type 'sx-question-mode-title) (sx--wrap-in-overlay '(sx-question-mode--section-content t) @@ -392,19 +394,20 @@ URL is used as 'help-echo and 'url properties." (propertize "RET" 'face 'font-lock-function-name-face)) ;; For visiting and stuff. 'sx-button-url url - :type 'sx-button-link)) + 'sx-button-copy url + :type 'sx-button-link) -(defun sx-question-mode-find-reference (id &optional fallback-id) - "Find url identified by reference ID in current buffer. + (defun sx-question-mode-find-reference (id &optional fallback-id) + "Find url identified by reference ID in current buffer. If ID is nil, use FALLBACK-ID instead." - (save-excursion - (save-match-data - (goto-char (point-min)) - (when (search-forward-regexp - (format sx-question-mode--reference-regexp - (or id fallback-id)) - nil t) - (match-string-no-properties 1))))) + (save-excursion + (save-match-data + (goto-char (point-min)) + (when (search-forward-regexp + (format sx-question-mode--reference-regexp + (or id fallback-id)) + nil t) + (match-string-no-properties 1)))))) (defun sx-question-mode--move-over-pre () "Non-nil if paragraph at point can be filled." @@ -63,6 +63,7 @@ question.upvoted question.downvoted question.question_id + question.share_link user.display_name comment.owner comment.body_markdown @@ -78,6 +79,7 @@ answer.answer_id answer.last_editor answer.link + answer.share_link answer.owner answer.body_markdown answer.upvoted |