I've recently started using C-x <left> and C-x <right>. Those are both standard Emacs bindings—nothing to configure. Left takes you back to the previous buffer (initially the same as C-x b RET) but doing it again takes you to the 3rd most recently visited buffer. If you're popping back and forth between 3 or 4 buffers a lot then I find it a lot ...
There is ido mode that should help.
put this in your init file, to activate ido mode by default:
Now, C-x b will show you a list of candidates.
Put this in your init file, if you prefer the items being displayed vertically:
(setq ido-separator "\n")
Courtesy of ergoemacs
Let me also suggest this post talking about switch to ...
After running recover-this-file and accepting the autosave version, you'll have a modified buffer containing the autosave contents. At this point you can use M-x diff-buffer-with-file RET to see the differences between the modified buffer and the saved file.
The key I've bound for this actually runs a custom function, in order to produce a unified diff, and ...
Emacs predates contemporary window-based operating systems, so its
terminology also predates the current terms. Unfortunately, it means that new users and experienced users sometimes have trouble making themselves understood to each other, since they're using the terms in different ways.
"Frames" are to Emacs what "windows" are to everything ...
Sticking to built-in Emacs commands, you can use multi-occur or multi-occur-in-matching-buffers (M-x multi-occur- TAB RET). multi-occur gives you fine control by prompting for each buffer to use, but it's tedious. multi-occur-in-matching-buffers lets you enter a regexp to match file names (it only searches in buffers that are visiting files); enter . as the ...
Unfortunately, this exact behavior isn't possible in Emacs <= 24.3, but you can save on window/buffer change using defadvice (as detailed on bbatsov's blog):
(defadvice switch-to-buffer (before save-buffer-now activate)
(when (and buffer-file-name (buffer-modified-p)) (save-buffer)))
(defadvice other-window (before other-window-now activate)
A lot of things in Emacs operate on the current buffer. You need to change the current buffer and restore it when you're done. Use with-current-buffer for simple cases where you just need to do something in another buffer, and save-current-buffer for more complex cases where you need to navigate between several buffers.
(defun buffer-string* (buffer)
You want the command M-x diff-buffer-with-file. See the manual:
diff-buffer-with-file is an interactive autoloaded compiled Lisp function in `diff.el'.
(diff-buffer-with-file &optional BUFFER)
View the differences between BUFFER and its associated file.
This requires the external program diff to be in your exec-path.
You may also be ...
Here's another, simple alternative that doesn't require recentf. Hooking the first function into kill-buffer-hook will push the filename associated with the buffer onto a list. (Note that, if you kill a buffer that's not visiting a file, it's gone for good.) The latter function pops that file off of the list and visits it:
(defvar killed-file-list nil
How do you know that the buffer is not narrowed?
Unless you have widened it right before you called the function, you cannot be sure.
Moreover, "great software" is often defined as "being used in ways the author has never envisioned" - so one should always be prepared for the unusual use of one's code.
Code readability is King
When you write (goto-char 1),...
Have you tried erase-buffer?
erase-buffer is an interactive built-in function in `C source code'.
Delete the entire contents of the current buffer.
Any narrowing restriction in effect (see `narrow-to-region') is removed,
so the buffer is truly empty after this.
How to find such a function? M-x apropos buffer erase
window-buffer returns the buffer currently displayed by a given window.
get-buffer-window, on the contrary, returns a window currently displaying the given buffer (or nil if there is no such window; play with the optional 2nd argument to tell it how to behave in cases where you have multiple frames).
With these two ingredients, you should be able to ...
I second @Nsukami's suggestion to use dedicated windows. Since it is a function, not a command, using set-window-dedicated-p directly can be cumbersome. With the following command and associated key binding, you can toggle "dedicatedness" of any window by pressing C-c t:
(defun toggle-window-dedicated ()
"Control whether or not Emacs is allowed to display ...
It is possible to configure how a buffer opens (in the same frame/window or a different frame/window) using display-buffer-alist. Refer to the references below to learn more about this variable.
We need to tell emacs to always open buffers ending with COMMIT_EDITMSG in a window but not in the same (*magit ..*) window.
Add the following snippet to ...
This does require a custom elisp function unless the minor mode has a (global-*-mode) function attached to it.
Luckily, it is a pretty simple function:
(defun global-disable-mode (mode-fn)
"Disable `MODE-FN' in ALL buffers."
(dolist (buffer (buffer-list))
(funcall mode-fn -1))))
To use (for ...
As @Sigma's answer mentions, you need to customize ibuffer-formats. The docstring gives a lot of details about how to modify it by hand, and also notes that you can use the customize machinery to tinker with it. If you prefer the elisp approach, you can adapt the default settings to your taste, with the numbers after the name component of the list ...
To complement sds's answer (with which I fully agree), despite appearances, (point-min) can be more efficient than 1. In terms of execution speed, my tests don't see any measurable difference, but in terms of size:
ELISP> (byte-compile '(lambda () (goto-char (point-min))))
#[nil "eb\207"  1]
ELISP> (byte-compile '(lambda () (goto-char 1)))
Here's a defun that would do what you are looking for:
(defun toggle-window-split ()
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
Try replacing the code for setting the font size with this:
(set-face-attribute 'default nil :font "DejaVu Sans Mono-14")
(set-face-attribute 'mode-line nil :font "DejaVu Sans Mono-10")
Of course, you'll want to change the sizes (14 and 10) to values of your liking.
If you want to customize a specific face and don't know the name of it, try doing
To see and edit multiple locations of the same buffer. So, you don't have to scroll a long buffer but simply switch window to visible region. Each cloned buffer also has different mark ring, narrowing and other buffer properties. If you don't use indirect buffer but create another window of the same buffer, then everything is shared and you cannot perform ...
Remove the corresponding function from the relevant variable :
(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
How did I find this ?
kill-this-buffer uses kill-buffer internally, which references the variable kill-buffer-query-functions.
ediff-current-file is an interactive autoloaded Lisp function in
Start ediff between current buffer and its file on disk.
This command can be used instead of `revert-buffer'. If there is
nothing to revert then this command fails.
By convention, those special names are used for buffers that are not associated directly to a file, but are used to provide the user with a view of some activity that happens in Emacs.
Amongst other things this includes:
emacs-lisp evaluation buffers
buffers for interaction with sub-processes
network-related buffers (IRC, messages, ...)
buffers that ...
Running the command ibuffer-auto-mode in an Ibuffer buffer makes it refresh the display after each interactive command.
There doesn't appear to be a direct way of activating it automatically. You can put this in your init file:
(add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode 1)))
I keep the Emacs manual and Elisp manual on speed dial for questions like these.
From the Elisp manual on indirect buffers:
Function: buffer-base-buffer &optional buffer
This function returns the base buffer of buffer, which defaults to the current buffer. If buffer is not indirect, the value is nil. Otherwise, the value is another buffer, which is ...
Instead of add another function to kill all dired buffers, I suggest you take advantage of filter groups in ibuffer, it allow you to group buffer by many condition.
Here is a example to set filter groups:
;; I create a group call Dired, which contains all buffer in dired-...