Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Emacs lock files from visualising #23

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ clerk.iml
public/girouette.css
public/images/
yarn.lock
*~
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:dev {:extra-deps {arrowic/arrowic {:mvn/version "0.1.1"}
binaryage/devtools {:mvn/version "1.0.3"}
cider/cider-nrepl {:mvn/version "0.26.0"}
thheller/shadow-cljs {:mvn/version "2.15.9"}}
thheller/shadow-cljs {:mvn/version "2.16.7"}}
:extra-paths ["dev"]
:jvm-opts ["-Dclerk.live_js=true" "-XX:-OmitStackTraceInFastThrow"]
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"shadow-cljs": "^2.15.13",
"shadow-cljs": "^2.16.7",
"tailwindcss": "2.2.12"
}
}
19 changes: 16 additions & 3 deletions src/nextjournal/clerk.clj
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,24 @@
(webserver/show-error! e)
(throw e))))

(defn supported-file?
"Returns whether `path` points to a file that should be shown."
[path]
;; file names starting with .# are most likely Emacs lock files and should be ignored.
(->> path io/file .getName
(re-matches #"(?!^\.#).+\.(md|clj|cljc)$")
some?))

#_(supported-file? "foo_bar.clj")
#_(supported-file? "xyz/foo.md")
#_(supported-file? "xyz/foo.clj")
#_(supported-file? "xyz/abc.#name.cljc")
#_(supported-file? ".#name.clj")
#_(supported-file? "xyz/.#name.cljc")

(defn file-event [{:keys [type path]}]
(when (and (contains? #{:modify :create} type)
(or (str/ends-with? path ".md")
(str/ends-with? path ".clj")
(str/ends-with? path ".cljc")))
(supported-file? path))
(binding [*ns* (find-ns 'user)]
(let [rel-path (str/replace (str path) (str (fs/canonicalize ".") fs/file-separator) "")
show-file? (or (not @!show-filter-fn)
Expand Down