I want to make a command-line app that can be used like this:
$push_to_emacs_buffer "some text"
Then the current running Emacs will append some text
into its current active buffer.
Any idea on how to achieve that?
To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab. Emacs fills in the rest of the name.
Kill (Cut), Copy, and Yank (Paste) Commands in Emacs To cut, or kill, the text, you can use the keys Ctrl + k to kill a particular line, or the Ctrl + w command to kill the entire selected region. To paste, or yank, the text, press the keys Ctrl + y.
C-x h will select the entire buffer. You can search for help within Emacs using the built-in help system.
Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.
Try
emacsclient -e '(with-current-buffer (window-buffer (selected-window)) (insert "some text"))'
On Linux, push-to-emacs-buffer
can be implemented like this:
#!/bin/sh
emacsclient -e "(with-current-buffer (window-buffer (selected-window)) \
(insert \"$@\"))"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With