Alt-Tab doesn't switch window after launch emacsclient - emacs

I wanted to open a new file in Emacs from shell in a new buffer in an existing window, so I used emacsclient.
After I launch emacsclient, it opens the file in a new buffer, as I wanted, but then Alt+Tab doesn't work and I need to click with the mouse on the top panel to get to another window.
May somebody know how to solve this problem? Or maybe open new file in a new buffer without emacsclient?
I'm using Ubuntu 11.10.
emacsclient command I'm using:
emacsclient --no-wait -n $*

Related

How to open directory from terminal in vs code? but inside the same window

I have vs code open and I'm using bash terminal within it, when I'm inside the directory I want to open I type code . and that opens everything I want but it opens a new vs code window. Is there a way it can open inside of the current vs code window I am in?
Try code . -r to force opening in the same window. See https://code.visualstudio.com/docs/editor/command-line#_core-cli-options for more options in the command line.
For a more "permanent" solution there is this setting:
Window: Open Files In New Window
Controls whether files should open in a new window. Note that there
can still be cases where this setting is ignored (e.g. when using the
--new-window or --reuse-window command line option).
Set it to off and then ``code .` is enough.

How to open file from ssh server on the emacs terminal?

I'm new to emacs and a little confused about opening a saved file on an ssh client so I can edit it (this is for school)
What I have done is...
Opened my terminal on mac
Opened emacs via terminal
Split emacs screen so I have one side to edit a c program and another side for terminal (to compile faster)
Logged onto an ssh client (there is a file on there that I'm supposed to edit)
The only problem is that I'm unsure how to open that specific file from my emacs terminal if that file is from an ssh client.
I have tried emacs filename.c on the emacs terminal & it opens a version of my file that isn't colored and scrolls oddly.
How can I correctly open the file so that it's colored and scrolls like the regular files on emacs?
I have also tried c-c c-f on terminal and typed my filename.c but it just opens a blank page.
Any suggestions? Thank you in advance!
Emacs can access files on a remote machine via its package Tramp. In order to open such a file from your local machine, apply
C-x C-f /ssh:user#host:/path/to/file
user is your login name at the remote machine, and host is the name of that machine.

How do I open Emacs in terminal when I double click on a file?

I run Emacs with -nw mode, but when I double click on a file I want to edit from my desktop, it opens up the Emacs app outside the terminal. Is there a way to change this?
Using OSX 10.8.5 and emacs 24.3.1.
After opening Emacs, run server-mode. Instead of associating the double click with Emacs, associate it with emacs-client. The client will connect to the server and open the file will open in the running Emacs instance. (not tested on OSX)

Make emacs never open up a new frame

How would you set emacs up to never create any new frame. If I want frames, I will do that from inside emacs.
Annoyingly, whenever I click a file from a file manager outside emacs, this opens up a completely new instance of emacs, with all the long loading time going along with that.
Opening a bunch of files, each taking like 5 seconds to finally load is not very convenient.
So what I want to do is this: Whenever I click a file on the file manager, I want that file to be opend up in the one instance of emacs that is already running as a new buffer.
How would I do that?
Using emacs 24.3.1 on Fedora 19 with Gnome 3.8.4
You want to start one single instance of emacs (which should start a server using (server-start) in your ~/.emacs) and then use emacsclient. You probably should
export EDITOR=emacsclient
in e.g. your ~/.bashrc
See invoking emacsclient (in Emacs documentation) and EmacsClient (in Emacs Wiki).
Here's what I did. I have Ubuntu, but I'm pretty sure that
Gnome also uses
/usr/share/applications/.
Here's my /usr/local/share/applications/emacsclient.desktop:
[Desktop Entry]
Name=Emacsclient
GenericName=Text Editor
Comment=View and edit files
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/usr/local/bin/emacsclient %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Here's my /usr/local/share/applications/emacs.desktop(just for completeness):
[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
The command to update these shortcuts without rebooting is:
sudo update-desktop-database
Now you should have an Emacsclient entry in your file managers "open with" dialog.
Make the associations and the files will open in emacs with a click of a mouse.
Just make sure to have in your ~/.emacs:
(require 'server)
(or (server-running-p) (server-start))

How to set emacs to open new files in current instance on Ubuntu/Mint?

I want to keep emacs open most of the time, and then whenever I open a text file, python file, etc (from nautilus/finder), I want it to open as a new buffer in my current emacs instance, rather than starting a new instance.
I tried following this guide:
I wasn't really sure about what to do with the file, but what I tried was copying it to /usr/bin/emacs_openfile, adding #!/bin/sh to the first line, and running chmod +x emacs_openfile
However, it doesn't work for me and just opens a new instance, even though I was able to associate text files with this program.
On a sidenote, I set emacs as the default editor using this.
You want emacs client.
Basically, set emacsclient as your default editor, and add (server-start) somewere in your emacs config.
There needs to be a running Emacs instance for emacsclient to work, but if it's a hassle it's possible to have a headless Emacs launched at login.
Did you start server in emacs? Make sure that you add (server-start) to your .emacs or do M-x server-start from an existing EMACS session.
Conceptually, it's really easy, just do emacsclient file-name on the command line or where you name the program.
Just for your information, If you are using GUI version on Mac, the dir os emacsclient is below:
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient