author | Luke Hoersten <Luke@Hoersten.org> |
Sat, 08 Aug 2009 11:26:04 -0500 | |
changeset 8 | f16b95667aa6 |
parent 4 | 0fda818a8b6a |
child 17 | 2067d6164e07 |
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") |
|
8
f16b95667aa6
Added line numbers and line truncation to C++.
Luke Hoersten <Luke@Hoersten.org>
parents:
4
diff
changeset
|
18 |
(let* ((pastebin-url "http://inf/paste/") |
1 | 19 |
(url-request-method "POST") |
20 |
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded"))) |
|
21 |
(url-request-data |
|
22 |
(format "title=%s&content=%s&lexer=%s&author=%s" |
|
23 |
(url-hexify-string (buffer-file-name)) ; title |
|
24 |
(url-hexify-string (buffer-substring-no-properties start end)) ; content |
|
25 |
(url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ; lexer |
|
26 |
(url-hexify-string (user-full-name))))) ; author |
|
27 |
(url-retrieve pastebin-url (lambda (arg) |
|
28 |
(cond |
|
29 |
((equal :error (car arg)) |
|
30 |
(signal (cdr arg))) |
|
31 |
((equal :redirect (car arg)) |
|
32 |
(let ((redirected (cadr arg))) |
|
33 |
(message redirected) |
|
34 |
(with-temp-buffer |
|
35 |
(insert redirected) |
|
36 |
(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
|
37 |
|
0fda818a8b6a
Added doxymacs and provides for requires.
Luke Hoersten <Luke@Hoersten.org>
parents:
1
diff
changeset
|
38 |
(provide 'hoersten-pastebin-region) |