emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/go-mode 4f3befb 003/495: add go-play-buffer and go-play-re


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 4f3befb 003/495: add go-play-buffer and go-play-region
Date: Sat, 7 Aug 2021 09:04:32 -0400 (EDT)

branch: elpa/go-mode
commit 4f3befb4cd19fe8efa03d3780285cf5eb2e8bf0f
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    add go-play-buffer and go-play-region
---
 go-mode.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/go-mode.el b/go-mode.el
index 2537ca7..bd00c10 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -15,6 +15,7 @@
 ;; - Support for C-M-e (end-of-defun)
 ;; - Support for C-M-h (mark-defun
 ;; - go-goto-imports
+;; - go-play-buffer and go-play-region
 ;;
 ;; Minor changes:
 ;; - use view-mode for the godoc buffer
@@ -461,6 +462,28 @@ Replace the current buffer on success; display errors on 
failure."
       (message "No imports found. Is this really a Go file?")))))
 
 
+(defun go-play-buffer ()
+  (interactive)
+  (go-play-region (point-min) (point-max)))
+
+(defun go-play-region (start end)
+  (interactive "r")
+  (let* ((url-request-method "POST")
+         (url-request-extra-headers
+          '(("Content-Type" . "application/x-www-form-urlencoded")))
+         (url-request-data (buffer-substring-no-properties start end))
+         (content-buf (url-retrieve
+                       "http://play.golang.org/share";
+                       (lambda (arg)
+                         (cond
+                          ((equal :error (car arg))
+                           (signal 'go-play-error (cdr arg)))
+                          (t
+                           (re-search-forward "\n\n")
+                           (kill-new (format "http://play.golang.org/p/%s"; 
(buffer-substring (point) (point-max))))
+                           (message "http://play.golang.org/p/%s"; 
(buffer-substring (point) (point-max)))))))))))
+
+
 ;; "However, it should not call syntax-ppss-flush-cache; so, it is not allowed 
to call syntax-ppss on some position and later modify the buffer at an earlier 
position."
 ;; ↑ let's hope this doesn't screw me over
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]