Is it possible to use emacsclient to pre-load emacs, but have each window operate independently? - emacs

I have been really enjoying having emacs load as a daemon when I login and using emacsclient -c to pop open an emacs window superquick.
However, I often have multiple emacs windows open at a time. Each one is dedicated to a particular project. Before I used emacsclient each of these emacs windows would be independent of the other, but now, they share the same set of buffers.
How can I continue to use emacsclient, but have the windows act independently?

Related

Doom emacs display various themes in terminal

I employed the 'Ocean next theme' on alacritty terminal Color schemes · jwilm/alacritty Wiki
Upon starting doom-emacs from terminal (tmux new -s 'main'),
the identical commands emacs -nw display various theme.
I want the one above.
It's tricky that if start a new tmux session with other name saying 'focus',
They display the same themes
Restart the machine multiple times,
my desired theme appears on 'main' session to the above window.
What's the problem?
Your setup has too many layers:
Terminal->Tmux ->Emacs.
Try just running emacs without tmux (emacs has all the tmux goodies integrated) or better run the GUI emacs directly (themes will be in 100% full potential).
BTW, emacs GUI is not like GUI Vim. It's the total package if you run it with exwm.
Take out all decorations (scrool bar menu bar etc..) and it will look like a terminal app except with access to thousands of packages that cannot run in the terminal mode because of limitations.
Once you use it this way. There is no coming back.
My .xinitrc has one line exec emacs (keep in mind you can run firefox inside emacs)

Why can't I open another emacsclient after activating follow-mode?

I use Emacs for many things (the list seems to be growing every day). I like to have several frames open (so I can keep them in separate workspaces), so I first start it with emacs --daemon and then connect various clients to it with emacsclient -t.
One thing I have recently added to that list is writing papers. I write in Markdown, which allows easy version tracking with Git. In order to make it more readable, I usually split the frame into 3 or 4 windows vertically, and use follow-mode to split the paper between them.
I recently ran into a problem with this setup. Emacs would randomly stop accepting connections, and any time I ran emacsclient -t it would hang, never opening the frame. It took me a while to figure out why it happened, but I finally did. To reproduce:
Start emacs with emacs --daemon
Connect the first client with emacsclient -t <file> where <file> is some plaintext file.
Activate follow-mode with M-x follow-mode
Attempt to connect another client with emacsclient -t. This client will hang and never connect.
Deactivating follow-mode after that point had no effect, clients were still unable to connect. If I never activate follow-mode, I never have a problem.
I also tried it without loading any init files (emacs --daemon --no-init-file --no-site-file), with the same result.
I'm running GNU Emacs 23.4.1, from the Ubuntu software repositories.
Why does this happen?
Looks like a bug in follow-mode (I cannot reproduce it with with emacs 24.3). Upgrading emacs would be a solution for fixing the problem.
This seem to be the official thread for this problem, which provides some adittional information and a workaround for those unable or unwilling to upgrade emacs.

How Can I Get MinTTY (Cygwin Terminal) to Open Emacs in a New Window?

I can't figure out why this isn't easy to find on Google, but after searching for about 10 minutes, I just decided to give up and post here.
The subject basically says it all. I'm running MinTTY as a cygwin terminal on a Windows XP desktop. All I want to do is have emacs open up in a new window rather than inside my terminal. What would be best is a switch for this, so I could toggle it depending on my current needs. This seems like something that would be useful to a lot of people, and I know I've done it before on Linux boxes, so I imagine there must be a way to do this in cygwin too. Anyone know how?
Just start a new mintty, telling it to invoke emacs:
mintty emacs
There are a couple of scenarios that you might clarify:
Running the cygwin version of emacs within a standard windows environment will call emacs within the current shell
If the Cygwin X-Windows server (i.e., “XWin Server”) has been started and the DISPLAY environment variable has been set in the mintty terminal (e.g., export DISPLAY=":0"), calling emacs will start it in its own window.
running the Windows version of emacs within the cygwin terminal should launch the new frame you are seeking.
If you want a separate emacs 'window', you would be best served by installing the Windows native version of emacs (I use the gnu emacs precompiled binaries), and calling it from the cygwin terminal.

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

Running Emacs Remotely between several machines

I use Emacs remotely using X-Server in a Windows client and Linux server. I noticed that I can halt it using ctrl-z and then type fg 1 to get it working again. Is there some way that I could get it to halt on the machine that I am on, and then log into a different machine and start where I left off? When I start a new ssh session, the emacs job isn't associated to my terminal. There must be someway to "steal" it.
Also, maybe there's an Emacs feature that will do basically the same thing. However, I think closing and re-opening all my files and buffers would take quite a while.
Expanding on the idea of using emacsclient, you can look at what what someone did to solve the problem of editing a file from a different machine than where (s)he started running Emacs.
As of Emacs 23, you can run emacsclient in terminal windows using the -nw option.
Other solutions you might want to try are to use:
gnu screen
vnc
For years I used screen to "attach" and "detach" from a virtual terminal that sounds like your usage model. If you have the ability to use graphics... vnc is really great, just do your work in a vnc session and connect to it any machine.
And your last idea is already implemented by the package desktop (which is bundled with Emacs). Take a look at the wiki page for session management, which includes other alternatives to desktop, as well as add-ons for desktop to lazily load files.
You can run emacs as a server, and use emacsclient to connect to it. You can open multiple connections to the same emacs server, via ttys or X11.
When doing this, C-X C-C will close your connection, and leave the server running.
A simple way to do this by invoking emacs as follows. This will connect to the server if one is running, or create one.
emacsclient --alternate-editor="" -c
Sometimes I will be at work and have to run out the door leaving my Emacs session as it was. Later, I will open an Emacs instance to the same machine (usually using remote SSH) and find that I have files open in Emacs. Now the good news. Emacs allows you to "steal" those files using M-x recover-this-file. I recommend one of Trey's solutions if you can plan ahead. If not, you can use this recover file technique to keep progress moving.