emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/webpaste 14fd97b 225/298: Add deprecation message of simpl


From: ELPA Syncer
Subject: [nongnu] elpa/webpaste 14fd97b 225/298: Add deprecation message of simpleclip option to clean up the code
Date: Thu, 9 Dec 2021 19:00:18 -0500 (EST)

branch: elpa/webpaste
commit 14fd97bc3c8554d9394b698610dca1186ff68b03
Author: Elis Hirwing <elis@hirwing.se>
Commit: Elis Hirwing <elis@hirwing.se>

    Add deprecation message of simpleclip option to clean up the code
---
 README.org                             |  6 ++++++
 tests/unit/test-webpaste-return-url.el | 23 +----------------------
 webpaste.el                            |  7 +++++--
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/README.org b/README.org
index c816c98..a5e36cc 100644
--- a/README.org
+++ b/README.org
@@ -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
diff --git a/tests/unit/test-webpaste-return-url.el 
b/tests/unit/test-webpaste-return-url.el
index f032e54..14bba42 100644
--- a/tests/unit/test-webpaste-return-url.el
+++ b/tests/unit/test-webpaste-return-url.el
@@ -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"
@@ -58,34 +57,14 @@
             "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/";)
diff --git a/webpaste.el b/webpaste.el
index 6b58f9d..dea11af 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]