Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BostX committed Jun 4, 2022
1 parent 8c0b7f9 commit a41017b
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

(define case-sensitive "i")
(define case-insensitive "-i")
;; passed directly to the regex as a flag for case-sensitivity flag
(define case-sensitivity (make-parameter case-sensitive))
(define case-sensitivity-help-text
(format "case-sensitive `~a`~a or case-insensitive `~a`~a search."
Expand Down Expand Up @@ -125,8 +126,8 @@ directory to search in."
(let ((txt (car ls)))
(display-fn txt)
(if cm
(with-colors 'red (lambda () (display-fn pattern)))
(display-fn pattern))
(with-colors 'red (lambda () (color-display pattern)))
(display pattern))
(colorize cm display-fn (cdr ls) pattern))]))

((compose
Expand All @@ -136,8 +137,6 @@ directory to search in."
(let ((strs (cdr file-strs)))
(unless (empty? strs)
(let* ((cm (colorize-matches))
(fn-displayln (if cm color-displayln displayln))
(fn-display (if cm color-display display))
(s (string-join strs "\n"))
(ptrn (pattern))
;; TODO use regexp-match* instead of regexp-split.
Expand All @@ -148,9 +147,9 @@ directory to search in."
s)))
(if cm
(with-colors 'white (lambda ()
(fn-displayln (car file-strs))))
(fn-displayln (car file-strs)))
(colorize cm fn-display lst ptrn)
(color-displayln (car file-strs))))
(displayln (car file-strs)))
(colorize cm (if cm color-display display) lst ptrn)
(printf "\n\n")))
strs)))
(curry map
Expand All @@ -159,19 +158,17 @@ directory to search in."
(lambda (inf)
(define exp
`(notes
,@(cons
(pattern)
(cons
(case-sensitivity)
(cons
(colorize-matches)
(parse-notes add-src-location-info inf))))))
,@((compose
(curry cons (pattern))
(curry cons (case-sensitivity))
(curry cons (colorize-matches)))
(parse-notes add-src-location-info inf))))
(eval exp ns)))))
(if (empty? strs)
(list f)
(list f (string-join strs "\n\n"))))))
(lambda (filter-fun)
"Return a list to files to search through."
"Return a list of files to search through."
(let ([all-files (for/list ([f (in-directory dir)])
(path->string f))])
(filter filter-fun all-files)))
Expand Down

0 comments on commit a41017b

Please sign in to comment.