Added supports for custom hooks when returning URLs. This fixes #22.

master
Elis Axelsson 9 years ago
parent 77e6154ece
commit 2a05d0274c
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 16
      README.org
  2. 14
      webpaste.el

@ -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

@ -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)

Loading…
Cancel
Save