Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Send command to emacs from external process

479 views
Skip to first unread message

Joe Riel

unread,
Oct 28, 2011, 11:40:10 PM10/28/11
to help-gn...@gnu.org
Frequently I'll have Emacs running on a machine,
with an unsaved buffer, and would like to save the
buffer but no longer have access to the terminal
(i.e. it's in a different room and I'm too lazy to
walk over there). I can login in to the machine
remotely. Is there a way to tell Emacs to save
the buffer?

--
Joe Riel


Pascal J. Bourguignon

unread,
Oct 28, 2011, 11:48:09 PM10/28/11
to
You need to have a (server-start) call in ~/.emacs


ssh remote emacsclient -e '"(with-current-buffer \"YourBuffer.txt\" (save-buffer))"'

or:

ssh remote
emacsclient -e '(with-current-buffer "YourBuffer.txt" (save-buffer))'




--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Jai Dayal

unread,
Oct 29, 2011, 12:18:27 AM10/29/11
to Joe Riel, help-gn...@gnu.org
One thing I can think of is to use Screen, and then after you ssh in, you just attach to the screen, and everything is there.. the entire environment

On Fri, Oct 28, 2011 at 11:40 PM, Joe Riel <jo...@san.rr.com> wrote:
Frequently I'll have Emacs running on a machine,
with an unsaved buffer, and would like to save the
buffer but no longer have access to the terminal
(i.e. it's in a different room and I'm too lazy to
walk over there).  I can login in to the machine
remotely.  Is there a way to tell Emacs to save
the buffer?

--
Joe Riel



Tassilo Horn

unread,
Oct 29, 2011, 2:47:14 AM10/29/11
to help-gn...@gnu.org
Jai Dayal <daya...@gmail.com> writes:

> One thing I can think of is to use Screen, and then after you ssh in,
> you just attach to the screen, and everything is there.. the entire
> environment

Or simply run emacs as a server. (info "(emacs)Emacs Server")

Bye,
Tassilo
--
(What the world needs (I think) is not
(a Lisp (with fewer parentheses))
but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf


Joe Riel

unread,
Oct 29, 2011, 10:24:56 AM10/29/11
to help-gn...@gnu.org
On Sat, 29 Oct 2011 08:47:14 +0200
Tassilo Horn <tas...@member.fsf.org> wrote:

> Jai Dayal <daya...@gmail.com> writes:
>
> > One thing I can think of is to use Screen, and then after you ssh in,
> > you just attach to the screen, and everything is there.. the entire
> > environment
>
> Or simply run emacs as a server. (info "(emacs)Emacs Server")

Thanks, that's exactly what I want.

--
Joe Riel


Stefan Monnier

unread,
Oct 29, 2011, 1:02:38 PM10/29/11
to
>> > One thing I can think of is to use Screen, and then after you ssh in,
>> > you just attach to the screen, and everything is there.. the entire
>> > environment
>> Or simply run emacs as a server. (info "(emacs)Emacs Server")
> Thanks, that's exactly what I want.

And when it's tool ate to start the server, you can kill the Emacs
process (with a soft signal, not like SIGKILL, of course), and Emacs
will autosave the buffers so they're ready for recovery.


Stefan

David Combs

unread,
Nov 26, 2011, 10:09:42 PM11/26/11
to
In article <jwvaa8jpw9k.fsf-mon...@gnu.org>,
Just to avoid mistakes, please show us a kill command that you WOULD use.

Then, maybe give the name of the recovery command, which we can then
follow up on in *info*.

THANKS!

David


Stefan Monnier

unread,
Dec 1, 2011, 11:24:04 AM12/1/11
to
>>>> > One thing I can think of is to use Screen, and then after you ssh in,
>>>> > you just attach to the screen, and everything is there.. the entire
>>>> > environment
>>>> Or simply run emacs as a server. (info "(emacs)Emacs Server")
>>> Thanks, that's exactly what I want.
>> And when it's tool ate to start the server, you can kill the Emacs
>> process (with a soft signal, not like SIGKILL, of course), and Emacs
>> will autosave the buffers so they're ready for recovery.
> Just to avoid mistakes, please show us a kill command that you WOULD use.

"killall emacs" or "kill <emacspid>".

> Then, maybe give the name of the recovery command, which we can then
> follow up on in *info*.

You can try M-x recover-session, but I personally only open the file
I want to edit and then use M-x recover-this-file.


Stefan
0 new messages