Switched all webpaste/whatever to webpaste-watever to comply with elisp guidelines

master
Elis Axelsson 9 years ago
parent 92f309e16c
commit 505ffb3d3d
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 12
      README.org
  2. 4
      tests/unit/test-webpaste-error-lambdas.el
  3. 4
      tests/unit/test-webpaste-get-provider-priority.el
  4. 8
      tests/unit/test-webpaste-paste-region-and-buffer.el
  5. 8
      tests/unit/test-webpaste-paste-text.el
  6. 10
      tests/unit/test-webpaste-return-url.el
  7. 6
      tests/unit/test-webpaste-success-lambdas.el
  8. 100
      webpaste.el

@ -57,12 +57,12 @@ This can be added to the =:config= section of use-package:
*** Confirm pasting with a yes/no confirmation before pasting *** Confirm pasting with a yes/no confirmation before pasting
To enable a confirmation dialog to always pop up and require you to confirm To enable a confirmation dialog to always pop up and require you to confirm
pasting before text is actually sent to a paste-provider you just need to set pasting before text is actually sent to a paste-provider you just need to set
the variable =webpaste/paste-confirmation= to a value that is non-nil. the variable =webpaste-paste-confirmation= to a value that is non-nil.
Example: Example:
#+begin_src emacs-lisp :tangle yes #+begin_src emacs-lisp :tangle yes
;; Require confirmation before doing paste ;; Require confirmation before doing paste
(setq webpaste/paste-confirmation t) (setq webpaste-paste-confirmation t)
#+end_src #+end_src
Can also be put in the =:config= section of =use-package= the same way as the Can also be put in the =:config= section of =use-package= the same way as the
@ -76,7 +76,7 @@ This is webpaste's default behavior. After a succesfull paste, the returned URL
from the provider will be sent to the killring. You can disable this with from the provider will be sent to the killring. You can disable this with
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq webpaste/add-to-killring nil) (setq webpaste-add-to-killring nil)
#+END_SRC #+END_SRC
**** Copy URL to the clipboard **** Copy URL to the clipboard
@ -84,18 +84,18 @@ If you have [[https://github.com/rolandwalker/simpleclip][simpleclip]] installed
clipboard. You can enable this with clipboard. You can enable this with
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq webpaste/copy-to-clipboard t) (setq webpaste-copy-to-clipboard t)
#+END_SRC #+END_SRC
**** Open the recently created paste in the browser **** Open the recently created paste in the browser
To enable opening of recently created pastes in an external browser, you can To enable opening of recently created pastes in an external browser, you can
enable the option =webpaste/open-in-browser= by setting this value to a enable the option =webpaste-open-in-browser= by setting this value to a
non-nil value. non-nil value.
Example: Example:
#+begin_src emacs-lisp :tangle yes #+begin_src emacs-lisp :tangle yes
;; Open recently created pastes in an external browser ;; Open recently created pastes in an external browser
(setq webpaste/open-in-browser t) (setq webpaste-open-in-browser t)
#+end_src #+end_src
Can also be put in the =:config= section of =use-package= the same way as the Can also be put in the =:config= section of =use-package= the same way as the

@ -16,7 +16,7 @@
(it (it
"with fallback" "with fallback"
(let ((error-lambda (webpaste/providers-error-lambda :text "my text"))) (let ((error-lambda (webpaste-providers-error-lambda :text "my text")))
(funcall error-lambda :error-thrown "my error") (funcall error-lambda :error-thrown "my error")
(expect 'message (expect 'message
@ -30,7 +30,7 @@
(it (it
"without fallback" "without fallback"
(let ((error-lambda (webpaste/providers-error-lambda-no-failover :text "my text"))) (let ((error-lambda (webpaste-providers-error-lambda-no-failover :text "my text")))
(funcall error-lambda :error-thrown "my error") (funcall error-lambda :error-thrown "my error")
(expect 'message (expect 'message

@ -16,7 +16,7 @@
("provider3" . "lambda")))) ("provider3" . "lambda"))))
;; Do test ;; Do test
(expect (webpaste/get-provider-priority) (expect (webpaste-get-provider-priority)
:to-equal :to-equal
'("provider1" "provider2" "provider3")))) '("provider1" "provider2" "provider3"))))
@ -27,7 +27,7 @@
(let ((webpaste-provider-priority '("provider2" "provider1" "provider3"))) (let ((webpaste-provider-priority '("provider2" "provider1" "provider3")))
;; Do test ;; Do test
(expect (webpaste/get-provider-priority) (expect (webpaste-get-provider-priority)
:to-equal :to-equal
'("provider2" "provider1" "provider3"))))) '("provider2" "provider1" "provider3")))))

@ -12,10 +12,10 @@
(before-each (before-each
(spy-on 'webpaste-paste-text) (spy-on 'webpaste-paste-text)
(spy-on 'yes-or-no-p :and-return-value nil) (spy-on 'yes-or-no-p :and-return-value nil)
(setq webpaste/paste-confirmation t)) (setq webpaste-paste-confirmation t))
(after-each (after-each
(setq webpaste/paste-confirmation nil)) (setq webpaste-paste-confirmation nil))
(it (it
"can't paste because of answer to question is no" "can't paste because of answer to question is no"
@ -35,10 +35,10 @@
(before-each (before-each
(spy-on 'webpaste-paste-text) (spy-on 'webpaste-paste-text)
(spy-on 'yes-or-no-p :and-return-value t) (spy-on 'yes-or-no-p :and-return-value t)
(setq webpaste/paste-confirmation t)) (setq webpaste-paste-confirmation t))
(after-each (after-each
(setq webpaste/paste-confirmation nil)) (setq webpaste-paste-confirmation nil))
(it (it
"can paste because of answer to question is yes" "can paste because of answer to question is yes"

@ -8,11 +8,11 @@
(describe (describe
"Paste text to provider" "Paste text to provider"
:var (webpaste/tested-providers) :var (webpaste-tested-providers)
(before-each (before-each
;; Override which fake providers exists ;; Override which fake providers exists
(spy-on 'webpaste/get-provider-priority (spy-on 'webpaste-get-provider-priority
:and-return-value :and-return-value
'("provider1" "provider2")) '("provider1" "provider2"))
@ -20,7 +20,7 @@
(spy-on 'webpaste-paste-text-to-provider) (spy-on 'webpaste-paste-text-to-provider)
;; And let tested list be resetted for each test ;; And let tested list be resetted for each test
(setq webpaste/tested-providers nil)) (setq webpaste-tested-providers nil))
(it (it
@ -45,7 +45,7 @@
"provider2") "provider2")
;; Check that the tested list is empty so another run would restart ;; Check that the tested list is empty so another run would restart
(expect webpaste/tested-providers :to-equal nil))) (expect webpaste-tested-providers :to-equal nil)))
(describe (describe

@ -33,7 +33,7 @@
(it (it
"can open an external browser with the url" "can open an external browser with the url"
(let ((webpaste/open-in-browser t)) (let ((webpaste-open-in-browser t))
(webpaste-return-url "https://example.com/") (webpaste-return-url "https://example.com/")
(expect 'browse-url-generic (expect 'browse-url-generic
@ -43,9 +43,9 @@
(it (it
"can append language on return" "can append language on return"
(let ((webpaste/provider-separators (let ((webpaste-provider-separators
'(("https://example.com/" . "?lang="))) '(("https://example.com/" . "?lang=")))
(webpaste/provider-lang-alists (webpaste-provider-lang-alists
'(("https://example.com/" . ((lisp-interaction-mode . "lisp")))))) '(("https://example.com/" . ((lisp-interaction-mode . "lisp"))))))
(spy-calls-reset 'kill-new) (spy-calls-reset 'kill-new)
@ -58,8 +58,8 @@
(it (it
"can put contents in clipboard using simpleclip" "can put contents in clipboard using simpleclip"
(let ((webpaste/copy-to-clipboard t) (let ((webpaste-copy-to-clipboard t)
(webpaste/webpaste/add-to-killring nil)) (webpaste-add-to-killring nil))
(webpaste-return-url "https://example.com/") (webpaste-return-url "https://example.com/")

@ -17,7 +17,7 @@
(it (it
"using a response header" "using a response header"
(let ((success-lambda (webpaste/providers-success-location-header))) (let ((success-lambda (webpaste-providers-success-location-header)))
(funcall success-lambda :response "my fake response") (funcall success-lambda :response "my fake response")
(expect 'webpaste-return-url (expect 'webpaste-return-url
@ -27,7 +27,7 @@
(xit (xit
"when using some request.el response thingy" "when using some request.el response thingy"
(let ((success-lambda (webpaste/providers-success-response-url))) (let ((success-lambda (webpaste-providers-success-response-url)))
(funcall success-lambda :response "my fake response") (funcall success-lambda :response "my fake response")
(expect 'webpaste-return-url (expect 'webpaste-return-url
@ -38,7 +38,7 @@
(it (it
"when returning a string with an url" "when returning a string with an url"
(let ((success-lambda (webpaste/providers-success-returned-string))) (let ((success-lambda (webpaste-providers-success-returned-string)))
(funcall success-lambda :data "\"https://example.com/\" (funcall success-lambda :data "\"https://example.com/\"
") ")

@ -54,51 +54,53 @@ default to all providers in order defined in ‘webpaste-providers’ list."
:type '(repeat string)) :type '(repeat string))
(defcustom webpaste/paste-confirmation nil (defcustom webpaste-paste-confirmation nil
"Prompt for a yes/no confirmation before attempting to paste a region or buffer." "Prompt for a yes/no confirmation before attempting to paste a region or buffer."
:group 'webpaste :group 'webpaste
:type 'boolean) :type 'boolean)
(defcustom webpaste/open-in-browser nil (defcustom webpaste-open-in-browser nil
"Open recently created pastes in a browser. "Open recently created pastes in a browser.
This uses `browse-url-generic' to open URLs." This uses `browse-url-generic' to open URLs."
:group 'webpaste :group 'webpaste
:type 'boolean) :type 'boolean)
(defcustom webpaste/copy-to-clipboard nil
(defcustom webpaste-copy-to-clipboard nil
"Uses simpleclip to send the provider's returned URL to the clipboard. "Uses simpleclip to send the provider's returned URL to the clipboard.
This uses `simpleclip-set-contents' to copy to clipboard." This uses `simpleclip-set-contents' to copy to clipboard."
:group 'webpaste :group 'webpaste
:type 'boolean) :type 'boolean)
(defcustom webpaste/add-to-killring t
(defcustom webpaste-add-to-killring t
"Add the returned URL to the killring after paste." "Add the returned URL to the killring after paste."
:group 'webpaste :group 'webpaste
:type 'boolean) :type 'boolean)
(defvar webpaste/tested-providers () (defvar webpaste-tested-providers ()
"Variable for storing which providers to try in which order while running. "Variable for storing which providers to try in which order while running.
This list will be re-populated each run based on webpaste-provider-priority or This list will be re-populated each run based on webpaste-provider-priority or
if that variable is nil, it will use the list of names from webpaste-providers if that variable is nil, it will use the list of names from webpaste-providers
each run.") each run.")
(defvar webpaste/provider-separators () (defvar webpaste-provider-separators ()
"Variable for storing separators for providers that doesn't post language. "Variable for storing separators for providers that doesn't post language.
Some providers accepts a post parameter with which language the code is. But Some providers accepts a post parameter with which language the code is. But
some providers want to append the language to the resulting URL.") some providers want to append the language to the resulting URL.")
(defvar webpaste/provider-lang-alists () (defvar webpaste-provider-lang-alists ()
"Variable for storing alists with languages for highlighting for providers. "Variable for storing alists with languages for highlighting for providers.
This list will be populated when you add providers to have the languages This list will be populated when you add providers to have the languages
precalculated, and also available both for pre and post request access.") precalculated, and also available both for pre and post request access.")
(defvar webpaste/default-lang-alist (defvar webpaste-default-lang-alist
'((css-mode . "css") '((css-mode . "css")
(fundamental-mode . "text") (fundamental-mode . "text")
(html-mode . "html") (html-mode . "html")
@ -112,21 +114,21 @@ precalculated, and also available both for pre and post request access.")
;;; Predefined error lambda for providers ;;; Predefined error lambda for providers
(cl-defun webpaste/providers-error-lambda (&key text) (cl-defun webpaste-providers-error-lambda (&key text)
"Predefined error callback for providers that always does failover." "Predefined error callback for providers that always does failover."
(cl-function (lambda (&key error-thrown &allow-other-keys) (cl-function (lambda (&key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown) (message "Got error: %S" error-thrown)
(webpaste-paste-text text)))) (webpaste-paste-text text))))
(cl-defun webpaste/providers-error-lambda-no-failover (&key text) (cl-defun webpaste-providers-error-lambda-no-failover (&key text)
"Predefined error callback for providers that shouldn't do failover." "Predefined error callback for providers that shouldn't do failover."
(cl-function (lambda (&key error-thrown &allow-other-keys) (cl-function (lambda (&key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)))) (message "Got error: %S" error-thrown))))
;;; Predefined success lambdas for providers ;;; Predefined success lambdas for providers
(cl-defun webpaste/providers-success-location-header () (cl-defun webpaste-providers-success-location-header ()
"Predefined success callback for providers returning a Location header." "Predefined success callback for providers returning a Location header."
(cl-function (lambda (&key response &allow-other-keys) (cl-function (lambda (&key response &allow-other-keys)
(when response (when response
@ -134,7 +136,7 @@ precalculated, and also available both for pre and post request access.")
(request-response-header response "Location")))))) (request-response-header response "Location"))))))
(cl-defun webpaste/providers-success-response-url () (cl-defun webpaste-providers-success-response-url ()
"Predefined success callback for providers that and up with an URL somehow." "Predefined success callback for providers that and up with an URL somehow."
(cl-function (lambda (&key response &allow-other-keys) (cl-function (lambda (&key response &allow-other-keys)
(when response (when response
@ -142,7 +144,7 @@ precalculated, and also available both for pre and post request access.")
(request-response-url response)))))) (request-response-url response))))))
(cl-defun webpaste/providers-success-returned-string () (cl-defun webpaste-providers-success-returned-string ()
"Predefined success callback for providers returning a string with URL." "Predefined success callback for providers returning a string with URL."
(cl-function (lambda (&key data &allow-other-keys) (cl-function (lambda (&key data &allow-other-keys)
(when data (when data
@ -152,7 +154,7 @@ precalculated, and also available both for pre and post request access.")
(webpaste-return-url data))))) (webpaste-return-url data)))))
(cl-defun webpaste/providers-default-post-field-lambda () (cl-defun webpaste-providers-default-post-field-lambda ()
"Predefined lambda for building post fields." "Predefined lambda for building post fields."
(cl-function (lambda (&key text (cl-function (lambda (&key text
post-field post-field
@ -162,7 +164,7 @@ precalculated, and also available both for pre and post request access.")
(cl-pushnew (cons post-field text) post-data) (cl-pushnew (cons post-field text) post-data)
;; Fetch alist of languages for this provider ;; Fetch alist of languages for this provider
(let ((provider-lang-alist (cdr (assoc provider-uri webpaste/provider-lang-alists)))) (let ((provider-lang-alist (cdr (assoc provider-uri webpaste-provider-lang-alists))))
;; Fetch language name for this major mode for this provider ;; Fetch language name for this major mode for this provider
(let ((language-name (cdr (assoc major-mode provider-lang-alist)))) (let ((language-name (cdr (assoc major-mode provider-lang-alist))))
(if (and post-lang-field-name language-name) (if (and post-lang-field-name language-name)
@ -172,11 +174,11 @@ precalculated, and also available both for pre and post request access.")
(defun webpaste/get-lang-alist-with-overrides (overrides) (defun webpaste-get-lang-alist-with-overrides (overrides)
"Fetches lang-alist with OVERRIDES applied." "Fetches lang-alist with OVERRIDES applied."
;; Copy original list to temporary list ;; Copy original list to temporary list
(let ((lang-alist webpaste/default-lang-alist)) (let ((lang-alist webpaste-default-lang-alist))
;; Go through list of overrides and append them to the temporary list ;; Go through list of overrides and append them to the temporary list
(dolist (override-element overrides) (dolist (override-element overrides)
(cl-pushnew override-element lang-alist)) (cl-pushnew override-element lang-alist))
@ -195,8 +197,8 @@ precalculated, and also available both for pre and post request access.")
(parser 'buffer-string) (parser 'buffer-string)
(lang-overrides '()) (lang-overrides '())
(lang-uri-separator nil) (lang-uri-separator nil)
(error-lambda 'webpaste/providers-error-lambda) (error-lambda 'webpaste-providers-error-lambda)
(post-field-lambda 'webpaste/providers-default-post-field-lambda)) (post-field-lambda 'webpaste-providers-default-post-field-lambda))
"Function to create the lambda function for a provider. "Function to create the lambda function for a provider.
Usage: Usage:
@ -210,8 +212,8 @@ Required params:
:success-lambda Callback sent to `request', look up how to write these in the :success-lambda Callback sent to `request', look up how to write these in the
documentation for `request'. Two good examples are documentation for `request'. Two good examples are
`webpaste/providers-success-location-header' and `webpaste-providers-success-location-header' and
`webpaste/providers-success-returned-string' as well as the `webpaste-providers-success-returned-string' as well as the
custom one used for the gist.github.com provider. custom one used for the gist.github.com provider.
Optional params: Optional params:
@ -235,8 +237,8 @@ Optional params:
:error-lambda Callback sent to `request', look up how to write these in the :error-lambda Callback sent to `request', look up how to write these in the
documentation for `request'. The default value for this is documentation for `request'. The default value for this is
`webpaste/providers-error-lambda', but there's also `webpaste-providers-error-lambda', but there's also
`webpaste/providers-error-lambda-no-failover' available if `webpaste-providers-error-lambda-no-failover' available if
you need a provider that isn't allowed to failover. you need a provider that isn't allowed to failover.
:post-field-lambda Function that builds and returns the post data that should be :post-field-lambda Function that builds and returns the post data that should be
@ -244,7 +246,7 @@ Optional params:
the names TEXT, POST-FIELD and POST-DATA. POST-DATA should the names TEXT, POST-FIELD and POST-DATA. POST-DATA should
default to `nil' or empty list. It also takes the option default to `nil' or empty list. It also takes the option
LANG-OVERRIDES which is a list that enables overiding of LANG-OVERRIDES which is a list that enables overiding of
`webpaste/default-lang-alist'. `webpaste-default-lang-alist'.
TEXT contains the data that should be sent. TEXT contains the data that should be sent.
POST-FIELD cointains the name of the field to be sent. POST-FIELD cointains the name of the field to be sent.
@ -252,11 +254,11 @@ Optional params:
;; If we get a separator sent to the function, append it to the list of ;; If we get a separator sent to the function, append it to the list of
;; separators for later use ;; separators for later use
(when lang-uri-separator (when lang-uri-separator
(cl-pushnew (cons uri lang-uri-separator) webpaste/provider-separators)) (cl-pushnew (cons uri lang-uri-separator) webpaste-provider-separators))
;; Add pre-calculated list of webpaste lang alists ;; Add pre-calculated list of webpaste lang alists
(cl-pushnew (cons uri (webpaste/get-lang-alist-with-overrides lang-overrides)) (cl-pushnew (cons uri (webpaste-get-lang-alist-with-overrides lang-overrides))
webpaste/provider-lang-alists) webpaste-provider-lang-alists)
(cl-function (cl-function
(lambda (text (lambda (text
@ -289,7 +291,7 @@ Optional params:
:post-field "c" :post-field "c"
:lang-uri-separator "/" :lang-uri-separator "/"
:lang-overrides '((emacs-lisp-mode . "elisp")) :lang-overrides '((emacs-lisp-mode . "elisp"))
:success-lambda 'webpaste/providers-success-location-header)) :success-lambda 'webpaste-providers-success-location-header))
("ix.io" ("ix.io"
,(webpaste-provider ,(webpaste-provider
@ -297,7 +299,7 @@ Optional params:
:post-field "f:1" :post-field "f:1"
:lang-uri-separator "/" :lang-uri-separator "/"
:lang-overrides '((emacs-lisp-mode . "elisp")) :lang-overrides '((emacs-lisp-mode . "elisp"))
:success-lambda 'webpaste/providers-success-returned-string)) :success-lambda 'webpaste-providers-success-returned-string))
("sprunge.us" ("sprunge.us"
,(webpaste-provider ,(webpaste-provider
@ -305,7 +307,7 @@ Optional params:
:post-field "sprunge" :post-field "sprunge"
:lang-uri-separator "?" :lang-uri-separator "?"
:lang-overrides '((emacs-lisp-mode . "elisp")) :lang-overrides '((emacs-lisp-mode . "elisp"))
:success-lambda 'webpaste/providers-success-returned-string)) :success-lambda 'webpaste-providers-success-returned-string))
("dpaste.com" ("dpaste.com"
,(webpaste-provider ,(webpaste-provider
@ -316,7 +318,7 @@ Optional params:
:post-field "content" :post-field "content"
:post-lang-field-name "syntax" :post-lang-field-name "syntax"
:lang-overrides '((emacs-lisp-mode . "clojure")) :lang-overrides '((emacs-lisp-mode . "clojure"))
:success-lambda 'webpaste/providers-success-location-header)) :success-lambda 'webpaste-providers-success-location-header))
("dpaste.de" ("dpaste.de"
,(webpaste-provider ,(webpaste-provider
@ -325,7 +327,7 @@ Optional params:
:post-field "content" :post-field "content"
:post-lang-field-name "lexer" :post-lang-field-name "lexer"
:lang-overrides '((emacs-lisp-mode . "clojure")) :lang-overrides '((emacs-lisp-mode . "clojure"))
:success-lambda 'webpaste/providers-success-returned-string)) :success-lambda 'webpaste-providers-success-returned-string))
("gist.github.com" ("gist.github.com"
,(webpaste-provider ,(webpaste-provider
@ -350,7 +352,7 @@ Optional params:
:post-field "code" :post-field "code"
:post-lang-field-name "language" :post-lang-field-name "language"
:lang-overrides '((emacs-lisp-mode . "clojure")) :lang-overrides '((emacs-lisp-mode . "clojure"))
:success-lambda 'webpaste/providers-success-response-url))) :success-lambda 'webpaste-providers-success-response-url)))
"Define all webpaste.el providers. "Define all webpaste.el providers.
Consists of provider name and lambda function to do the actuall call to the Consists of provider name and lambda function to do the actuall call to the
@ -359,7 +361,7 @@ return it to the user.")
(defun webpaste/get-provider-priority () (defun webpaste-get-provider-priority ()
"Return provider priority." "Return provider priority."
;; Populate webpaste-provider-priority if needed ;; Populate webpaste-provider-priority if needed
@ -381,11 +383,11 @@ return it to the user.")
"Return RETURNED-URL to user from the result of the paste service." "Return RETURNED-URL to user from the result of the paste service."
;; Loop providers separators ;; Loop providers separators
(dolist (provider-separator webpaste/provider-separators) (dolist (provider-separator webpaste-provider-separators)
;; Match if the separator is for this URI ;; Match if the separator is for this URI
(when (string-match-p (regexp-quote (car provider-separator)) returned-url) (when (string-match-p (regexp-quote (car provider-separator)) returned-url)
;; Get alist of languages for this provider ;; Get alist of languages for this provider
(let ((provider-lang-alist (cdr (assoc (car provider-separator) webpaste/provider-lang-alists)))) (let ((provider-lang-alist (cdr (assoc (car provider-separator) webpaste-provider-lang-alists))))
;; Get language name from list of languages ;; Get language name from list of languages
(let ((language-name (cdr (assoc major-mode provider-lang-alist)))) (let ((language-name (cdr (assoc major-mode provider-lang-alist))))
;; If we get a language name ;; If we get a language name
@ -394,19 +396,19 @@ return it to the user.")
(setq returned-url (concat returned-url (cdr provider-separator) language-name))))))) (setq returned-url (concat returned-url (cdr provider-separator) language-name)))))))
;; Reset tested providers after successful paste ;; Reset tested providers after successful paste
(setq webpaste/tested-providers nil) (setq webpaste-tested-providers nil)
;; If the user want to open the link in an external browser, do so. ;; If the user want to open the link in an external browser, do so.
(when webpaste/open-in-browser (when webpaste-open-in-browser
(browse-url-generic returned-url)) (browse-url-generic returned-url))
;; Send RETURNED-URL to the clipboard using simpleclip ;; Send RETURNED-URL to the clipboard using simpleclip
(when webpaste/copy-to-clipboard (when webpaste-copy-to-clipboard
(simpleclip-set-contents returned-url) (simpleclip-set-contents returned-url)
(message "URL copied to clipboard.")) (message "URL copied to clipboard."))
;; Add RETURNED-URL to killring for easy pasting ;; Add RETURNED-URL to killring for easy pasting
(when webpaste/add-to-killring (when webpaste-add-to-killring
(kill-new returned-url) (kill-new returned-url)
(message "Added %S to kill ring." returned-url))) (message "Added %S to kill ring." returned-url)))
@ -426,25 +428,25 @@ make `webpaste-paste-text' do less magic things all at once."
If webpaste-provider-priority isn't populated, it will populate it with the If webpaste-provider-priority isn't populated, it will populate it with the
default providers. default providers.
Then if webpaste/tested-providers isn't populated it will be populated by Then if webpaste-tested-providers isn't populated it will be populated by
webpaste-provider-priority. webpaste-provider-priority.
Then it extracts the first element of webpaste/tested-providers and drops Then it extracts the first element of webpaste-tested-providers and drops
the first element from that list and gets the lambda for the provider and the first element from that list and gets the lambda for the provider and
runs the lambda to paste TEXT to the paste service. The paste-service in turn runs the lambda to paste TEXT to the paste service. The paste-service in turn
might call this function again with TEXT as param to retry if it failed. might call this function again with TEXT as param to retry if it failed.
When we run out of providers to try, it will restart since When we run out of providers to try, it will restart since
webpaste/tested-providers will be empty and then populated again." webpaste-tested-providers will be empty and then populated again."
;; Populate tested providers for this request if needed ;; Populate tested providers for this request if needed
(unless webpaste/tested-providers (unless webpaste-tested-providers
(setq webpaste/tested-providers (webpaste/get-provider-priority))) (setq webpaste-tested-providers (webpaste-get-provider-priority)))
;; Get name of provider at the top of the list ;; Get name of provider at the top of the list
(let ((provider-name (car webpaste/tested-providers))) (let ((provider-name (car webpaste-tested-providers)))
;; Drop the name at the top of the list ;; Drop the name at the top of the list
(setq webpaste/tested-providers (cdr webpaste/tested-providers)) (setq webpaste-tested-providers (cdr webpaste-tested-providers))
;; Run pasting function ;; Run pasting function
(webpaste-paste-text-to-provider text provider-name))) (webpaste-paste-text-to-provider text provider-name)))
@ -458,7 +460,7 @@ Argument MARK Current mark."
(interactive "r") (interactive "r")
;; unless we wanted a paste confirmation and declined ;; unless we wanted a paste confirmation and declined
(unless (and webpaste/paste-confirmation (unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire region?"))) (not (yes-or-no-p "paste entire region?")))
;; Extract the buffer contents with buffer-substring and paste it ;; Extract the buffer contents with buffer-substring and paste it
(webpaste-paste-text (buffer-substring point mark)))) (webpaste-paste-text (buffer-substring point mark))))
@ -470,7 +472,7 @@ Argument MARK Current mark."
(interactive) (interactive)
;; unless we wanted a paste confirmation and declined ;; unless we wanted a paste confirmation and declined
(unless (and webpaste/paste-confirmation (unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire buffer?"))) (not (yes-or-no-p "paste entire buffer?")))
;; Extract the buffer contents with buffer-substring and paste it ;; Extract the buffer contents with buffer-substring and paste it
(webpaste-paste-text (buffer-substring (point-min) (point-max))))) (webpaste-paste-text (buffer-substring (point-min) (point-max)))))

Loading…
Cancel
Save