[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 59dfa96 423/495: Add confirmation prompt for Playg
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 59dfa96 423/495: Add confirmation prompt for Playground uploads |
Date: |
Sat, 7 Aug 2021 09:06:01 -0400 (EDT) |
branch: elpa/go-mode
commit 59dfa9627d41d82b0261fabb74432ed908db4e0b
Author: Peter Sanford <psanford@sanford.io>
Commit: Muir Manders <muir@retailnext.net>
Add confirmation prompt for Playground uploads
go-play-region and go-play-buffer will now ask for confirmation before
uploading to the Go Playground. This is to help prevent accidental
uploads of private code that should not be posted to the Playground.
You can disable the prompt by setting go-confirm-playground-uploads to
nil.
This fixes #267
Closes: #281 [via git-merge-pr]
---
go-mode.el | 57 +++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 20 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index e19df3b..d515174 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -211,6 +211,14 @@ mis-identifying them as gb projects."
:type '(repeat function)
:group 'go)
+(defcustom go-confirm-playground-uploads t
+ "Ask before uploading code to the public Go Playground.
+
+Set this to nil to upload without prompting.
+"
+ :type 'boolean
+ :group 'go)
+
(defcustom godoc-command "go doc"
"Which executable to use for `godoc'.
This can either be 'godoc' or 'go doc', both as an absolute path
@@ -1273,27 +1281,36 @@ declaration."
(defun go-play-region (start end)
"Send the region between START and END to the Playground.
If non-nil `go-play-browse-function' is called with the
-Playground URL."
+Playground URL.
+
+By default this function will prompt to confirm you want to upload
+code to the Playground. You can disable the confirmation by setting
+`go-confirm-playground-uploads' to nil.
+"
(interactive "r")
- (let* ((url-request-method "POST")
- (url-request-extra-headers
- '(("Content-Type" . "application/x-www-form-urlencoded")))
- (url-request-data
- (encode-coding-string
- (buffer-substring-no-properties start end)
- 'utf-8))
- (content-buf (url-retrieve
- "https://play.golang.org/share"
- (lambda (arg)
- (cond
- ((equal :error (car arg))
- (signal 'go-play-error (cdr arg)))
- (t
- (re-search-forward "\n\n")
- (let ((url (format "https://play.golang.org/p/%s"
- (buffer-substring (point)
(point-max)))))
- (when go-play-browse-function
- (funcall go-play-browse-function url)))))))))))
+ (if (and go-confirm-playground-uploads
+ (not (yes-or-no-p "Upload to public Go Playground?")))
+ (message "Upload aborted")
+ (let* ((url-request-method "POST")
+ (url-request-extra-headers
+ '(("Content-Type" . "application/x-www-form-urlencoded")))
+ (url-request-data
+ (encode-coding-string
+ (buffer-substring-no-properties start end)
+ 'utf-8))
+
+ (content-buf (url-retrieve
+ "https://play.golang.org/share"
+ (lambda (arg)
+ (cond
+ ((equal :error (car arg))
+ (signal 'go-play-error (cdr arg)))
+ (t
+ (re-search-forward "\n\n")
+ (let ((url (format "https://play.golang.org/p/%s"
+ (buffer-substring (point)
(point-max)))))
+ (when go-play-browse-function
+ (funcall go-play-browse-function
url))))))))))))
;;;###autoload
(defun go-download-play (url)
- [nongnu] elpa/go-mode 60ed26e 368/495: cmd/guru: emacs: only check modified buffers with file names, (continued)
- [nongnu] elpa/go-mode 60ed26e 368/495: cmd/guru: emacs: only check modified buffers with file names, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d209550 353/495: cmd/guru: emacs: minor changes to keybindings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6ac5669 372/495: cmd/guru: emacs: interpret byte offsets correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode afb2a24 382/495: go.tools: use golang.org/x/... import paths, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3a82342 379/495: Regenerate AUTHORS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8991b83 384/495: refactor/rename: emacs: kill go-rename buffer correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode adea2e5 395/495: Make go-guru-build-tags a list of strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d511e35 402/495: Replace obsolete one-argument form of ‘looking-back’., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 35f6826 404/495: Bump version to 1.5.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode da55ef1 413/495: Evaluate error conditions before prompting for new name, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 59dfa96 423/495: Add confirmation prompt for Playground uploads,
ELPA Syncer <=
- [nongnu] elpa/go-mode 13e9f22 428/495: Fix go-rename when buffer is not visiting any file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9ab06b3 443/495: indent: fix nested dangling lines that don't use parens, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6d58e9d 442/495: indent: fix case statement in func in composite literal, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 592bd4b 440/495: indent: fix various cases with dangling operators, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with dangling "=", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f9174b2 458/495: Improve go-dot-mod-mode font lock regexp, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 91b37c4 461/495: Disable output during indentation tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d712cf3 470/495: Make yes-or-no-p's PROMPT end in a space, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd2f6d2 467/495: Fix multiline func signature fontification., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b91a6cd 479/495: Fix composite literal key fontification, ELPA Syncer, 2021/08/07