Switched function and variable names that are supposed to be internal

Squashed commit of the following:

commit a870501c91bf4f96f863400b577e3c96ff1ecd60
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 11:16:07 2017 +0200

    Rename webpaste-provider function to be in the "private scope" by name

commit 9dc6c8e2ce7edf88cf63c2795bfdd903d72473ba
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 11:12:22 2017 +0200

    Rename webpaste-get-provider-priority to be in the "private scope" by name

commit 7e786fdb3069c2c79040179684821136906729f7
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 11:10:00 2017 +0200

    Rename webpaste-return-url function to be in the "private scope" by name

commit 0dd576487b1edfe7d9522e499bedc26d4ee31b12
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 11:02:00 2017 +0200

    Rename webpaste-default-lang-alist and webpaste-get-lang-alist-with-overrides to be in "private scope" by name

commit bf4ac93a04fb7c79a20f32a69fed6cd7df84ef5c
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 11:00:05 2017 +0200

    Rename webpaste-provider-lang-alists to be in "private scope" by name

commit feec4b26750573d1e12b982772d3aa978a5fa678
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 10:55:35 2017 +0200

    Rename webpaste-provider-separators to be in "private scope" by name

commit 7b6a0207c1921bb8f53cf18a8ab644790fa2feb9
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 10:51:15 2017 +0200

    Rename tested-providers variable to be in "private scope" by name

commit e2926ffbb9feeaf1a56f54477583b52a97167e88
Author: Elis Axelsson <elis.axelsson@gmail.com>
Date:   Sun Jun 11 10:44:51 2017 +0200

    Switch all defun's to cl-defuns for consistency, rearrange some page breaks
master
Elis Axelsson 9 years ago
parent 26a8035f5e
commit 8ef26cf872
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 20
      tests/integration/test-webpaste-providers.el
  2. 2
      tests/unit/test-webpaste-default-post-field-lambda.el
  3. 4
      tests/unit/test-webpaste-get-provider-priority.el
  4. 2
      tests/unit/test-webpaste-paste-text.el
  5. 6
      tests/unit/test-webpaste-provider-creation.el
  6. 14
      tests/unit/test-webpaste-return-url.el
  7. 8
      tests/unit/test-webpaste-success-lambdas.el
  8. 82
      webpaste.el

