This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-10
Channels
- # aws (39)
- # babashka (4)
- # beginners (5)
- # biff (25)
- # cider (14)
- # clj-on-windows (40)
- # clojure-europe (36)
- # clojure-gamedev (1)
- # clojure-losangeles (4)
- # clojure-norway (51)
- # clojure-spec (5)
- # clojure-uk (2)
- # clojurescript (2)
- # clr (176)
- # data-science (10)
- # datalevin (17)
- # datomic (7)
- # deps-new (4)
- # docs (3)
- # emacs (12)
- # figwheel (3)
- # figwheel-main (5)
- # hyperfiddle (20)
- # instaparse (3)
- # introduce-yourself (8)
- # lsp (66)
- # malli (43)
- # off-topic (4)
- # rdf (11)
- # reagent (5)
- # releases (2)
- # sci (11)
- # shadow-cljs (24)
- # slack-help (2)
- # specter (7)
- # tools-deps (3)
- # xtdb (48)
Dear emacs friends!
I want to projectile-replace
something in my project which is called defined-by*
but when I try to replace this, projectile also tries to replace defined-by
without a star.
Note that I did not use projectile-replace-regexp
. Should I escape the star or so?
doom uses ripgrep for find and replace which is insanely fast and allows escaping like you want, never used projectile for that though.
Maybe try escaping the star \*
#!/usr/bin/env bb
(require '[babashka.cli :as cli]
'[babashka.fs :as fs]
'[clojure.string :as str])
(let [{:keys [opts args]} (cli/parse-args *command-line-args*)
{:keys [y]} opts
[root match replacement] args
files (fs/glob root "**")]
(doseq [file files
:when (not (fs/directory? file))]
(loop [changed? false
s (slurp (fs/file file))
from-idx 0]
(if-let [idx (str/index-of s match from-idx)]
(do (println "====" (str file))
(println (subs s (max (- idx 10) 0) (min (+ idx (+ (count match) 10)) (count s))))
(when-not y (println "Replace? (Y)"))
(if (or y (= "Y" (read-line)))
(recur true (str/replace-first s match replacement) idx)
(recur changed? s idx)))
(when changed? (spit (fs/file file) s))))))
I tend to use an in-project rg
, +vertico/embark-export-write
and then use a regex or iedit-mode
multiple cursors on all the matches
I use helm-AG, which let's me edit and save the search results, multiple cursors helps too. if there are too many things to replace then command line sd (like sed) is pretty good
Thanks for the suggestions all. My bb script did the job this time, but I'll look into more sophisticated tools next time projectile-replace fails me :)
I like wgrep ... It makes the grep results buffer editable so you can use query-replace, macros, etc and then save the edits into all the buffers you've changed.
Yeah, it's really useful, doom uses something similar, it's the only way to find and replace visually like other editors that I know