-
Notifications
You must be signed in to change notification settings - Fork 5
/
carbon-now-sh.el
65 lines (48 loc) · 1.89 KB
/
carbon-now-sh.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;;; carbon-now-sh.el --- https://carbon.now.sh integration.
;; Copyright © 2018 Vitalii Elenhaupt <[email protected]>
;; Author: Vitalii Elenhaupt
;; URL: https://github.com/veelenga/carbon-now-sh.el
;; Keywords: convenience
;; Version: 0
;; Package-Requires: ((emacs "24.4"))
;; This file is not part of GNU Emacs.
;;; License:
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This package allows you to open selected content in carbon.now.sh.
;; Usage:
;; Select some text and run this interactive function:
;;
;; (carbon-now-sh)
;;; Code:
(require 'cl-lib)
(require 'url-util)
(defgroup carbon-now-sh nil
"https://carbon.now.sh integration"
:prefix "carbon-now-sh-"
:group 'applications
)
(defconst carbon-now-sh-baseurl "https://carbon.now.sh")
(cl-defun carbon-now-sh--region(&key
(beg (and (use-region-p) (region-beginning)))
(end (and (use-region-p) (region-end))))
"Return code in current region."
(when beg (buffer-substring-no-properties beg end)))
;;;###autoload
(defun carbon-now-sh ()
"Open current region in carbon.now.sh."
(interactive)
(browse-url
(concat carbon-now-sh-baseurl "?code="
(url-hexify-string (carbon-now-sh--region)))))
(provide 'carbon-now-sh)
;;; carbon-now-sh.el ends here