close emacs from remote computer - emacs

I forgot to close emacs at work which has buffers which are not saved.
Is there a way to close emacs from my remote computer using an ssh connection with forcing emacs to save all buffers?

You can kill the Emacs process from a shell. Emacs will have produced auto-save information for all file-related buffers.
Then start a new emacs, type M-x recover-session, and you will see a list of recent sessions to recover.
Type C-c C-c on the latest and follow instructions.

Related

How do I exit Emacs from the terminal?

I just installed Emacs 26.3 on Ubuntu 20.04. I opened a buffer in the terminal, and I cannot close it. C-x C-c does nothing. f10 to activate the menu does not activate the menu.
I'm using a .emacs file that maps cut/copy/paste commands to the normal C-x/C-c/C-v. I don't think that this can affect the issue, however, because I have the exact same setup (including the same .emacs file) on by Emacs 24.5/Ubuntu 16.04 laptop, and it has no problem exiting with C-x C-c. Also, I had the exact same problem before I installed the .emacs file on the new system.
How do I kill Emacs?
This question exists, but it has no useful answers.
ESC x save-buffers-kill-terminal
OFC binding C-x will affect C-x C-c. You don't need to know anything about Emacs to realize the problem. Just think twice.

Emacs Tramp connection fails with "no such directory"

I'm hoping to use Tramp mode to edit files on a remote Linux machine, so I open a file like this:
C-x C-f /ssh:hwolff#<host>:/home/hwolff/temp.txt
But there is no prompt for a password, and saving the file brings the error "no such directory". Emacs seems to be treating the file path as if it's local, rather than attempting to connect to the remote machine. I can SSH to that machine with no problems.
Following the SO discussion Emacs Tramp unable to open directory at times, I tried turning on tramp-debug-buffer, but no debug buffer ever appeared.
Relevant lines from the *Messages* buffer:
Use M-x make-directory RET RET to create the directory and its parents
...
Saving file /ssh:hwolff#<host>:/home/hwolff/temp.txt...
ad-Orig-error: /ssh:hwolff#<host>:/home/hwolff/: no such directory
I loaded Tramp like this:
(load-file "/Applications/Aquamacs.app/Contents/Resources/lisp/net/tramp.elc")
That seemed to work fine, and Emacs seems to report that Tramp is ready:
M-x tramp-version
2.1.10
I'm running Emacs 23.3.1 as Aquamacs on Mac OS 10.7.5:
GNU Emacs 23.3.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
of 2011-03-18 on braeburn.aquamacs.org - Aquamacs Distribution 2.2

How do I control emacs from a terminal?

I'm trying to drive emacs on OSX using Dragon Naturally Speaking running inside a Windows VM. Rather than running emacs in the VM, I'd like to drive an emacs (built from the HEAD of the repository) already running on the mac side of things. So, after a hunt through the emacs lisp manual I came up with the following snippets of lisp (currently running from the scratch buffer while I work stuff out):
;; This part is run from an emacsclient -t session
(defvar slave-frame last-event-frame)
;; and this is run in a GUI frame
(defadvice handle-switch-frame (after update-slave-redirect-advice activate)
(unless (eq last-event-frame slave-frame)
(redirect-frame-focus slave-frame last-event-frame)))
And all is well. I type into the terminal window, displaying buffer A and my typing appears in the GUI frame busily dsplaying buffer B. Great. Until I do C-x C-f or any other command that needs the minibuffer, at which point I get the error Terminal 1 is locked, cannot read from it.
I'm I barking up the wrong tree here, or is there a way to make redirect-frame-focus work nicely with commands that use the minibuffer?
Piers,
What behavior do you want, redirection to a minibuffer on the (Windows) client or a minibuffer on the server? Also, what version/flavor of emacs are you using?

Refresh remote directory in Emacs Tramp Mode

I've been using Tramp mode on my Emacs to edit files remotely. I'm also using ido mode. When I add a new file in the same directory of a file I opened using Tramp, I couldn't get Tramp to find the new file(with C-x C-f). Is there a way to refresh Tramp?
Your question is about ido-mode used with tramp. To refresh ido auto-complete while in the process of finding a file, you can press C-l, to execute: ido-reread-directory.
As documented here, you can press g in the dired buffer to run revert-buffer and refresh the directory listing.

In emacs, query-replace-regexp keyboard shortcut doesn't work in the terminal (e.g., emacs -nw)

Is it expected that C-M-% and ESC C-% do not run the command query-replace-regexp when running emacs in a terminal window (for example, emacs -nw)?
According to describe-function the binding exists, but emacs runs query-replace instead (which has the binding M-%). This has happened on several machines I've tried it on, and does not happen when I run emacs in a window.
The problem is that C-% simply can't be typed in a terminal. The only control sequences available are those that corresponds to ascii-code 0-31, mainly C-letter.
I have created a new shortcut in my .emacs file.
(global-set-key "\M-q" 'query-replace-regexp)
Control-Alt-Shift-% all together works on Windows and Fedora Linux. Does your keyboard have all those keys?