@ -12,7 +12,7 @@
(before-each (before-each
;; Block requests ;; Block requests
(spy-on 'webpaste-paste-text) (spy-on 'webpaste-paste-text)
(spy-on 'webpaste-return-url)) (spy-on 'webpaste--return-url))
(it (it
"can paste with ptpb.pw" "can paste with ptpb.pw"
@ -23,10 +23,10 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)
(expect (spy-calls-most-recent 'webpaste-return-url) (expect (spy-calls-most-recent 'webpaste--return-url)
:to-equal :to-equal
(make-spy-context :current-buffer (current-buffer) (make-spy-context :current-buffer (current-buffer)
:args '("https://ptpb.pw/gLC6") :args '("https://ptpb.pw/gLC6")
@ -42,10 +42,10 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)
(expect (spy-calls-most-recent 'webpaste-return-url) (expect (spy-calls-most-recent 'webpaste--return-url)
:to-equal :to-equal
(make-spy-context :current-buffer (current-buffer) (make-spy-context :current-buffer (current-buffer)
:args '("http://ix.io/whJ") :args '("http://ix.io/whJ")
@ -61,7 +61,7 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
@ -74,7 +74,7 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
@ -87,7 +87,7 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
@ -103,7 +103,7 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
@ -116,7 +116,7 @@
";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el" ";; This is a build artifact made from an integration test for https://github.com/etu/webpaste.el"
:sync t) :sync t)
(expect (spy-calls-count 'webpaste-return-url) :to-equal 1) (expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))) (expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))))

@ -12,7 +12,7 @@
(let ((post-lambda (webpaste-providers-default-post-field-lambda)) (let ((post-lambda (webpaste-providers-default-post-field-lambda))
(major-mode 'fundamental-mode) (major-mode 'fundamental-mode)
(webpaste-provider-lang-alists '(("https://example.com/" . ((fundamental-mode . "text")))))) (webpaste--provider-lang-alists '(("https://example.com/" . ((fundamental-mode . "text"))))))
(let ((post-data (funcall post-lambda (let ((post-data (funcall post-lambda
:text "my text" :text "my text"
:post-field "content" :post-field "content"

@ -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,7 +12,7 @@
(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"))

@ -12,7 +12,7 @@
(before-each (before-each
(setq broken-provider (setq broken-provider
(webpaste-provider (webpaste--provider
:uri "http://invalid-domain-name/" :uri "http://invalid-domain-name/"
:post-field "data" :post-field "data"
:success-lambda (lambda () (cl-function :success-lambda (lambda () (cl-function
@ -23,7 +23,7 @@
(setq used-lambda "error")))))) (setq used-lambda "error"))))))
(setq working-provider (setq working-provider
(webpaste-provider (webpaste--provider
:uri "https://httpbin.org/status/200" :uri "https://httpbin.org/status/200"
:post-field "data" :post-field "data"
:success-lambda (lambda () (cl-function :success-lambda (lambda () (cl-function
@ -57,7 +57,7 @@
(spy-on 'error) (spy-on 'error)
(let ((used-lambda nil) (let ((used-lambda nil)
(provider (webpaste-provider (provider (webpaste--provider
:uri "http://invalid-domain-name/" :uri "http://invalid-domain-name/"
:post-field "data" :post-field "data"
:success-lambda (cl-function :success-lambda (cl-function

@ -19,7 +19,7 @@
(it (it
"can put in kill-ring and message the user" "can put in kill-ring and message the user"
(webpaste-return-url "https://example.com/") (webpaste--return-url "https://example.com/")
(expect 'browse-url-generic :not :to-have-been-called) (expect 'browse-url-generic :not :to-have-been-called)
@ -35,7 +35,7 @@
"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
:to-have-been-called-with :to-have-been-called-with
@ -44,14 +44,14 @@
(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)
(webpaste-return-url "https://example.com/") (webpaste--return-url "https://example.com/")
(expect 'kill-new (expect 'kill-new
:to-have-been-called-with :to-have-been-called-with
@ -62,7 +62,7 @@
(let ((webpaste-copy-to-clipboard t) (let ((webpaste-copy-to-clipboard t)
(webpaste-add-to-killring nil)) (webpaste-add-to-killring nil))
(webpaste-return-url "https://example.com/") (webpaste--return-url "https://example.com/")
(expect 'simpleclip-set-contents (expect 'simpleclip-set-contents
:to-have-been-called-with :to-have-been-called-with
@ -80,7 +80,7 @@
(let ((webpaste-copy-to-clipboard nil) (let ((webpaste-copy-to-clipboard nil)
(webpaste-add-to-killring nil) (webpaste-add-to-killring nil)
(webpaste-open-in-browser nil)) (webpaste-open-in-browser nil))
(webpaste-return-url "https://example.com/") (webpaste--return-url "https://example.com/")
(expect 'simpleclip-set-contents (expect 'simpleclip-set-contents
:to-have-been-called-with :to-have-been-called-with

@ -12,7 +12,7 @@
(before-each (before-each
(spy-on 'request-response-header :and-return-value "https://example.com/") (spy-on 'request-response-header :and-return-value "https://example.com/")
(spy-on 'request-response-url :and-return-value "https://example.com/") (spy-on 'request-response-url :and-return-value "https://example.com/")
(spy-on 'webpaste-return-url)) (spy-on 'webpaste--return-url))
(it (it
"using a response header" "using a response header"
@ -20,7 +20,7 @@
(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
:to-have-been-called-with :to-have-been-called-with
"https://example.com/"))) "https://example.com/")))
@ -30,7 +30,7 @@
(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
:to-have-been-called-with :to-have-been-called-with
"https://example.com/"))) "https://example.com/")))
@ -42,7 +42,7 @@
(funcall success-lambda :data "\"https://example.com/\" (funcall success-lambda :data "\"https://example.com/\"
") ")
(expect 'webpaste-return-url (expect 'webpaste--return-url
:to-have-been-called-with :to-have-been-called-with
"https://example.com/")))) "https://example.com/"))))

@ -49,7 +49,7 @@ provider priority for which order which provider should be tried when used."
(defcustom webpaste-provider-priority () (defcustom webpaste-provider-priority ()
"Define provider priority of which providers to try in which order. "Define provider priority of which providers to try in which order.
This variable should be a list of strings and if it isn't defined it will This variable should be a list of strings and if it isn't defined it will
default to all providers in order defined in webpaste-providers list." default to all providers in order defined in webpaste--provider list."
:group 'webpaste :group 'webpaste
:type '(repeat string)) :type '(repeat string))
@ -138,7 +138,7 @@ This uses `simpleclip-set-contents' to copy to clipboard."
(("content" . ,text))))))))))) (("content" . ,text)))))))))))
:success-lambda (lambda () (cl-function (lambda (&key data &allow-other-keys) :success-lambda (lambda () (cl-function (lambda (&key data &allow-other-keys)
(when data (when data
(webpaste-return-url (webpaste--return-url
(cdr (assoc 'html_url (json-read-from-string data))))))))) (cdr (assoc 'html_url (json-read-from-string data)))))))))
("paste.pound-python.org" ("paste.pound-python.org"
@ -150,34 +150,34 @@ This uses `simpleclip-set-contents' to copy to clipboard."
: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 arguments to be sent to `webpaste-provider' when Consists of provider name and arguments to be sent to `webpaste--provider' when
the provider is created. So to create a custom provider you should read up on the provider is created. So to create a custom provider you should read up on
the docs for `webpaste-provider'." the docs for `webpaste--provider'."
:group 'webpaste :group 'webpaste
:type 'alist) :type 'alist)
(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--provider
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")
@ -189,6 +189,7 @@ precalculated, and also available both for pre and post request access.")
(yaml-mode . "yaml")) (yaml-mode . "yaml"))
"Alist that maps `major-mode' names to language names.") "Alist that maps `major-mode' names to language names.")
;;; 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)
@ -209,7 +210,7 @@ precalculated, and also available both for pre and post request access.")
"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
(webpaste-return-url (webpaste--return-url
(request-response-header response "Location")))))) (request-response-header response "Location"))))))
@ -217,7 +218,7 @@ precalculated, and also available both for pre and post request access.")
"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
(webpaste-return-url (webpaste--return-url
(request-response-url response)))))) (request-response-url response))))))
@ -228,7 +229,7 @@ precalculated, and also available both for pre and post request access.")
(setq data (replace-regexp-in-string "\n$" "" data)) (setq data (replace-regexp-in-string "\n$" "" data))
(setq data (replace-regexp-in-string "\"" "" data)) (setq data (replace-regexp-in-string "\"" "" data))
(webpaste-return-url data))))) (webpaste--return-url data)))))
(cl-defun webpaste-providers-default-post-field-lambda () (cl-defun webpaste-providers-default-post-field-lambda ()
@ -241,7 +242,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)
@ -251,11 +252,11 @@ precalculated, and also available both for pre and post request access.")
(defun webpaste-get-lang-alist-with-overrides (overrides) (cl-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))
@ -263,9 +264,8 @@ precalculated, and also available both for pre and post request access.")
;; Return temporary list ;; Return temporary list
lang-alist)) lang-alist))
(cl-defun webpaste-provider (&key uri (cl-defun webpaste--provider (&key uri
post-field post-field
success-lambda success-lambda
(type "POST") (type "POST")
@ -279,7 +279,7 @@ precalculated, and also available both for pre and post request access.")
"Function to create the lambda function for a provider. "Function to create the lambda function for a provider.
Usage: Usage:
(webpaste-provider (webpaste--provider
[:keyword [option]]...) [:keyword [option]]...)
Required params: Required params:
@ -323,7 +323,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.
@ -331,11 +331,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
@ -358,17 +358,15 @@ Optional params:
:sync sync :sync sync
:error (funcall error-lambda :text text)))))) :error (funcall error-lambda :text text))))))
(cl-defun webpaste--get-provider-by-name (provider-name) (cl-defun webpaste--get-provider-by-name (provider-name)
"Get provider by PROVIDER-NAME." "Get provider by PROVIDER-NAME."
(apply 'webpaste-provider (apply 'webpaste--provider
(cdr (assoc provider-name webpaste-providers-alist)))) (cdr (assoc provider-name webpaste-providers-alist))))
(defun webpaste-get-provider-priority () (cl-defun webpaste--get-provider-priority ()
"Return provider priority." "Return provider priority."
;; Populate webpaste-provider-priority if needed ;; Populate webpaste-provider-priority if needed
@ -383,18 +381,16 @@ Optional params:
webpaste-provider-priority) webpaste-provider-priority)
;;;###autoload (cl-defun webpaste--return-url (returned-url)
(defun webpaste-return-url (returned-url)
"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
@ -403,7 +399,7 @@ Optional params:
(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
@ -429,7 +425,7 @@ Optional params:
;;;###autoload ;;;###autoload
(defun webpaste-paste-text-to-provider (text provider-name) (cl-defun webpaste-paste-text-to-provider (text provider-name)
"Paste TEXT to specific PROVIDER-NAME. "Paste TEXT to specific PROVIDER-NAME.
This function sends a paste to a spacific provider. This function is created to This function sends a paste to a spacific provider. This function is created to
make `webpaste-paste-text' do less magic things all at once." make `webpaste-paste-text' do less magic things all at once."
@ -437,37 +433,37 @@ make `webpaste-paste-text' do less magic things all at once."
;;;###autoload ;;;###autoload
(defun webpaste-paste-text (text) (cl-defun webpaste-paste-text (text)
"Paste TEXT to some paste service. "Paste TEXT to some paste service.
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)))
;;;###autoload ;;;###autoload
(defun webpaste-paste-region (point mark) (cl-defun webpaste-paste-region (point mark)
"Paste selected region to some paste service. "Paste selected region to some paste service.
Argument POINT Current point. Argument POINT Current point.
Argument MARK Current mark." Argument MARK Current mark."
@ -481,7 +477,7 @@ Argument MARK Current mark."
;;;###autoload ;;;###autoload
(defun webpaste-paste-buffer () (cl-defun webpaste-paste-buffer ()
"Paste current buffer to some paste service." "Paste current buffer to some paste service."
(interactive) (interactive)

Loading…
Cancel
Save