I find the narrow-to-region command useful, however it applies to the buffer and not to the current window.
I'd like to have one window display a narrowed version of the buffer, while the buffer is displayed widened if it occurs in any other window.
Is this possible?
Try M-x clone-indirect-buffer or C-x 4 c. For details,
see Indirect Buffers.
Related
This is probably a very obvious question, but I seem to have missed something. When I first started using emacs about a month ago, pressing C-v would scroll down and leave two line at the top of the screen, à la tutorial. Somewhere along the line I must have upgraded packages, and it now places the cursor at the top of the screen - no context lines.
Running C-u -2 C-v works as expected, so I tried M-x set-variable RET next-screen-context-lines RET 2, which had absolutely no effect. According to C-h v RET next-screen-context-lines, I can set the variable to any positive or negative number I choose, but pressing C-v always results in the cursor moving to the top of the screen and now context lines. Incidentally, M-v has the same problem. I can't find a relevant setting in my .emacs, but I tried mv .emacs .emacs.bak and noticed no difference.
I'm running GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.22) of 2013-12-22 on binet, modified by Debian according to C-h C-a
Other than that, emacs is an amazing program I wish I'd used before, and which has now all but replaced libreoffice for me (with the help of RST). Now to learn to touch type...
Many thanks in advance for your time.
[EDIT]: I was wrong, the point moves as well and I hadn't noticed (see below). The variables suggested below are useful, however.
Check your value of user option scroll-margin: C-h v RET scroll-margin RET. The default value is 0. Try setting it to 2.
There are also other scrolling-related options whose values you can check. Try M-x apropos-option RET ^scroll RET. (Ignore any hits for scroll-bar.)
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I more easily switch between buffers in Emacs?
GNU Emacs 24.1.1
Hello,
When I want to switch buffers I use the following C-x C-b if I have many buffers active. But I find it very inefficient.
And it will display a lists of open buffers in the next buffer (I don't like this in the next buffer). Normally I have 4 buffers open at the same time.
Using the above I will then have to put the cursor (C-o) to get focus in the buffer-list buffer, when scroll up or down to select the buffer I want.
Sometimes I use C-x-b if I don't have many active buffers. However, I always have many.
However, I am looking for something then will open up a small buffer with a list of buffers (the minimum needed - just enough to show all buffers), and will automatically have focus. I scroll to select the buffer I want. And it will appear in the buffer I had focus on before I open the list of buffers. The buffer-list will then disappear.
Does anyone know of anything like this to make switching buffers easier.
Many thanks for any advice,
Apart from ido-mode, good buffer switching solutions are:
Plain-old C-x b + icomplete-mode
ibuffer - just rebind C-x C-b to ibuffer to see it in action:
(global-set-key (kbd "C-x C-b") 'ibuffer)
Helm - an incremental narrowing and selection framework useful to find just about anything (buffers included).
Check ido-mode. C-x C-b is the old way.
The ido lets you interactively do things with buffers and files.
I have used emacs for erlang programming. According to http://emacswiki.org/emacs/CompileCommand, I have configure c-c c for recompile.
In the emacs frame, 6 windows are open, top 3 are for erlang source code reading and writing.
In the below windows, one is supposed for the compie window.
But when different windows is active and recompile, the compile window will switch randomly. How to fix it in one perticular window?
If you start reading at C-hf display-buffer RET (or in the manual at M-: (info "(elisp) Choosing Window") RET), you'll find a bunch of ways in which you can modify the behaviour.
It can get a little complex, but something like this might be all you need in your recompile function:
(let ((display-buffer-overriding-action
'(display-buffer-reuse-window)))
(compile))
I always use dedicated windows when I want to keep things in the one place, so you might also find that useful to look into:
M-: (info "(elisp) Dedicated Windows") RET
I use the toggle-window-dedicated function from Pin Emacs buffers to windows (for cscope) (see also How do I make this Emacs frame keep its buffer and not get resized?)
I'm new to Emacs. I'm confused about the C-x o command. This command will move the focus to the other window. If I have many windows, which window will be selected as the target? What's the quickest way to do this?
Thanks
"When there are more than two windows, this command moves through all the windows in a cyclic order, generally top to bottom and left to right." - Emacs Manual
http://www.gnu.org/software/libtool/manual/emacs/Other-Window.html
C-x o is as quick as any other if you just have two windows. When you have more than 2 windows though, it can be a pain getting to the one you want using C-x o.
The quickest way to move to a particular window to the left/right/top/bottom of the current window is Wind Move. It comes with Emacs 21 and above. You can use Shift + arrow key to move to a window.
http://www.emacswiki.org/emacs/WindMove
First you've got to notice that "window" in Emacs slang means not what you may think it means. What is normally called a window is called "frame" in Emacs. What Emacs calls "window" is a split window inside a frame.
The easiest way to understand what C-x o does is by trying it out yourself.
In a running Emacs instance, first type C-x 2. Now the frame is split vertically into two windows. The cursor ("point") is in the upper of the two windows. Now type C-x 3 and you will have split the upper window horizontally again. All in all you've got three windows now.
Now type C-x o repeatedly to cycle through the different windows. That's it.
Once you've gotten used to the order in which the windows are cycled through, you can do multiple hops at once, thereby skipping some windows, by using the key combination together with a prefix argument. So say, you want to skip one window and thus jump two at once, type C-2 C-x o. This way you can quickly jump to the window you want.
(To return to a single window, type C-x 1.)
C-x o cycles though your opend windows in current frame. If you often have many opend windows, have a try of dim switch window. It displays window index visually and you can switch to a window using its index.
In case such people like me brows the web with research engines to simplify the switching between more than one window I suggest this bindings key configuration (to put in your init file):
(global-set-key [s-left] 'windmove-left)
(global-set-key [s-right] 'windmove-right)
(global-set-key [s-up] 'windmove-up)
(global-set-key [s-down] 'windmove-down)
It bind windows direction switching to super (windows key) + arrows key direction. These case should come unbound.
EDIT
(windmove-default-keybindings 'super) is simpler code thanks to #phils comment below.
BTW if you work with gnome these keys might be bound to some windows moves so you'll have to change it.
How can I modify the way emacs picks which buffer to show after closing a buffer?
When I have multiple columns showing the same buffer, and then open another file in one of the buffers and then close the newly opened buffer, it doesn't switch back to the previous buffer, but to another buffer.
I'll try to explain with an example:
Start with a new emacs at *scratch*
C-x 2 (split into two columns)
C-x C-f 1 (find file 1)
C-x o (switch to other frame)
C-x b 1 (find file 1)
C-x C-f 2 (find file 2)
C-x k (kill buffer)
Now it switches to scratch but I would like it to show 1 in both windows again, is it possible to make emacs behave this way?
This may not be a direct answer to your question, but it might help.
Emacs manages its buffer list, including deciding which buffer gets displayed when you kill one (via kill-buffer). I haven't looked into how it's done, but the documentation is "out there". Lots of people have created custom buffer-stack management magic to change the way emacs does things, maybe some of them are based on bayesian analysis, or whatever. You can imagine the possibilities.
I've never looked into changing the way emacs manages its buffers. Instead I just bind other-window and switch-to-buffer to easy keystrokes (C-x o, C-x b) and I get really good at using them.
you could create a simple function for what you want: it should destroys all other windows, then split the window so that the current buffer is displayed in both. Luckily, emacs has functions that do exactly those things.
(defun cheeso-show-buffer-two-windows ()
"Close all other windows; then split, and show the current
buffer in both windows."
(interactive)
(delete-other-windows)
(split-window-vertically))
Bind that to a keystroke, and badda-bing, you're there. This is a vertical split - the windows are displayed in a vertical stack. If you want it horizontally split (the windows are side-by-side), then replace ... well, you know.
This also doesn't quite help directly, but Winner mode might help you get where you want to get.
Are you using tabbar-mode? I had the same problem and for me tabbar was the cause. Tabbar adds the function tabbar-buffer-kill-buffer-hook to kill-buffer-hook. You can remove it with (remove-hook 'kill-buffer-hook 'tabbar-buffer-kill-buffer-hook).
If you don't use tabbar try M-x describe-variable kill-buffer-hook. One of the functions in this list should be responsible for messing with your buffers.