Going back to a previous buffer in emacs - emacs

I used C-x u and the screen I was typing on disappeared, so I tried creating again on the second question but it says that file already exists; how do go back to the one I created in the first question?

If you want to go back to the previous buffer, probably you could use Ctrl-X <left> keybinding. If you want to go back to previous window, you could try Ctrl-C <left>

There's a suite of options based on what you're trying to accomplish:
Ctrl-x <left> jumps to your previous buffer, can be repeated to keep popping stack frames
Ctrl-x b opens a prompt in the minibuffer. The default option is the prior buffer, but you can use <up>/<down> keys to browse the prior stack of buffers
Ctrl-x Ctrl-b opens *Buffer List* where you can see all buffers and select the one you want

Related

How to prevent a fram show up for a second when emacsclient or `emacs -nw` starts?

I am using emacs-daemon. When every I restart my daemon and do C-x C-b my Buffer List seems always full.
Later, when I start my emacsclient for a seconds(like a fast flash) it shows a file that located on the top of my Buffer List and opens the file I want to open. This is little annoying to face with all the time.
Example:
I type emacsclient -t file_a.py.
For a second or less, buffer called file_b.py opens (my lastly opened file).
Than file_a.py get opens.
This always repeats itself even I clean my buffer list doing following and open a new file (since buffer list now contains more than one file):
Link:
Edit: There's also the boring old buffer menu you get with C-x C-b.
In this menu, you can hold d until it marks each buffer for deletion,
then press x to commit.
Even after doing this after that IBuffer shows up since it is the latest opened buffer.
[Q] Is it possible to prevent 1 second file show up when I start emacsclient? If possible I always want to keep my Buffer List empty, but not sure would it be a good idea, or some how keep a empty file at the top of the buffer list since it will show a blank frame.
This also occurs when I using emacs -nw where scratch* buffer or latest opened buffer shows up for as seconds as well.

Emacs switch-to-buffer (C-x b) will change window if the buffer is opened in some other window

I would like to change the behavior of switch-to-buffer to always open the desired buffer in the current window instead of switching to another window if already opened.
My rationale for doing this :
I have 2 screens, one Emacs on each. One is for reading, the other one for writing. Some buffers will be in the reading side for a while, but now I want to edit them. I'd like to have them in front of me instead of automatically switch to this other window on the side.
Thank you.
That is what switch-to-buffer does - exactly what you say you want. Do you see something different when you start Emacs without an init file (emacs -Q)?
The only exception is when the window cannot be used for that buffer. As the doc string says:
If the selected window cannot display the specified
buffer (e.g. if it is a minibuffer window or strongly dedicated
to another buffer), call `pop-to-buffer' to select the buffer in
another window.

How to make emacs allow opening one buffer in different frames?

I have two frames of the same Emacs instance (got them by C-x 5 2) and a file opened in one of these frames. Then I try to show this file in a buffer in another frame (by C-x b) and nothing happens.
Actually, I think it shows this file in a buffer in the first frame, but this is not what I want it to do. I want it to show this buffer in both frames.
When there is only one frame and some windows in it, opening one buffer in different windows is no problem. I want the same behaviour but with several frames.
Most likely you are using iswitch, as what you describe is its default behavior.
You can change it by doing M-x customize-variable RET iswitchb-default-method. probably you want to choose option samewindow
The ido equivalent variable , in case you are using it, is ido-default-buffer-method (ido defaults to raise-frame, that does not match with your observed behavior).
You may find if you are using one or the other using the way #Olaf describes.
Maybe, you have C-x b redefined. I have the same behaviour with iswitch-buffer. But when I enter M-x switch-to-buffer, it shows the buffer in the second window.
You can find out, which command is executed with C-h c C-x b.

In Emacs, can we maximize current active window, and then restore it back in multiple window environment?

I like to open multiple window, each with its own file opened. Sometimes, I want to maximize the one I edited to occupy whole screen, and then to restore it back to its previous size and position..
Is there a way?
According to the emacs menu, I can only figure out enlarge-window, shrink-window.. thats it..
More or less - try using winner-mode. It will remember the last few (ca 200) window configurations, and will let you walk through them with a simple (C-c (right|left)) keystroke. And it's quite easy to turn on, since it's built in:
(when (fboundp 'winner-mode)
(winner-mode 1))
Combine it with windmove and moving between your windows will be even more awesome.
Use the command window-configuration-to-register: M-x window-configuration-to-register, press the Enter key, then some register (character), e.g. a. To maximize current window, use C-x 1. When you want to restore, type C-x r j a.
Workaround.
ESC ESC ESC maximizes the buffer with active cursor.
M-x ` to navigate between other buffers.

How do I stop Emacs from changing my split buffers?

I have a number of splits open, looking at various buffers. But when I for example check the help on a function it will replace one of the splits with the help buffer. Once I'm done reading the help I have to go back to the correct buffer manually which is a pain. How do I get Emacs to be nicer to my buffers?
Update: Help will let you press q to go back to the previous buffer. But causing the Emacs backtrace to pop up also steals one of my buffer windows and it doesn't have a q.
Update: Backtrace DOES have q to go back. My original question still remains: how do I ask Emacs not to steal one of my splits?
Adding the line(push "*Help*" special-display-buffer-names) to the init file should make subsequent invocations of the help buffer to appear in its own frame(what the desktop usually calls "window"), and leave the original frame with its configuration alone.
See Special Buffer Frames.
You could also use winner-mode. It came up on planet.emacsen.org a while back.
Winner Mode is a global minor mode. When activated, it allows to “undo” (and “redo”) changes in the window configuration with the key commands ‘C-c left’ and ‘C-c right’.
That way you can undo any changes to your splits immediately after they happen.
I hope this will help you :
C-x 0 to remove the current window
C-x 1 to keep only the current window
you can use windmove by adding the following line in your .emacs :
(windmove-default-keybindings)
Then, you can move the point between windows using S-right S-left S-up and S-down
There are lots of ways to store and restore emacs windows, see emacswiki.org on the subject.
What I do is just go to that changed buffer, C-x k it, and the current buffer in that window will be the previous buffer.
It may be possible to define advice for the help that saves the current window and buffer state and restores it with a simple keybind. But this is outside my basic elisp knowledge.