Add deprecation message of simpleclip option to clean up the code

master
Elis Hirwing 8 years ago
parent 9972cf4634
commit 14fd97bc3c
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 6
      README.org
  2. 23
      tests/unit/test-webpaste-return-url.el
  3. 7
      webpaste.el

@ -102,6 +102,9 @@ clipboard. You can enable this with
(setq webpaste-copy-to-clipboard t)
#+END_SRC
Warning: This option is deprecated and will be dropped in the future. Please
use a custom hook instead.
*** Open the recently created paste in the browser
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
@ -132,6 +135,9 @@ can have several hooks as well if you want it to do several custom things.
(lambda (url)
(message "Opened URL in browser: %S" url)
(browse-url-generic url)))
;; Simple hook to replicate the `webpaste-copy-to-clipboard' option
(add-hook 'webpaste-return-url-hook 'simpleclip-set-contents)
#+end_src
** Custom providers

@ -13,8 +13,7 @@
(setq webpaste-return-url-hook nil)
(spy-on 'message)
(spy-on 'kill-new)
(spy-on 'browse-url-generic)
(spy-on 'simpleclip-set-contents))
(spy-on 'browse-url-generic))
(it
"can put in kill-ring and message the user"
@ -57,35 +56,15 @@
:to-have-been-called-with
"https://example.com/?lang=lisp")))
(it
"can put contents in clipboard using simpleclip"
(let ((webpaste-copy-to-clipboard t)
(webpaste-add-to-killring nil))
(webpaste--return-url "https://example.com/")
(expect 'simpleclip-set-contents
:to-have-been-called-with
"https://example.com/")
(expect 'message
:to-have-been-called-with
"URL copied to clipboard.")))
(it
"can run user defined hooks"
(add-hook 'webpaste-return-url-hook 'message)
(add-hook 'webpaste-return-url-hook 'browse-url-generic)
(add-hook 'webpaste-return-url-hook 'simpleclip-set-contents)
(let ((webpaste-copy-to-clipboard nil)
(webpaste-add-to-killring nil)
(webpaste-open-in-browser nil))
(webpaste--return-url "https://example.com/")
(expect 'simpleclip-set-contents
:to-have-been-called-with
"https://example.com/")
(expect 'message
:to-have-been-called-with
"https://example.com/")

@ -70,7 +70,10 @@ This uses `browse-url-generic' to open URLs."
(defcustom webpaste-copy-to-clipboard nil
"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.
Warning: This option is deprecated and will be dropped in the future. Please
use a hook with `webpaste-return-url-hook' in the future."
:group 'webpaste
:type 'boolean)
@ -431,7 +434,7 @@ Optional params:
;; Send RETURNED-URL to the clipboard using simpleclip
(when webpaste-copy-to-clipboard
(simpleclip-set-contents returned-url)
(message "URL copied to clipboard."))
(message "URL copied to clipboard. -- Warning: This option is deprecated, please use a hook instead."))
;; Add RETURNED-URL to killring for easy pasting
(when webpaste-add-to-killring

Loading…
Cancel
Save