aboutsummaryrefslogtreecommitdiff
path: root/sx-button.el
diff options
context:
space:
mode:
Diffstat (limited to 'sx-button.el')
-rw-r--r--sx-button.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/sx-button.el b/sx-button.el
index afc1cf7..af3c7e3 100644
--- a/sx-button.el
+++ b/sx-button.el
@@ -50,6 +50,21 @@ This is usually a link's URL, or the content of a code block."
(point) 'sx-button-copy-type)
content)))))
+(defun sx-button-edit-this (text-or-marker)
+ "Open a temp buffer populated with the string TEXT-OR-MARKER.
+When given a marker (or interactively), use the 'sx-button-copy
+text-property under the marker. This is usually the content of a
+code-block."
+ (interactive (list (point-marker)))
+ ;; Buttons receive markers.
+ (when (markerp text-or-marker)
+ (unless (setq text-or-marker
+ (get-text-property text-or-marker 'sx-button-copy))
+ (sx-message "Nothing of interest here.")))
+ (with-current-buffer (pop-to-buffer (generate-new-buffer
+ "*sx temp buffer*"))
+ (insert text-or-marker)))
+
(defun sx-button-follow-link (&optional pos)
"Follow link at POS. If POS is nil, use `point'."
(interactive)
@@ -89,6 +104,11 @@ This is usually a link's URL, or the content of a code block."
'sx-button-copy-type "Share Link"
:supertype 'sx-button)
+(define-button-type 'sx-question-mode-code-block
+ 'action #'sx-button-edit-this
+ 'face nil
+ :supertype 'sx-button)
+
(define-button-type 'sx-button-link
'action #'sx-button-follow-link
:supertype 'sx-button)