[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste 7397cbc 220/298: Fix duplicate elements added to
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste 7397cbc 220/298: Fix duplicate elements added to alists |
Date: |
Thu, 9 Dec 2021 19:00:18 -0500 (EST) |
branch: elpa/webpaste
commit 7397cbcedd89f29b0f182931ae6ced7e462e6c9a
Author: Radon Rosborough <radon.neon@gmail.com>
Commit: Radon Rosborough <radon.neon@gmail.com>
Fix duplicate elements added to alists
Previously, pasting a buffer multiple times could produce a series of
URLs with more and more duplicates of the language specifier appended
to the end. Using a dedicated method for mutating alists instead of
`cl-pushnew', which introduces duplicates, solves this problem.
---
webpaste.el | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/webpaste.el b/webpaste.el
index 6003260..d0e7101 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -159,6 +159,25 @@ the docs for `webpaste--provider'."
+;; modified from https://emacs.stackexchange.com/a/33893/12534
+(defun webpaste--alist-set (key val alist)
+ "Set property KEY to VAL in ALIST. Return new alist.
+This creates the association if it is missing, and otherwise sets
+the cdr of the first matching association in the list. It does
+not create duplicate associations. Key comparison is done with
+`equal'.
+
+This method may mutate the original alist, but you still need to
+use the return value of this method instead of the original
+alist, to ensure correct results."
+ (let ((pair (assoc key alist)))
+ (if pair
+ (setcdr pair val)
+ (push (cons key val) alist)))
+ alist)
+
+
+
(defvar webpaste--tested-providers ()
"Variable for storing which providers to try in which order while running.
This list will be re-populated each run based on ‘webpaste-provider-priority’
or
@@ -332,11 +351,16 @@ Optional params:
;; If we get a separator sent to the function, append it to the list of
;; separators for later use
(when lang-uri-separator
- (cl-pushnew (cons uri lang-uri-separator) webpaste--provider-separators))
+ (setq webpaste--provider-separators
+ (webpaste--alist-set
+ uri lang-uri-separator webpaste--provider-separators)))
;; Add pre-calculated list of webpaste lang alists
- (cl-pushnew (cons uri (webpaste--get-lang-alist-with-overrides
lang-overrides))
- webpaste--provider-lang-alists)
+ (setq webpaste--provider-lang-alists
+ (webpaste--alist-set
+ uri
+ (webpaste--get-lang-alist-with-overrides lang-overrides)
+ webpaste--provider-lang-alists))
(cl-function
(lambda (text
- [nongnu] elpa/webpaste e7fed98 246/298: Reindent entire webpaste.el to match updated indentation style, (continued)
- [nongnu] elpa/webpaste e7fed98 246/298: Reindent entire webpaste.el to match updated indentation style, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 9d3c866 233/298: WP-25: Implement support for raw pastes, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ef33b0f 269/298: Fix provider definition issue and add test for paste.mozilla.org, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b713d5e 259/298: travis: Drop tests for versions where cask seems to be incompatible, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 2decf1e 276/298: Revert "Fix bug in webpaste-paste-buffer-or-region when you don't have a region", ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 1600425 291/298: Merge branch 'dsedivec-master', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste bbdc5e5 296/298: providers: Drop paste.pound-python.org, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 49a7123 236/298: Add missing TOC link about raw pastes, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e0a35fd 232/298: WP-25: Add test for raw pastes, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 5505685 226/298: Drop simpleclip support, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7397cbc 220/298: Fix duplicate elements added to alists,
ELPA Syncer <=
- [nongnu] elpa/webpaste 69a8eed 240/298: Merge branch 'kaushalmodi-add-toml-lang-to-ptpbpw-default', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 01a65a0 262/298: Merge branch 'DamienCassou-typos', ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ed33094 266/298: Support mozilla hosted pastebin service, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste badf3b5 257/298: nix-shell: Improve the shell so all tests just runs, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 933c62f 245/298: CONTRIBUTING: Add some more clarifications, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 01fd1d6 231/298: WP-25: Add custom to only paste raw pastes, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 77e6154 193/298: Bump version for new release, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 157d524 206/298: Fix build since EVM and Cask seems to behave strangely lately, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste a5d0ba1 237/298: Add nix-mode mapping for nix language files for ptpb.pw and ix.io, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 5c742bf 238/298: Remove sprunge.us as provider, ELPA Syncer, 2021/12/09