[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste e892ef2 277/298: webpaste: Add custom to limit am
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste e892ef2 277/298: webpaste: Add custom to limit amount of retries |
Date: |
Thu, 9 Dec 2021 19:00:29 -0500 (EST) |
branch: elpa/webpaste
commit e892ef243fb7bcf786d0994a59465868a6fb392e
Author: Elis Hirwing <elis@hirwing.se>
Commit: Elis Hirwing <elis@hirwing.se>
webpaste: Add custom to limit amount of retries
---
webpaste.el | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/webpaste.el b/webpaste.el
index 83649f9..42a9595 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -86,6 +86,12 @@ This uses `browse-url-generic' to open URLs."
:type 'hook)
+(defcustom webpaste-max-retries 10
+ "Max retries before we give up on pasting, say if network is down or so."
+ :group 'webpaste
+ :type 'number)
+
+
(defcustom webpaste-providers-alist
'(("ix.io"
:uri "http://ix.io/"
@@ -191,6 +197,12 @@ This list will be populated when you add providers to have
the languages
precalculated, and also available both for pre and post request access.")
+(defvar webpaste--current-retries 0
+ "Variable for storing the current amount of retries.
+This shouldn't go biffer than `webpaste-max-retries' to avoid infinite
+loops. This variable is reset on each new paste.")
+
+
(defvar webpaste--default-lang-alist
'((c-mode . "c")
(c++-mode . "cpp")
@@ -513,6 +525,12 @@ When we run out of providers to try, it will restart since
(unless webpaste--tested-providers
(setq webpaste--tested-providers (webpaste--get-provider-priority)))
+ ;; If we have too many retries, empty the provider list.
+ (if (>= webpaste--current-retries webpaste-max-retries)
+ (setq webpaste--tested-providers nil)
+ ;; Otherwise increment the retry counter.
+ (setq webpaste--current-retries (+ 1 webpaste--current-retries)))
+
;; Get name of provider at the top of the list
(let ((provider-name (car webpaste--tested-providers)))
;; Drop the name at the top of the list
@@ -530,6 +548,9 @@ Argument POINT Current point.
Argument MARK Current mark."
(interactive "r")
+ ;; Set retry counter to zero before we start.
+ (setq webpaste--current-retries 0)
+
;; unless we wanted a paste confirmation and declined
(unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire region?")))
@@ -542,6 +563,9 @@ Argument MARK Current mark."
"Paste current buffer to some paste service."
(interactive)
+ ;; Set retry counter to zero before we start.
+ (setq webpaste--current-retries 0)
+
;; unless we wanted a paste confirmation and declined
(unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire buffer?")))
- [nongnu] elpa/webpaste d7047a9 222/298: Update copyright year, (continued)
- [nongnu] elpa/webpaste d7047a9 222/298: Update copyright year, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste dc99105 260/298: Merge branch 'switch-to-nix-emacs-ci', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 3a1eaca 183/298: Added integration tests for gist.github.com, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8ef26cf 198/298: Switched function and variable names that are supposed to be internal, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste cfd41c7 207/298: Add Emacs-24.3 again as well as Emacs-25.3 as new version is out, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ba05903 248/298: travis: Run the integration tests in emacs 26.1, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 9ca4105 267/298: Extend default language list, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 44df573 244/298: Merge branch 'kaushalmodi-add-lang-detection-from-shebang', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 0f79722 270/298: Add wrapper around webpaste for buffer and region, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 20da215 271/298: Add unit tests for pasting buffer OR region depending on context, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e892ef2 277/298: webpaste: Add custom to limit amount of retries,
ELPA Syncer <=
- [nongnu] elpa/webpaste bd2bf6a 281/298: github-actions: Set up github actions and undercover for unit tests, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 54e2ed4 178/298: Added integration test for ix.io, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 26a8035 197/298: Switched to simpler provider definitions where we don't store lambdas in the alist, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e2ba2f5 282/298: github-actions: Set up github actions for integration tests, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 67a1a8c 295/298: Copyright header shouldn't be a range of years, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b063ddd 292/298: README: Update number of providers, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 0c814bc 179/298: Added integration test for sprunge.us, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste bb7a705 184/298: Added unit test for simpleclip feature, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste bd1ec2a 187/298: Disabled one test since it doesn't work, but really should..., ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste de5cbd2 190/298: Update contributor guidelines to match codestyle, ELPA Syncer, 2021/12/09