[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode d548425 483/486: Create rust-playpen.el from exi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode d548425 483/486: Create rust-playpen.el from existing code |
Date: |
Sat, 7 Aug 2021 09:26:19 -0400 (EDT) |
branch: elpa/rust-mode
commit d54842519e512b9197e0e8b9421c0771307e33b9
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: brotzeit <brotzeitmacher@gmail.com>
Create rust-playpen.el from existing code
---
Makefile | 1 +
rust-mode.el | 42 ----------------------------------------
rust-playpen.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 42 deletions(-)
diff --git a/Makefile b/Makefile
index 7ef02af..ded2945 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ EMACS_ARGS ?=
ELS = rust-mode.el
ELS += rust-compile.el
+ELS += rust-playpen.el
ELS += rust-rustfmt.el
ELCS = $(ELS:.el=.elc)
diff --git a/rust-mode.el b/rust-mode.el
index 37b5cd3..0b1f5d1 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -16,7 +16,6 @@
;;; Code:
(eval-when-compile (require 'rx))
-(eval-when-compile (require 'url-vars))
(require 'json)
(require 'thingatpt)
@@ -54,16 +53,6 @@ When nil, `where' will be aligned with `fn' or `trait'."
:group 'rust-mode
:safe #'booleanp)
-(defcustom rust-playpen-url-format "https://play.rust-lang.org/?code=%s"
- "Format string to use when submitting code to the playpen."
- :type 'string
- :group 'rust-mode)
-
-(defcustom rust-shortener-url-format
"https://is.gd/create.php?format=simple&url=%s"
- "Format string to use for creating the shortened link of a playpen
submission."
- :type 'string
- :group 'rust-mode)
-
(defcustom rust-match-angle-brackets t
"Whether to enable angle bracket (`<' and `>') matching where appropriate."
:type 'boolean
@@ -1621,37 +1610,6 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
;;; Secondary Commands
-(defun rust-playpen-region (begin end)
- "Create a shareable URL for the region from BEGIN to END on the Rust
playpen."
- (interactive "r")
- (let* ((data (buffer-substring begin end))
- (escaped-data (url-hexify-string data))
- (escaped-playpen-url (url-hexify-string
- (format rust-playpen-url-format escaped-data))))
- (if (> (length escaped-playpen-url) 5000)
- (error "encoded playpen data exceeds 5000 character limit (length %s)"
- (length escaped-playpen-url))
- (let ((shortener-url (format rust-shortener-url-format
escaped-playpen-url))
- (url-request-method "POST"))
- (url-retrieve shortener-url
- (lambda (state)
- ;; filter out the headers etc. included at the
- ;; start of the buffer: the relevant text
- ;; (shortened url or error message) is exactly
- ;; the last line.
- (goto-char (point-max))
- (let ((last-line (thing-at-point 'line t))
- (err (plist-get state :error)))
- (kill-buffer)
- (if err
- (error "failed to shorten playpen url: %s"
last-line)
- (message "%s" last-line)))))))))
-
-(defun rust-playpen-buffer ()
- "Create a shareable URL for the contents of the buffer on the Rust playpen."
- (interactive)
- (rust-playpen-region (point-min) (point-max)))
-
(defun rust-promote-module-into-dir ()
"Promote the module file visited by the current buffer into its own
directory.
diff --git a/rust-playpen.el b/rust-playpen.el
new file mode 100644
index 0000000..1a9e583
--- /dev/null
+++ b/rust-playpen.el
@@ -0,0 +1,59 @@
+;;; rust-playpen.el --- Support for the Rust Playground -*- lexical-binding:t
-*-
+;;; Commentary:
+
+;; This library implements support for the Rust Playground,
+;; which is hosted at https://play.rust-lang.org and developed
+;; at https://github.com/integer32llc/rust-playground.
+
+;;; Code:
+
+(eval-when-compile (require 'url))
+
+;;; Options
+
+(defcustom rust-playpen-url-format "https://play.rust-lang.org/?code=%s"
+ "Format string to use when submitting code to the playpen."
+ :type 'string
+ :group 'rust-mode)
+
+(defcustom rust-shortener-url-format
"https://is.gd/create.php?format=simple&url=%s"
+ "Format string to use for creating the shortened link of a playpen
submission."
+ :type 'string
+ :group 'rust-mode)
+
+;;; Commands
+
+(defun rust-playpen-region (begin end)
+ "Create a shareable URL for the region from BEGIN to END on the Rust
playpen."
+ (interactive "r")
+ (let* ((data (buffer-substring begin end))
+ (escaped-data (url-hexify-string data))
+ (escaped-playpen-url (url-hexify-string
+ (format rust-playpen-url-format escaped-data))))
+ (if (> (length escaped-playpen-url) 5000)
+ (error "encoded playpen data exceeds 5000 character limit (length %s)"
+ (length escaped-playpen-url))
+ (let ((shortener-url (format rust-shortener-url-format
escaped-playpen-url))
+ (url-request-method "POST"))
+ (url-retrieve shortener-url
+ (lambda (state)
+ ;; filter out the headers etc. included at the
+ ;; start of the buffer: the relevant text
+ ;; (shortened url or error message) is exactly
+ ;; the last line.
+ (goto-char (point-max))
+ (let ((last-line (thing-at-point 'line t))
+ (err (plist-get state :error)))
+ (kill-buffer)
+ (if err
+ (error "failed to shorten playpen url: %s"
last-line)
+ (message "%s" last-line)))))))))
+
+(defun rust-playpen-buffer ()
+ "Create a shareable URL for the contents of the buffer on the Rust playpen."
+ (interactive)
+ (rust-playpen-region (point-min) (point-max)))
+
+;;; _
+(provide 'rust-playpen)
+;;; rust-playpen.el ends here
- [nongnu] elpa/rust-mode 39f32cc 447/486: In emacs >= 26.2, use replace-buffer-contents after formatting, (continued)
- [nongnu] elpa/rust-mode 39f32cc 447/486: In emacs >= 26.2, use replace-buffer-contents after formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eca55c0 451/486: Check for -> and => early in rust-ordinary-lt-gt-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ca7d99c 469/486: Set default directory when compiling., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c5c7ed3 471/486: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4e394ac 475/486: Add Makefile, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 09b4320 476/486: test: Suppress some noisy messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode afeddec 325/486: Merge pull request #224 from tromey/beginning-of-defun, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7fd78f0 444/486: rust-goto-format-problem: make sure to always just to a buffer that exists., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9e03890 478/486: Create rust-compile.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 41642f0 481/486: rust-end-of-string: Move definition, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d548425 483/486: Create rust-playpen.el from existing code,
ELPA Syncer <=
- [nongnu] elpa/rust-mode eb5270b 437/486: rust-before-save-hook: log errors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2df6cf7 439/486: Don't fail on re-search-forward. (#359), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ca415e9 470/486: Add rust-check function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e327658 274/486: Merge pull request #178 from ryuslash/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7e2533f 415/486: Fix rustc-compilation-regexps: match error messages with dashes. (#331), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9107989 424/486: review, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d0f3f45 431/486: imenu: fn items: match async/const and all pub variants. (#346), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7afad7b 464/486: rearrange II: Regexp variables and functions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bbb3792 473/486: Remove "-face" suffix from names of faces, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3eb6d2f 485/486: Create rust-utils.el from existing code, ELPA Syncer, 2021/08/07