Fork me on GitHub
#emacs
<
2024-01-10
>
Daniel Slutsky13:01:01

An Elisp code style question: In the https://github.com/scicloj/clay.el Emacs package for the Clay tool, I've been using slashes in file names, just thinking it would make them convenient & readable for Clojure users. E.g., clay/make-last-sexp instead of clay-make-last-sexp. Before proposing the package for MELPA, I am wondering whether this naming habit diverges too much from the common way of doing things. Any thoughts? Should I avoid that? Is it actually useful?

vemv13:01:42

Never gave me a practical problem in many years of elisping Personally I'd be happy to see it more commonly used!

πŸ™ 1
elken13:01:18

Typical convention is the second one, but plenty of people use slash namespacing. Not worth worrying about it πŸ™‚

πŸ™ 1
Daniel Slutsky13:01:21

That is so helpful, thanks for your quick feedback!

Daniel Slutsky13:01:57

https://github.com/purcell/package-lint gives me errors such as:

99:0: error: `clay/make-last-sexp' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).  
Since package-lint seems to be a requirement for a MELPA pull-request, I guess I'll change the slashes to dashes.

😞 2
vemv13:01:34

TIL about p-lint. Guess we should use it in CIDER etc (which predates that linter)

πŸ™ 1
practicalli-johnny18:01:42

I've seen a lot of things in the form clay/make-last-sexp and this its very useful to identify the source of these functions. It makes it very clear to me this way.

πŸ™ 1
Daniel Slutsky18:01:19

Thanks, it helps to know.

Benjamin13:01:48

Agreeing with package lint here. Emacs itself also uses - everywhere

πŸ™ 1
teodorlu13:01:25

Good afternoon! I need to quickly inspect 131 json files visually in a folder. I’d like to view them in emacs, and quickly go to the next file, without having to remember the next file name. I found a way to do it with Vim:

vim *.json
:next
:next
:next
...
Vim was then opened with all the files, :next shows me the next file. Problems: β€’ I had to use Vim, I prefer Emacs β€’ I have to type 5 letters each time I move to the next file. I’d prefer an action that was one letter. Any suggestions for how I can solve this in Emacs? Has anyone done something similar?

βœ… 1
magnars13:01:57

Macro to the rescue

emacs-spin 2
magnars13:01:16

Start in dired at the first file

magnars13:01:29

Go into the file, press F3 to start recording a macro

πŸ‘€ 1
magnars13:01:45

Jump to dired, next line, enter

magnars13:01:53

F4 to end the macro

πŸ‘ 1
elken13:01:54

https://github.com/protesilaos/dired-preview might save you having to open them at all, but I agree macro + dired is the way to go otherwise

πŸ‘ 1
magnars13:01:08

Now you can press F4 to go to the next file

πŸ‘ 1
teodorlu13:01:04

I think I’ll try using macros* since I’d like to get more experience using macros. Thank you both! πŸ™ ❀️

vemv13:01:18

Another approach being to feed them into Clojure and cider-inspect the result

magnars13:01:18

these are not written macros

magnars13:01:27

these are kmacros - keyboard macros, recorded live

πŸ‘ 1
magnars13:01:54

very powerful tool πŸ™‚

teodorlu13:01:43

oh, man this is totally amazing. I had no idea it would be so simple to do and so easy it would be to use. 😁 😁 😁 😁

πŸ˜„ 3
Ed15:01:18

I realise you've already learned used macros to solve this, which is probably way better, but if you use the emacs server, you could also open them all with emacsclient -nw -c *.json and run server-edit, which is bound to C-x # by default, to say you're done editing that file and move on to the next one. When you get to the end of the list it will return you to the terminal prompt. Also, if you just wanted to read them, you can use less *.json to display each in turn and then :n to goto the next one (three less characters than vim ;P) or if you've installed bat then that will display them all in a paginated fashion (like less) and probably give you syntax highlighting.

πŸ’― 1
teodorlu15:01:46

@U0P0TMEFJ with your suggestion, I was able to come up with this abomination:

ls sites/*json | xargs -n 1 less
q to go to next, C-c to close all. Abomination modified to work with bat:
ls sites/*json | xargs -n 1 bat --paging=always
Thanks! And I hope Berlin is treating you as well as ever, if that was your permanent residence when we spoke last summer πŸ™‚

πŸ‘ 1
Ed16:01:05

I was remote working for a company in Berlin a while ago, but I'm generally UK based πŸ˜‰ ... I hope your currently location is treating you well too. πŸ™‚

❀️ 1
teodorlu16:01:34

Oslo as usual, with real snow this winter, which I appreciate!

Ed16:01:43

Oslo is nice. We had a great holiday in TromsΓΈ a few years ago in Jan to see the Aurora, and spent a few days in Oslo. The Norwegian scenery can be amazing ;)

❀️ 1
Patrix21:01:43

>> Vim was then opened with all the files, :next shows me the next file. Problems: > β€’ I have to type 5 letters each time I move to the next file. I’d prefer an action that was one letter. FYI, :n works just as well as :next, I didn't even know :next was possible and always used :n

πŸ‘ 1
til 1
Ed01:01:22

https://youtu.be/q4ZJPiW9beE?si=_ivbugBevAMhwTg7 ... this seems like a good reason to live in Oslo πŸ˜‰

πŸ˜„ 1