Questions tagged [buffers]

The text you are editing in Emacs resides in an object called a buffer. Each time you visit a file, a buffer is used to hold the file's text. Each time you invoke Dired, a buffer is used to hold the directory listing.

Filter by
Sorted by
Tagged with
28
votes
2answers
5k views

What's the difference between a buffer, a file, a window, and a frame?

When posing questions on this site, people sometimes talk about "windows" when they mean "frames," and "buffers" or "files" when they mean "windows." So: Q: What is the difference between a buffer, ...
4
votes
2answers
2k views

How to modify-face for a specific buffer?

I work with a lot of tabular data files and use stripe-buffer.el make them easier to read. But I also work with more than one, so I'd like to make it easier to distinguish among them as well and want ...
12
votes
2answers
2k views

How do I force a specific buffer to open in a new window?

When committing changes in Magit, it is useful to have the diff view open while adding details about the commit. In Magit, we see the diff in the *magit ..* buffer. When you hit cc while the cursor ...
10
votes
2answers
703 views

make `previous-buffer` and `next-buffer` to ignore some buffers

in Helm I ignore some buffers from showing when using C-x b, I'm looking for a way to make the commands previous-buffer and next-buffer behave the same ignoring some buffers.
12
votes
3answers
774 views

Kill buffer when frame is deleted

When I close a frame, I'd like for its buffer to be killed. If the buffer is displayed in other frames, the buffer should not be killed. Do nothing if more than one buffer is displayed in a frame. ...
8
votes
3answers
834 views

Highlighting text in open (displayed) buffers/windows — searching for text from one buffer in another

Right now, I have my Emacs frame vertically split, and am looking at two different buffers in the two windows. I'd like to go to a word in one buffer, hit some keys, and have the ocurrences of that ...
70
votes
18answers
33k views

How do I switch buffers quickly?

In vanilla Emacs, I have to do C-x b and then manually type out the buffer name to switch. If I forget the name of the buffer, I have to hit TAB to list possible completions. Is there anything I can ...
51
votes
1answer
2k views

How to view diff when emacs suggests to recover this file?

Sometimes it happens: emacs prompts you about recovering unsaved changes to a file, but you cannot remember if you want those changes or not. Starting at the recover-this-file buffer, is there a way ...
23
votes
8answers
4k views

Close all dired buffers

Sometimes my buffer list has 10+ dired windows, and I end up using buffer-menu to manually mark and kill all of them. Is there a faster way to close all open dired windows?
14
votes
2answers
2k views

How can I prevent a command from using specific windows?

Typically, I have a frame split into four windows, where two at the bottom are dedicated to my *compilation* and *grep* buffers. When browsing compilation errors, next-error will eventually replace my ...
17
votes
2answers
2k views

Kill process buffer without confirmation?

