author | Luke Hoersten <Luke@Hoersten.org> |
Sun, 04 Dec 2011 12:49:31 -0600 | |
changeset 46 | 2c6b198426df |
parent 35 | 4a9c440b6764 |
permissions | -rw-r--r-- |
4
0fda818a8b6a
Added doxymacs and provides for requires.
Luke Hoersten <Luke@Hoersten.org>
parents:
1
diff
changeset
|
1 |
;; ~/.emacs.d/hoersten-pastebin-region.el |
0fda818a8b6a
Added doxymacs and provides for requires.
Luke Hoersten <Luke@Hoersten.org>
parents:
1
diff
changeset
|
2 |
;; Luke Hoersten <[email protected]> |
0 | 3 |
|
4 |
;; custom keys |
|
5 |
(global-set-key (kbd "C-c w") 'pastebin-region) |
|
6 |
||
7 |
;; Based on http://www.emacswiki.org/cgi-bin/wiki/download/pastebin.el |
|
8 |
(defvar pastebin-type-assoc |
|
9 |
'((emacs-lisp-mode . "common-lisp") |
|
1 | 10 |
(c-mode . "c") |
11 |
(python-mode . "python") |
|
12 |
(nxml-mode . "xml") |
|
13 |
(c++-mode . "cpp"))) |
|
0 | 14 |
|
15 |
(defun pastebin-region (start end) |
|
16 |
"Send selected text to dpaste pastebin." |
|
17 |
(interactive "r") |
|
17
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
18 |
(let* |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
19 |
((pastebin-url "http://inf/paste/") |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
20 |
(url-request-method "POST") |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
21 |
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded"))) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
22 |
(url-request-data |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
23 |
(format |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
24 |
"title=%s&content=%s&lexer=%s&author=%s" |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
25 |
(url-hexify-string (buffer-file-name)) ; title |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
26 |
(url-hexify-string (buffer-substring-no-properties start end)) ; content |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
27 |
(url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ; lexer |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
28 |
(url-hexify-string (user-full-name))))) ; author |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
29 |
(url-retrieve |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
30 |
pastebin-url |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
31 |
(lambda (arg) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
32 |
(cond |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
33 |
((equal :error (car arg)) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
34 |
(signal (cdr arg))) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
35 |
((equal :redirect (car arg)) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
36 |
(let ((redirected (cadr arg))) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
37 |
(message redirected) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
38 |
(with-temp-buffer |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
39 |
(insert redirected) |
2067d6164e07
Updated nav and yasnipped modes as well as cleaned up the pastebin script.
Luke Hoersten <Luke@Hoersten.org>
parents:
8
diff
changeset
|
40 |
(clipboard-kill-ring-save (point-min) (point-max)))))))))) |
4
0fda818a8b6a
Added doxymacs and provides for requires.
Luke Hoersten <Luke@Hoersten.org>
parents:
1
diff
changeset
|
41 |
|
35
4a9c440b6764
Moved 3rd party libs to separate dir and added optional scion haskell support.
Luke Hoersten <Luke@Hoersten.org>
parents:
29
diff
changeset
|
42 |
(message "Loading pastebin-region...done") |
4a9c440b6764
Moved 3rd party libs to separate dir and added optional scion haskell support.
Luke Hoersten <Luke@Hoersten.org>
parents:
29
diff
changeset
|
43 |
(provide 'pastebin-region) |