Fork me on GitHub
#off-topic
<
2020-07-24
>
vishal sharma12:07:22

Hi, i need a suggestion, i am getting some events, i want to be able to search and visualize the events(aggregate query) should i store those events in db, or in file or somewhere different at all?

tvaughan14:07:05

What's the preferred way to automate opening buffers, splitting frames, running commands, etc. in emacs like split-pane, select-pane, send-keys, etc. in tmux? I'm not looking to save some random state to go back to it later, nor are these things confined to a project.

hiredman15:07:28

Emacs has a programming language elisp that can do all these things. So you can write an elisp program that opens files, selects buffers, splits windows, etc and then just tell emacs to evaluate it

tvaughan15:07:54

Thanks @U0NCTKEV8. There's a better description of what I'm after in this thread https://clojurians.slack.com/archives/C03RZGPG3/p1595604170447100

mpenet15:07:39

@tvaughan dvtm is often mentioned for this

mpenet15:07:50

dvtm + abduco would be the equivalent of tmux

tvaughan15:07:24

Thanks @U050SC7SV but I'm not looking to replace tmux. I want tmux like scripting capabilities in emacs. I want to automate the opening of emacs buffers, splitting frames, running emacs lisp commands, etc. but in emacs lisp

mpenet15:07:42

oh I missread

bartuka15:07:13

I don't know if I am missreading too, but in elisp you have functions like split-window-{vertically,horizontally}, new-frame, generate-new-buffer and you can execute shell commands using several options like shell-command-to-string

bartuka15:07:06

you want to write elisp functions to automate your processes, is that right?

tvaughan15:07:14

I'm hoping I don't have to write much. I'm hoping there's a package out there that can do most of this already. For example, I want to split emacs into two halves C-x 3, select the right most window, open a file over tramp, run cider-jack-in, select the left most window, run an elisp function I wrote to expand the window width, then open a file, then run C-c k to eval the buffer in the repl.

tvaughan15:07:23

That looks like its mostly centered around editing. I'm looking for something higher-level. A generic way of saying "select this window and run these keystrokes." I'm not looking for a set of interactive commands, but rather something that takes some sequence of instructions that I have stored in a .el start-up script and runs them on command. I want to be able to type M-x start-clojure-devel where I say, most likely in .dir-locals.el, start-clojure-devel means run the sequence of commands listed above

hiredman15:07:10

Running keystrokes is not the way to think about it, keys are generally bound to run some elisp function, when you are automate things you don't send keystrokes (you can but typically don't) you just call the elisp functions directly

tvaughan15:07:33

Not everything associated with a keystroke has a similar function that can be called programatically

hiredman15:07:57

https://gist.github.com/d4c507478430274ccf07de735632454a is a setup.el I have for a project that sets up the window like I want for that project and fiddles with opacity and font sizes

tvaughan16:07:21

Cool. Maybe this could be simple enough I don't need a package for this. Thanks

andy.fingerhut19:07:35

I thought everything in Emacs with a keystroke did have a function that can be called programmatically?

andy.fingerhut19:07:43

If I type C-h k <keystrokes>, for example C-h k C-x 3, I see a buffer appear that starts with the text "C-x 3 runs the command split-window-right ..."

andy.fingerhut19:07:56

And split-window-right is a function that can be called in Elisp code.

andy.fingerhut19:07:51

Here is a simple Elisp function I wrote that is loaded from my init.el, and I bind a function key that when pressed, executes that function: https://github.com/jafingerhut/dotfiles/blob/master/link/.emacs.d/lisp/fn-key-bindings.el#L18-L24

tvaughan21:07:35

You're probably right @U0CMVHBL2. But how does that function know which window to split? Isn't that determined by which window was active when the keystrokes were entered?

andy.fingerhut21:07:02

The rest of the documentation that appears when I type C-h k C-x 3 includes this text:

andy.fingerhut21:07:03

Split the selected window into two side-by-side windows. The selected window is on the left. The newly split-off window is on the right and displays the same buffer. Return the new window.

andy.fingerhut21:07:03

I am pretty sure that "the selected window" is accessible via either an Elisp function, or perhaps some global Elisp variable, and it is updated by whatever operations cause the selected window to change.

andy.fingerhut21:07:12

I haven't used them before, but I believe there are Elisp functions to list all buffers, create new ones, delete buffers, etc., and all of those are what are used to implement the behaviors you get when you enter the appropriate key strokes that do those things.

tvaughan21:07:16

That's good news, thanks. But this is sounding like a much bigger project than installing a package and setting a few things. 😞

tvaughan21:07:24

Oh, I'm aware. I just don't consider myself one of them. hahaha 🙂 Besides maintaining my own setup for decades https://github.com/carrete/.emacs.d I still consider myself an emacs newbie

mpenet15:07:49

otherwise if you prefer emacs at the root, libvterm is supposedly really good