I have C-x C-k bound to kill-this-buffer. But when I enter into a buffer which is running a process like Python or MySQL, if I do C-x C-k it asks Buffer "*Python*" has a running process; kill it (...
13
votes
6answers
787 views

how to get buffers (not just files) to honor auto-mode-alist?

Q: how can I get new buffers to honor the mapping in auto-mode-alist? When finding a file, Emacs compares the file extension to the auto-mode-alist to determine which major mode to use for the file's ...
16
votes
1answer
2k views

How to know my buffer's visible/focused status?

I'm writing an extension that talks to an outside process, so it is a given to lower the amount of 'hey whats up' requests when my buffer isn't focused. So, what is the best way to recognize: When ...
13
votes
2answers
1k views

How to kill a buffer when it causes Emacs to stop responding? [duplicate]

I use Emacs Dired to manage files. Accidentally, I hit Enter on an image file, Emacs tries to open the image and stop response. Is there a way to kill this process? (Since I am running other ...
5
votes
1answer
447 views

Insert into specific buffer (not the active buffer)?

Is there any way to insert text into a buffer that isn't the active buffer with Elisp? Perhaps there is an equivalent to with-temp-buffer that takes a specific, existing buffer as an argument?
26
votes
4answers
2k views

How to auto-save buffers when Emacs loses focus?

I recently had a Sublime Text user try out Emacs for a while, and he was interested in getting the same auto-save behavior in Emacs. Basically, he wanted all buffers to be saved whenever the frame ...
11
votes
3answers
621 views

How to modify a buffer without undo noticing?

Q: How do I insert/modify text in a buffer without undo noticing? Here's the use case. I have a comment block at the start of every file that, among other things, updates a timestamp for the most ...
7
votes
4answers
10k views

Spacemacs: kill buffer and kill window in one command?

Is there a spacemacs command that both closes the window and kills the buffer? In other words, the equivalent of Vim's :q?
5
votes
2answers
427 views

Workspace configuration

I'm working with Emacs on several different projects with several different languages. I'm seeking for solution that could help manage project as workspace. Meaning Understand language in use and ...
4
votes
1answer
398 views

Let switch-to-buffer to already open buffer switch to that window, rather than open it in this one

Is there a way to make switch-to-buffer more dwim in this regard? Let's say I have two windows with foo.el and bar.el open. With my point in foo.el, if I switch-to-buffer and open bar.el, I'd like to ...
9
votes
2answers
1k views

Single mode line for all windows

Is it possible to have only one mode line (sometimes referred as "statusbar") for all windows? I'd like to make this single mode line show information about the currently selected buffer.
8
votes
4answers
2k views

copy contents of current buffer in a temp buffer and operate on that

I need to copy the contents of the current buffer to a temp buffer, set that buffer to a particular major mode to take advantage of its benefits and get the information I need back to the main logic. ...
8
votes
4answers
1k views

How can I run a keyboard macro in selected buffers from Ibuffer or selected files from dired?

If I have to do some variable name refactoring, I use ag and multiple-cursors. But when I have to do some code block removal/addition/moving, I use keyboard macros. But I need to switch to each ...
7
votes
2answers
803 views

How to persistently move the cursor in a buffer other than the current one?

NB: The post How to move point to the end of another buffer, using `with-current-buffer` and `goto-char`? presumably asks the same question as this one, but the answers given to it do not readily ...
6
votes
1answer
320 views

Why must I set and reset `buffer-multibyte` to correctly view multibyte buffers?

In an ongoing project, we are inserting multibyte text into a buffer and experiencing strange behavior. When the question is first viewed, we receive something like: Quote Environment à la Strunk\...
11
votes
2answers
1k views

How can I make ibuffer auto-refresh the list of buffers?

M-x ibuffer Select a buffer Kill that buffer After the buffer is killed, the ibuffer buffer re-appears, but it still shows the buffer name killed in step 3. Is it possible to have ibuffer auto-...
8
votes
2answers
1k views

Rapidly preview files

Similar to this question, I'd like a tool/minor mode to quickly preview my files by merely having the cursor positioned over them (e.g. the currently selected file is displayed in the active buffer ...
6
votes
1answer
148 views

Clone a buffer to see the same contents in an other mode

Suppose I'm working on a file in org-mode or enriched-mode or html-mode ..., and I wanted to see the same contents in an other window with an other mode, say text-mode, how to do that? I tried to ...
5
votes
0answers
91 views

Why is cloning of file buffers prohibited?

Why does clone-buffer not work on file buffers. I can make it work by the following advice: (advice-add 'clone-buffer :around (lambda (oldfun &rest args) "Allow cloning file buffers." ...
4
votes
1answer
2k views

Programming of Initial-buffer-choice

I need to make a function that will choose an org mode file if emacs was called with no arguments, and basically go about its way otherwise. So far I have (defun personaltodo () (if (= 1 (...
3
votes
1answer
197 views

How to automatically save buffer after each modification without using packages

I'm using Emacs and Windows 10 and I am fairly new to both Emacs and elisp (and I am not a programmer). I'm looking for a way to automatically save a buffer immediately after any modification ...
1
vote
1answer
421 views

Is it possible to change the font size in specific buffers?

I would like to have different font sizes for the buffer windows in Emacs. That is, I would like to have a bigger font in the buffer where i write the code, and a smaller font in the buffer where i ...
1
vote
2answers
289 views

The time of the last change of the current buffer

Can Emacs determine the time of the last change (or the last edit) done to the current buffer? The buffer may has been saved or not.
0
votes
0answers
93 views

open the shell buffer in the same frame as compilation buffer — C compilation

I'm regularly compiling some C programs and one thing is annoying : after I've compiled, I'm opening a shell with M-x shell ./foo, but the shell open in place of the source code's window. I would ...
16
votes
1answer
2k views

Switch window split orientation, fastest way

Say you have two buffers open like so: ------------------------------------ | | buffer 1 | buffer 2 | | | ------...
8
votes
1answer
3k views

Find position in file by character number

When an error occur in compiling a program in Ghostscript, the error message gives a "Current file position is ..." with a number. I use emacs to edit the program file, so I would like to be able ...
6
votes
1answer
225 views

Automatically saving the current file after typing a certain number of characters

Is there a way to force Emacs to automatically save the current file (if it is not already saved) after typing n characters (n is a number determined by the user). Edit: After the comment of @Dan and ...
5
votes
1answer
526 views

Replacing display-buffer-reuse-frames

display-buffer-reuse-frames tells Emacs to re-use frames for displaying buffers. However, as of 24.3 this variable is obsolete (emphasis mine): display-buffer-reuse-frames is a variable defined ...
4
votes
1answer
1k views

Change the default mode used when opening a new buffer

For example, we can open a new buffer with C-x b <new-buffer-name>, and by default, this new buffer opens in fundamental-mode, which is not very useful to me. I would like to change this to open ...
4
votes
1answer
191 views

How to skip some buffers when use prev-buffer/next-buffer? [duplicate]

windows 10, emacs 26.1 Suppose I open 10 buffers. If I can use prev-buffer (C-x left) / next-buffer (C-x right) to go to prev/next buffers. It's very comfortable. But I need when I do this to skip ...
4
votes
2answers
224 views

Something like save-excursion that saves the complete buffer state?

[This question is related to, but not a duplicate of, the question copy contents of current buffer in a temp buffer and operate on that. Besides other incidental things (e.g., the question itself is ...
3
votes
1answer
336 views

How to make persistent buffer list above frame like in vim powerline

I want to implement behavior similar to mine vim config, where all basic info was below the main frame, like modes, position in file, changes, but above the frame is list of all buffers, with ...
3
votes
1answer
893 views

How to open multiple files without automatically activating the “Buffer List” split?

Running emacs with multiple files automatically opens the "Buffer List" split-window. eg: emacs -Q *.txt Opens a split window, one which contains a list of buffers. How can multiple files be ...
3
votes
2answers
226 views

Show the matching line in the center of the screen instead of the bottom when opening a grep result

When I grep something inside emacs and click to open one of the matching files. The matching line is always displayed at the bottom of the screen, and I have to scroll it up for a better view. Is it ...
2
votes
2answers
505 views

How to move point to the end of another buffer, using `with-current-buffer` and `goto-char`?

I'm trying to implement «effective append» for log buffer, e.g. if a point is at point-max position then insert text and move point to new point-max, otherwise append text and preserve point position. ...
2
votes
2answers
130 views

Switch to next buffer under certain circumstances

I have the following line of code in my .emacs file: (global-set-key (kbd "C-<tab>") 'next-buffer) This key-binding allows me to C-<tab> my way around Emacs. However, because of certain ...
1
vote
1answer
288 views

Kill initial buffers

I want to kill some buffers created by default, such as the GNU Emacs, but putting: (kill-buffer "*GNU Emacs*") On the .emacs doesn't work. I guess this code is called before the initial buffers are ...
1
vote
1answer
80 views

How to make man replace the same buffer?

Instead of open many buffers I wish to have the same buffer for all calls to the man.
1
vote
1answer
907 views

how to modify buffer display behaviour?

I use display-buffer-alist to Configure buffer display. For example I have this snippet to display flycheck errors buffer. (add-to-list 'display-buffer-alist `(,(rx bos "*Flycheck errors*...
0
votes
2answers
124 views

quickly switching to a buffer with a particular file name/mode

G'day! it's my "learn some more Elisp" day. I'm trying to make a shortcut that opens my main org file. I've made it this far (global-set-key (kbd "C-c h") 'switch-to-most-recent-org-file) (defun ...