dpaste region function new form

This commit is contained in:
Sameer Rahmani 2011-01-04 19:32:02 +03:30
parent 96d3c0c068
commit 722217a997
1 changed files with 24 additions and 21 deletions

View File

@ -112,43 +112,46 @@ binding for Kuso IDE dpaste plugin"
)
)
(defun dpaste-region ()
"dpaste the region and return the URL."
(interactive)
(let (start end text type title run poster command buf)
(setq start (region-beginning))
(setq end (region-end))
(if (> start end)
(progn
(setq tmp start)
(setq start end)
(setq end tmp)
)
)
;;(setq text (get-region-text))
(deactivate-mark)
;; (setq start (region-beginning))
;; (setq end (region-end))
;; (if (> start end)
;; (progn
;; (setq tmp start)
;; (setq start end)
;; (setq end tmp)
;; )
;; )
(setq text (get-region-text))
(setq title (or (buffer-file-name) (buffer-name)))
(setq poster "sameer")
(setq buf (generate-new-buffer "*Paste*"))
(log buf)
;; This line of code gets from the el file that i mentioned above
(setq type (or (cdr (assoc major-mode dpaste-support-types)) ""))
(shell-command-on-region start end (concat "curl -si" " -F 'content=<-'"
(with-temp-buffer
(insert text)
(shell-command-on-region start end (concat "curl -si" " -F 'content=<-'"
" -A 'Kuso dpaste plugin'"
" -F 'language=" type "'"
" -F 'title=" title "'"
" -F 'poster=" poster "'"
" http://dpaste.com/api/v1/") buf)
(with-current-buffer buf
" http://dpaste.com/api/v1/"))
(goto-char (point-min))
;; Also get from dpaste.el that i mentioned above ------------
(search-forward-regexp "^Location: http://dpaste.com/[0-9]+/")
(message "Paste created: %s (yanked)" (match-string 1))
(kill-new (match-string 1)))
(kill-buffer but)
(message "Link: %s (yanked)" (match-string 1))
(kill-new (match-string 1))
)
;; ----------------------------
)
)
;; ----------------------------------------------------------------------
;; Minor Modes
;; ----------------------------------------------------------------------