summaryrefslogtreecommitdiff
path: root/fussy.lisp
blob: 9173e0a722fe780b699aec5c0f9850982ad45768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;;; fussy.lisp

(in-package #:fussy)

(defvar +default-emacs-package-archive+
  "https://melpa.org/packages/archive-contents")

(defun emacs-reader-readtable ()
  (let ((*readtable* (copy-readtable nil)))
    (labels ((bracket-reader (stream char)
               (declare (ignorable char))
               (read-delimited-list #\] stream)))
      (set-macro-character #\[ #'bracket-reader)
      (set-macro-character #\] (get-macro-character #\) nil))
      *readtable*)))


(defun fetch-emacs-archive (&optional (archive +default-emacs-package-archive+))
  (multiple-value-bind (stream status) (dexador:get archive :want-stream t)
    (when (= 200 status)
      (let ((*readtable* (emacs-reader-readtable)))
        (read stream)))))

(defun package-name-mentions (str)
  (lambda (package)
    (when (consp package)
      (let ((string-name
              (symbol-name (first package))))
        (search str string-name :test #'char-equal)))))

(defun find-themes (archive-contents)
  (remove-if-not (package-name-mentions "-theme") archive-contents))