From 9ddc6170ae04e752dc7dfce298617262e3fa28a3 Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Thu, 4 May 2017 07:39:05 +0200 Subject: [PATCH] Simplify webpaste/get-lang-alist-with-overrides implementation Just append stuff, it doesn't matter anyways since you always read from the beginning anyways and overrides, removal and addition works the same like this anyways. --- webpaste.el | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/webpaste.el b/webpaste.el index 0a72d88..ee88d44 100644 --- a/webpaste.el +++ b/webpaste.el @@ -287,21 +287,13 @@ return it to the user." (defun webpaste/get-lang-alist-with-overrides (overrides) "Fetches lang-alist with OVERRIDES applied." + ;; Copy original list to temporary list (let ((lang-alist webpaste/default-lang-alist)) - ;; Go through list of overrides + ;; Go through list of overrides and append them to the temporary list (dolist (override-element overrides) - ;; Set key and value from override list - (let ((key (car override-element)) - (value (cdr override-element))) - - ;; If the element doesn't exist, add it - (unless (assoc (car override-element) lang-alist) - (cl-pushnew (cons key value) lang-alist)) - - ;; If the element in the list is changed - (unless (equal (cdr (assoc key lang-alist)) value) - (cl-pushnew (cons key value) lang-alist)))) + (cl-pushnew override-element lang-alist)) + ;; Return temporary list lang-alist))