polarity_inverter

joined 2 years ago
 

So I wrote a little function for how I use eat.

In eat, you can have multiple terminal buffers open, and they are differentiated by incrementing numbers. The official way to open an additional buffer is to run eat with a prefix argument like C-u M-x eat. I wrote my little function to do this for me, because I don't use prefix arguments/C-u anywhere else and just couldn't remember it.

So this function checks the buffer list for existing eat buffers. If there is one with a number at the end, it takes this number, increments it by one and then opens a new eat buffer with this incremented number. If there is just one without a number, it opens a new buffer with the number one, since the first buffer is created without a number per default. If there is no eat buffer at all, it just calls eat to create one. This is the function:

(defun eat-more ()
  "Open a new terminal"
  (interactive)
  (if (match-buffers "\*eat\*")
      (if (string-match ".*<.>" (prin1-to-string (last (match-buffers "\*eat\*"))))
	  (eat (funcall eat-default-shell-function) (+ (string-to-number (substring (prin1-to-string (last (sort (match-buffers "\*eat\*")))) -4 -3)) 1))
	(eat (funcall eat-default-shell-function) 1))
    (eat)))

This works as intended, but the line getting and incrementing the buffer number looks really awkward. So my question is: How could I improve that to make it more readable without changing the logic completely?

There are probably shorter ways to do this by just calling eat with a prefix argument in the function itself, or something like that. But I am interested in interacting with the buffer list and all this nested string slicing and converting feels off. The actual eat function is defined here in eat.el Do you have any suggestions?

[–] [email protected] 1 points 4 months ago (2 children)

You could either copy them to the top of your template, or you could take a look at the blockinfile module

[–] [email protected] 9 points 1 year ago

No, he was feared when he was alive. Most people actually celebrate his death...

[–] [email protected] 5 points 2 years ago (1 children)

They already did. The war sped up a process Zelensky's party already started beforehand.

[–] [email protected] 1 points 2 years ago* (last edited 2 years ago)

in parts of europe you can get some kobos branded as "tolino" - they have the same hardware, but actually run on android

[–] [email protected] 2 points 2 years ago

It's okay, definitely was worth it for me.

But I still think its kinda weird to put out a 400$ device and then say: "here's full ssh root access, but don't use it"

[–] [email protected] 1 points 2 years ago

no, it is quite fancy hardware, almost a4 paper sized, very thin and with an amazing hand writing experience and pretty good ocr.

Its a good device, but also quite expensive

[–] [email protected] 5 points 2 years ago (4 children)

the remarkable software is proprietary. they just run it on linux and give you root via ssh, but installing anything voids your warranty...

[–] [email protected] 1 points 2 years ago

nice. replying to a mastodon-post as a comment in a lemmy-thread is fancy 🖖

 

Some piece of fediverse history as a start for this new account.