[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste 2a05d02 194/298: Added supports for custom hooks
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste 2a05d02 194/298: Added supports for custom hooks when returning URLs. This fixes #22. |
Date: |
Thu, 9 Dec 2021 19:00:12 -0500 (EST) |
branch: elpa/webpaste
commit 2a05d0274cbf5bb723ab087566c2dc12fe1a96b7
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>
Added supports for custom hooks when returning URLs. This fixes #22.
---
README.org | 16 ++++++++++++++++
webpaste.el | 14 +++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
index b89e42b..f9960d0 100644
--- a/README.org
+++ b/README.org
@@ -101,6 +101,22 @@ Example:
Can also be put in the =:config= section of =use-package= the same way as the
provider definitions above.
+**** Use a custom hook
+You can define a custom hook to send your URL's to when returning them from
+the paste provider. This is just like regular hooks for major modes etc. You
+can have several hooks as well if you want it to do several custom things.
+
+#+begin_src emacs-lisp
+ ;; Simple hook to just message the URL, this is more or less the default
+ ;; already. But if you disable the default and still want a message, this
+ ;; would work fine.
+ (add-hook 'webpaste-return-url-hook 'message)
+
+ ;; To build your own send-to-browser hook, you could do like this:
+ (add-hook 'webpaste-return-url-hook
+ (lambda (url) (browse-url-generic url)))
+#+end_src
+
** TODO Providers to implement [7/10]
- [X] ptpb.pw
- [X] ix.io
diff --git a/webpaste.el b/webpaste.el
index 6f0f536..ae8fc8e 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -79,6 +79,11 @@ This uses `simpleclip-set-contents' to copy to clipboard."
:group 'webpaste
:type 'boolean)
+(defcustom webpaste-return-url-hook nil
+ "Hook executed with the returned url as parameter."
+ :group 'webpaste
+ :type 'hook)
+
(defvar webpaste-tested-providers ()
@@ -410,7 +415,14 @@ return it to the user.")
;; Add RETURNED-URL to killring for easy pasting
(when webpaste-add-to-killring
(kill-new returned-url)
- (message "Added %S to kill ring." returned-url)))
+ (message "Added %S to kill ring." returned-url))
+
+ ;; Run user defined hooks
+ (dolist (hook webpaste-return-url-hook)
+ (funcall hook returned-url))
+
+ ;; Return URL instead of nil
+ returned-url)
- [nongnu] elpa/webpaste 59fd22f 161/298: Merge branch 'naclander-POST-bug', (continued)
- [nongnu] elpa/webpaste 59fd22f 161/298: Merge branch 'naclander-POST-bug', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste d475f02 170/298: Added integration test for ptpb.pw, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 95de0b8 169/298: Remove sync as a provider parameter on creation and add it on execution, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste fd4332a 172/298: Merge branch 'test-providers-on-travis', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 60c0a98 167/298: Added printing of travis event type, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste d0442ad 168/298: Renamed all unit tests to make it easier for integration tests, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste cac4979 173/298: Added option to send returned URL to clpboard, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste db393a1 175/298: Merge branch 'naclander-copy-to-clipboard', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 92f309e 188/298: Added a contributing guidelines file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ddd2fca 186/298: Added tests for success lambdas, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 2a05d02 194/298: Added supports for custom hooks when returning URLs. This fixes #22.,
ELPA Syncer <=
- [nongnu] elpa/webpaste b96e411 204/298: Moved the paste message to be a variable used for all integration tests, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 26f089e 201/298: Rename webpaste-paste-text and webpaste-paste-text-to-provider to be in "private scope", ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 90a96d2 199/298: Change emacs-lisp-mode from elisp to clojure for sprunge.us, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 4b32baa 203/298: Rename all the lambdas to private scopes, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste cc9ba3d 202/298: Begin autoloading of the webpaste group, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste aed3e00 210/298: Bump version for new release, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b8f300f 209/298: Add pattern for buttercup to not run gists.github.com on travis, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 4bd15f8 227/298: Add a nix-shell file for some development utils, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste f047313 219/298: Update the custom hook example to actually need to be a lambda, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ac24701 214/298: Merge branch 'DamienCassou-simplify-travis', ELPA Syncer, 2021/12/09