Fork me on GitHub
#emacs
<
2023-03-30
>
aaelony16:03:54

I have to say, M-x find-grep-dired is amazing and I can't believe I only just recently discovered it. Hope others benefit from it!

👍 4
👀 8
2
ag17:03:35

I confirm. find-name-dired and find-grep-dired are incredibly underrated commands. https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired-and-Find.html What's crazy about them is that the output is a Dired buffer. You can, for example, search for matching files and start renaming them. Total and complete bananas.

💯 6
👍 2
ag17:03:47

I bet if you ask someone using a "ITJUSTWORKS™" IDE, they'd be mumbling something about that in three-hundred and fifty years of them being a programmer they never had to do that. More reasonable ones would probably say something like: "I'd just write a bash/python/awk one-liner. Yeah, I don't mind that it's 700 chars long..."

aaelony17:03:42

I may never need to write find . -name "*.clj" | xargs grep foo again 😉

ag17:03:02

I mean you get it right? It's a effing Dired buffer. You can for example search for matching files, then mark some of them (even using regexp again) and say for example compress them into a .zip. Or copy them somewhere else, etc.

aaelony17:03:57

yep, amazing

Benjamin13:04:25

Yes, that is really nice thanks. There is also embark - embark-export can do similar things. For instance using consult-find, then exporting into a dired buffer.

2
Mario G09:04:22

I took note a few weeks ago of this conversation, only today I stumbled on a suitable use case. AWESOME, just awesome. Thanks for mentioning it yeshugs

🚀 1
ag17:03:35

One of the ideas that keep popping up whenever I have to touch a large .edn file, is to make imenu navigable across the keys in the map. I swear, if it keeps bothering me, I will try to write a function that does that. Or maybe someone already did?

💡 6
ericdallo18:03:58

clojure-lsp could support that under documentSymbols for .edn files, pretty useful and fits the feature indeed

ericdallo18:03:30

also, clojure-lsp has all the necessary analysis of each keyword of the edn, so would be way easier than an adhoc elisp function and would be possible to be used OOTB on other editors :)

Chris Clark18:03:14

I guess code folding could be an alternative way to achieve something similar (more quickly navigate to keys). Not that I have that working…

ag18:03:34

Chris, code folding hides the nested keys. I want something that works like imenu in Org-mode.

👍 2
ag18:03:16

> clojure-lsp has all the necessary analysis of each keyword of the edn Can you send me relevant pieces (maybe in the code)? I'll put that in my backlog and hopefully try to experiment with that at some point.

ericdallo19:03:40

Sure, https://github.com/clojure-lsp/clojure-lsp/blob/de391efb86307203cfa98ab73e7d34733677a6fb/lib/src/clojure_lsp/feature/document_symbol.clj#L52 that does that, currently it only check for var-definitions in the ns, but we could check if it's a edn file, return that idea of yours

dakra19:03:05

Not exactly what you're asking but I added this hacky regex to my imenu to get a very simple version of all root level keywords in an edn file (add-to-list 'imenu-generic-expression '(nil "^.?.?\\(:[^ ]+\\).*$" 1) t) Maybe use it as an inspiration and say if you find a proper solution 🙂 https://github.com/dakra/dmacs/blob/b6a038340dfc9d521ca4aee0529ae7b3ff4616e5/init.org?plain=1#L5589-L5593

ag23:03:48

Oh, nice @UFAP0C8KU. But I also wish you didn't show me that, because now I may not have that itch to figure out a way that works for nested keys too.

ag23:03:15

And you may wanna wrap it, like this:

(when (string= "edn" (file-name-extension (or (buffer-file-name) "")))
    (add-to-list 'imenu-generic-expression '(nil "^.?.?\\(:[^ ]+\\).*$" 1) t))

dakra08:03:31

Good suggestion. I was a bit surprised that edn doesn't have it's own mode like lisp-data-mode . But it turns out that I actually like the same regex in my cljs files as well. With re-frame I have something like

(rf/reg-event-db
 :foo/bar
 (fn-traced [db [_ foo]]
   ...
and now :foo/bar appears in my imenu alongside the normal defn functions.

2
ag03:04:14

Woah. Thank you. This is awesome!!

🚀 2