Fork me on GitHub
#emacs
<
2021-03-05
>
teodorlu10:03:30

Quick question. I find that using find . -iname '*.go' | xargs bat (or use cat instead of bat, if you don't care about syntax highlighting) is an excellent way to quickly read a bunch of files. There's one caveat: I can't treat it as an Emacs buffer. Are anyone else doing something similar to what I'm doing to "collect a bunch of files to read linearly"? Suggestions on how to "Emacsify" the workflow? Thanks!

vemv11:03:48

from a quick googling, it looks like emacs can't make a buffer out of stdin directly So maybe I'd persist find . -iname '*.go' | xargs bat to a tmp file and open that

teodorlu11:03:59

Good point. I suppose I'd loose syntax highlighting then?

teodorlu11:03:54

:thinking_face: It might not be too hard to write a script that takes a list of filenames as input, and produces an org-mode file with those files listed.

vemv11:03:48

> Good point. I suppose I'd loose syntax highlighting then? You can always M-x clojure-mode (or w/e mode it is) to activate it

👍 1
teodorlu12:03:22

Good point. Or save the temp file with the right extension. :thinking_face:

andy.fingerhut14:03:58

Does M-x grep using the -r recursive option to grep do what you need? Or does it include files that you want to leave out?

1
andy.fingerhut14:03:37

I have heard that Emacs packages like projectile and a few others might be able to help you create sets of files to operate upon that might be useful here, but I haven't tried it myself.

👍 1
andy.fingerhut14:03:31

If you take the output of the find ... xargs grep command you mentioned, and put it into an Emacs buffer, and then change its mode to whatever the minor/major mode is used for M-x grep output, (maybe compilation-mode? I forget), then it might let you step forward and backward to found lines quickly.

1
teodorlu16:03:48

https://clojurians.slack.com/archives/C099W16KZ/p1614955438005200?thread_ts=1614939450.002500&amp;cid=C099W16KZ Would that leave me a complete listing of a subset of files? Running M-x grep left me an option to grep, but I'm not sure how this helps me read a bunch of files linearly in a project.

teodorlu16:03:54

https://clojurians.slack.com/archives/C099W16KZ/p1614955531005800?thread_ts=1614939450.002500&amp;cid=C099W16KZ I've been thinking something along these lines.

find . -iname '*.go' | orgcat > 
Where orgcat is an Emacs Lisp script that reads file contents, and creates an org-mode file with approperiate #BEGIN_SRC lang blocks for the files.

teodorlu16:03:13

(I haven't made any attempts to write orgcat yet)

ag20:03:21

@U3X7174KS if you need the output of a command in a buffer, one way could be running shell-command-on-region in a buffer with a prefix basically, create an empty buffer in the project, and run C-u M-| then type your command find . -iname '*.go' | xargs bat the output of the command will be yanked into the buffer

👍 2
ag20:03:08

but if I understand it right, you're simply trying to have "occur" buffer with the files. Ivy-occur, or helm-occur.

1
teodorlu20:03:10

I might have to read up on occur.

ag20:03:15

depending of what you use, helm-rg or counsel-rg - they both can be called with a prefix

ag20:03:50

that way you can pass any arbitrary command line params to rg (cmd utility)

Phil Shapiro20:03:21

Eshell is a shell for emacs that lets you do a lot of interesting things, including redirect the output of a shell command to a buffer. https://www.gnu.org/software/emacs/manual/html_mono/eshell.html

Phil Shapiro21:03:23

But if you want to process the output of a command like grep, using compile mode might be best. M-x compile RET and replace the default compile command with the thing you want it run.

1
ag21:03:19

ivy, and helm are the best for the output of grep, rg, ag, etc. Once you have the occurrences, you can call occur-mode command, i.e. C-c C-o in ivy/counsel buffer

danielneal12:03:31

For some reason my .dir-locals.el with my cider-clojure-cli-global-options have stopped being picked up

danielneal12:03:40

anyone have any ideas why that might have happened

danielneal12:03:06

atm I'm doing C-u M-x cider-jack-in and typing in the options manually like a caveman

dpsutton15:03:44

@danieleneal there was a version of cider that removed them and then later they were re added. What is the contents of them?

danielneal15:03:00

((clojure-mode . ((cider-clojure-cli-global-options . "-A:dev:test"))))

danielneal15:03:08

I'm on cider 1.0.0

danielneal15:03:57

but if I do describe-variable cider-clojure-cli-global-options its nil

dpsutton15:03:07

Try (hack-local-variables)

danielneal16:03:57

yeah, that sets it

danielneal16:03:05

how does that work?

dpsutton16:03:17

that just kinda refreshes the dir locals stuff. it's a way to slap the top of emacs like you would slap an appliance to make it work

grazfather17:03:33

hahaha that guy is from snatch