summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2024-03-09 14:42:50 -0500
committerJohn Turner <jturner.usa@gmail.com>2024-03-09 14:56:52 -0500
commit3fefebf0682c711d2ac2031f3191ef626bae7be7 (patch)
tree7da51d292f69f09a234614996cb4a52a9fd94ce6
parent6ca351607c63dcc54b7f02c25823c9fe4a457247 (diff)
downloadwgetpaste.el-3fefebf0682c711d2ac2031f3191ef626bae7be7.tar.gz
make wgetpaste-sentinel defcustom variable
-rw-r--r--wgetpaste.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/wgetpaste.el b/wgetpaste.el
index f08b96f..5db808d 100644
--- a/wgetpaste.el
+++ b/wgetpaste.el
@@ -44,6 +44,13 @@
(defcustom wgetpaste-upload-failure-hook nil
"Hooks to run after wgetpaste process exits unsuccessfully")
+(defcustom wgetpaste-sentinel (lambda (process _)
+ (unless (process-live-p process)
+ (run-hooks (if (zerop (process-exit-status process))
+ 'wgetpaste-after-upload-hook
+ 'wgetpaste-upload-failure-hook))))
+ "Sentinel function to install to wgetpaste process")
+
(defun wgetpaste-buffer ()
(run-hooks 'wgetpaste-before-upload-hook)
(let ((process (make-process
@@ -52,10 +59,7 @@
:connection-type 'pipe
:buffer (get-buffer-create wgetpaste-stdout-buffer)
:stderr (get-buffer-create wgetpaste-stderr-buffer)
- :sentinel (lambda (process event)
- (unless (process-live-p process)
- (when (zerop (process-exit-status process))
- (run-hooks 'wgetpaste-after-upload-hook)))))))
+ :sentinel wgetpaste-sentinel)))
(process-send-region process (point-min) (point-max))
(process-send-eof process)
process))