[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 02d44df 067/495: add function for downloading play
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 02d44df 067/495: add function for downloading playgrounds into emacs |
Date: |
Sat, 7 Aug 2021 09:04:45 -0400 (EDT) |
branch: elpa/go-mode
commit 02d44dfccaa9fc0e2c963ce858f0efff17b7635b
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
add function for downloading playgrounds into emacs
---
README.md | 1 +
go-mode.el | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/README.md b/README.md
index 1e98677..85906a6 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,7 @@ Features
- Support for `C-M-e` (`end-of-defun`)
- Support for `C-M-h` (`mark-defun`)
- Two functions for sending code to the Playground (`go-play-buffer` and
`go-play-region`)
+- A function for downloading code from the Playground into a Go buffer
(`go-download-play`)
- A function for adding imports, including tab completion (`go-import-add`,
bound to `C-c C-a`)
- A function for removing or commenting unused imports
(`go-remove-unused-imports`)
- A function for jumping to the file's imports (`go-goto-imports`)
diff --git a/go-mode.el b/go-mode.el
index a7874cc..8b3b2ce 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -14,6 +14,8 @@
(require 'diff-mode)
(require 'cl))
+(require 'ffap)
+
(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]")
(defconst gofmt-stdin-tag "<standard input>")
(defconst go-identifier-regexp "[[:word:][:multibyte:]_]+")
@@ -524,6 +526,20 @@ link in the kill ring."
(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)))))))))))
+;;;###autoload
+(defun go-download-play (url)
+ "Downloads a paste from the playground and inserts it in a Go
+buffer. Tries to look for a URL at point."
+ (interactive (list (read-from-minibuffer "Playground URL: " (ffap-url-p
(ffap-string-at-point 'url)))))
+ (with-current-buffer (url-retrieve-synchronously (concat url ".go"))
+ (let ((buffer (generate-new-buffer (concat (car (reverse (split-string url
"/"))) ".go"))))
+ (goto-char (point-min))
+ (re-search-forward "\n\n")
+ (copy-to-buffer buffer (point) (point-max))
+ (kill-buffer)
+ (with-current-buffer buffer
+ (go-mode)
+ (switch-to-buffer buffer)))))
;; "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
- [nongnu] elpa/go-mode fb9ab02 087/495: buffer-file-truename is an *abbreviated* truename, so use file-truename instead., (continued)
- [nongnu] elpa/go-mode fb9ab02 087/495: buffer-file-truename is an *abbreviated* truename, so use file-truename instead., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 745c437 092/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c833b77 094/495: Fix cache invalidation for dangling operator cache, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 87c8b6e 096/495: do not use dangling op cache when buffer is narrowed, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8e19ae5 097/495: add some documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b5960fe 099/495: nicer messages in gofmt, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 939d630 100/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 47b3928 102/495: disable read-only on error buffer before trying to write to it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c94ca2e 064/495: refactor, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6b77ff1 065/495: allow disabling fontification for function/method calls, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 02d44df 067/495: add function for downloading playgrounds into emacs,
ELPA Syncer <=
- [nongnu] elpa/go-mode ec6fef4 066/495: Define a customization group for go-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 856eff3 105/495: Instead of relying on gofmt's -d flag, use diff -n directly. This, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d5839a0 106/495: use kill-whole-line directly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e1bb58a 109/495: Update README because go-mode.el is now upstream, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b1bb0e0 111/495: replace shell-command-on-region with call-process-region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9f1f94e 113/495: use own implementation of go--string-prefix-p because it has been added in Emacs 24 and people are still using Emacs 23, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 22192f7 121/495: use featurep instead of version string to check for xemacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3b0efdd 132/495: docstrings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7ab928a 146/495: Add support for methods that have no name for the receiver, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 83de700 145/495: Enable compilation-mode for gofmt error buffer before displaying it, ELPA Syncer, 2021/08/07