From 722217a9977c46e70d63f77075b98f4eee542f83 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 4 Jan 2011 19:32:02 +0330 Subject: [PATCH] dpaste region function new form --- src/plugins/dpaste.el | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/plugins/dpaste.el b/src/plugins/dpaste.el index 63b3429..a7ccda4 100644 --- a/src/plugins/dpaste.el +++ b/src/plugins/dpaste.el @@ -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 ;; ----------------------------------------------------------------------