aboutsummaryrefslogtreecommitdiff
path: root/src/lib.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.lisp')
-rw-r--r--src/lib.lisp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib.lisp b/src/lib.lisp
index b5256fe..ec44bca 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -76,19 +76,18 @@
(uiop:delete-file-if-exists (cached-oneliners-file)))
(defun merge-into-cache (new-ols)
- (if (uiop:file-exists-p (cached-oneliners-file))
- (let ((cached-ols (with-open-file (input (cached-oneliners-file)) (read input))))
- (with-open-file (out (cached-oneliners-file) :direction :output :if-exists :supersede)
- (print
- (nconc
- new-ols
- (remove-if
- (lambda (old)
- (find (getf old :id) new-ols :key (lambda (x) (getf x :id))))
- cached-ols))
- out)))
- (with-open-file (out (cached-oneliners-file) :direction :output)
- (print new-ols out))))
+ (let* ((cached
+ (when (uiop:file-exists-p (cached-oneliners-file))
+ (with-open-file (input (cached-oneliners-file)) (read input))))
+ (updated
+ (append
+ new-ols
+ (loop for old in cached
+ for id = (getf old :id)
+ unless (find id new-ols :key (lambda (x) (getf x :id)))
+ collect old))))
+ (with-open-file (output (cached-oneliners-file) :direction :output :if-exists :supersede)
+ (print updated output))))
;;; UTILITIES
(defun make-temp-file-name ()
@@ -115,7 +114,9 @@ the directories that appear in the value of that variable."
(make-pathname :name name :directory directory))))
(defun tags-from-oneliner (oneliner)
- (remove-if-not #'executable-on-system-p (ppcre:split " +" oneliner)))
+ (remove-duplicates
+ (remove-if-not #'executable-on-system-p (ppcre:split " +" oneliner))
+ :test #'equal))
(defun prompt (prompt
&key