dpaste region function new form
This commit is contained in:
parent
96d3c0c068
commit
722217a997
|
@ -112,43 +112,46 @@ binding for Kuso IDE dpaste plugin"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
(defun dpaste-region ()
|
(defun dpaste-region ()
|
||||||
"dpaste the region and return the URL."
|
"dpaste the region and return the URL."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let (start end text type title run poster command buf)
|
(let (start end text type title run poster command buf)
|
||||||
(setq start (region-beginning))
|
;; (setq start (region-beginning))
|
||||||
(setq end (region-end))
|
;; (setq end (region-end))
|
||||||
(if (> start end)
|
;; (if (> start end)
|
||||||
(progn
|
;; (progn
|
||||||
(setq tmp start)
|
;; (setq tmp start)
|
||||||
(setq start end)
|
;; (setq start end)
|
||||||
(setq end tmp)
|
;; (setq end tmp)
|
||||||
)
|
;; )
|
||||||
)
|
;; )
|
||||||
;;(setq text (get-region-text))
|
(setq text (get-region-text))
|
||||||
(deactivate-mark)
|
|
||||||
|
|
||||||
(setq title (or (buffer-file-name) (buffer-name)))
|
(setq title (or (buffer-file-name) (buffer-name)))
|
||||||
(setq poster "sameer")
|
(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)) ""))
|
(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'"
|
" -A 'Kuso dpaste plugin'"
|
||||||
" -F 'language=" type "'"
|
" -F 'language=" type "'"
|
||||||
" -F 'title=" title "'"
|
" -F 'title=" title "'"
|
||||||
" -F 'poster=" poster "'"
|
" -F 'poster=" poster "'"
|
||||||
" http://dpaste.com/api/v1/") buf)
|
" http://dpaste.com/api/v1/"))
|
||||||
(with-current-buffer buf
|
|
||||||
|
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
;; Also get from dpaste.el that i mentioned above ------------
|
|
||||||
(search-forward-regexp "^Location: http://dpaste.com/[0-9]+/")
|
(search-forward-regexp "^Location: http://dpaste.com/[0-9]+/")
|
||||||
(message "Paste created: %s (yanked)" (match-string 1))
|
(message "Link: %s (yanked)" (match-string 1))
|
||||||
(kill-new (match-string 1)))
|
(kill-new (match-string 1))
|
||||||
(kill-buffer but)
|
)
|
||||||
|
|
||||||
;; ----------------------------
|
;; ----------------------------
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
;; ----------------------------------------------------------------------
|
;; ----------------------------------------------------------------------
|
||||||
;; Minor Modes
|
;; Minor Modes
|
||||||
;; ----------------------------------------------------------------------
|
;; ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue