Skip to content

Commit 204fe33

Browse files
committed
Mark implementation fns and data private
1 parent ebf2315 commit 204fe33

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

clj/src/vim_clojure_static/generate.clj

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@
1818
;; Helpers
1919
;;
2020

21-
(defn vim-frak-pattern
21+
(defn- vim-frak-pattern
2222
"Create a non-capturing regular expression pattern compatible with Vim."
2323
[strs]
2424
(-> (f/string-pattern strs {:escape-chars :vim})
2525
(string/replace #"\(\?:" "\\%\\(")))
2626

27-
(defn property-pattern
27+
(defn- property-pattern
2828
"Vimscript very magic pattern for a character property class."
2929
([s] (property-pattern s true))
3030
([s braces?]
3131
(if braces?
3232
(format "\\v\\\\[pP]\\{%s\\}" s)
3333
(format "\\v\\\\[pP]%s" s))))
3434

35-
(defn syntax-match-properties
35+
(defn- syntax-match-properties
3636
"Vimscript literal `syntax match` for a character property class."
3737
([group fmt props] (syntax-match-properties group fmt props true))
3838
([group fmt props braces?]
3939
(format "syntax match %s \"%s\" contained display\n"
4040
(name group)
4141
(property-pattern (format fmt (vim-frak-pattern props)) braces?))))
4242

43-
(defn get-private-field
43+
(defn- get-private-field
4444
"Violate encapsulation and get the value of a private field."
4545
[^Class cls fieldname]
4646
(let [^Field field (first (filter #(= fieldname (.getName ^Field %))
4747
(.getDeclaredFields cls)))]
4848
(.setAccessible field true)
4949
(.get field field)))
5050

51-
(defn fn-var? [v]
51+
(defn- fn-var? [v]
5252
(let [f @v]
5353
(or (contains? (meta v) :arglists)
5454
(fn? f)
5555
(instance? MultiFn f))))
5656

57-
(defn inner-class-name [^Class cls]
57+
(defn- inner-class-name [^Class cls]
5858
(string/replace (.getName cls) #".*\$(.+)" "$1"))
5959

60-
(defn map-keyword-names [coll]
60+
(defn- map-keyword-names [coll]
6161
(reduce
6262
(fn [v x]
6363
;; Include fully qualified versions of core vars for matching vars in
@@ -71,7 +71,7 @@
7171
:else (conj v (str x))))
7272
[] coll))
7373

74-
(defn vim-top-cluster
74+
(defn- vim-top-cluster
7575
"Generate a Vimscript literal `syntax cluster` statement for `groups` and
7676
all top-level syntax groups in the given syntax buffer."
7777
[groups syntax-buf]
@@ -275,7 +275,11 @@
275275
"\\c%%(In|blk\\=|block\\=)%s"
276276
(map string/lower-case (:block character-properties))))
277277

278-
(def comprehensive-clojure-character-property-regexps
278+
(def vim-lispwords
279+
"Vimscript literal `setlocal lispwords=` statement."
280+
(str "setlocal lispwords=" (string/join \, (sort lispwords)) "\n"))
281+
282+
(defn- comprehensive-clojure-character-property-regexps []
279283
"A string representing a Clojure literal vector of regular expressions
280284
containing all possible property character classes. For testing Vimscript
281285
syntax matching optimizations."
@@ -290,24 +294,20 @@
290294
(fmt "script=" :script)
291295
(fmt "block=" :block)])))
292296

293-
(def vim-lispwords
294-
"Vimscript literal `setlocal lispwords=` statement."
295-
(str "setlocal lispwords=" (string/join \, (sort lispwords)) "\n"))
296-
297297
;;
298298
;; Update functions
299299
;;
300300

301-
(def CLOJURE-SECTION
301+
(def ^:private CLOJURE-SECTION
302302
#"(?ms)^CLOJURE.*?(?=^[\p{Lu} ]+\t*\*)")
303303

304-
(defn fjoin [& args]
304+
(defn- fjoin [& args]
305305
(string/join \/ args))
306306

307-
(defn qstr [& xs]
307+
(defn- qstr [& xs]
308308
(string/replace (apply str xs) "\\" "\\\\"))
309309

310-
(defn update-doc! [first-line-pattern src-file dst-file]
310+
(defn- update-doc! [first-line-pattern src-file dst-file]
311311
(let [sbuf (->> src-file
312312
io/reader
313313
line-seq
@@ -318,7 +318,7 @@
318318
hunk (re-find CLOJURE-SECTION sbuf)]
319319
(spit dst-file (string/replace-first dbuf dmatch hunk))))
320320

321-
(defn copy-runtime-files! [src dst & opts]
321+
(defn- copy-runtime-files! [src dst & opts]
322322
(let [{:keys [tag date paths]} (apply hash-map opts)]
323323
(doseq [path paths
324324
:let [buf (-> (fjoin src path)
@@ -327,7 +327,7 @@
327327
(string/replace "%%RELEASE_DATE%%" date))]]
328328
(spit (fjoin dst "runtime" path) buf))))
329329

330-
(defn project-replacements [dir]
330+
(defn- project-replacements [dir]
331331
{(fjoin dir "syntax/clojure.vim")
332332
{"-*- KEYWORDS -*-"
333333
(qstr generation-comment
@@ -345,7 +345,7 @@
345345
"-*- TOP CLUSTER -*-"
346346
(qstr generation-comment
347347
(vim-top-cluster (mapv first keyword-groups)
348-
(slurp (fjoin dir "syntax/clojure.vim"))))}
348+
(slurp (fjoin dir "syntax/clojure.vim"))))}
349349

350350
(fjoin dir "ftplugin/clojure.vim")
351351
{"-*- LISPWORDS -*-"
@@ -358,7 +358,7 @@
358358
clojure-version-comment
359359
vim-completion-words)}})
360360

361-
(defn update-project!
361+
(defn- update-project!
362362
"Update project runtime files in the given directory."
363363
[dir]
364364
(doseq [[file replacements] (project-replacements dir)]
@@ -372,7 +372,7 @@
372372
(do (printf "Updating %s\n" magic-comment)
373373
(spit file buf')))))))
374374

375-
(defn update-vim!
375+
(defn- update-vim!
376376
"Update Vim repository runtime files in dst/runtime"
377377
[src dst]
378378
(let [current-tag (string/trim-newline (:out (sh "git" "tag" "--points-at" "HEAD")))
@@ -398,7 +398,7 @@
398398

399399
;; Generate an example file with all possible character property literals.
400400
(spit "tmp/all-char-props.clj"
401-
comprehensive-clojure-character-property-regexps)
401+
(comprehensive-clojure-character-property-regexps))
402402

403403
;; Performance test: `syntax keyword` vs `syntax match`
404404
(vim-clojure-static.test/benchmark

0 commit comments

Comments
 (0)