Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
46 votes
2 answers
10k 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, ...
Dan's user avatar
  • 33.1k
9 votes
2 answers
4k 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 ...
wdkrnls's user avatar
  • 3,707
13 votes
2 answers
3k 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 ...
Kaushal Modi's user avatar
  • 25.7k
14 votes
3 answers
2k 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.
shackra's user avatar
  • 2,782
17 votes
2 answers
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 ...
piwi's user avatar
  • 273
15 votes
5 answers
5k views

Revert all open buffers (and ignore errors)

When working on a project under version control with git, I often want to do some things in a shell that affect many of my open files, then revert every buffer that I have open to make sure that I don'...
Patrick Collins's user avatar
14 votes
2 answers
3k 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 ...
Nick's user avatar
  • 4,493
13 votes
3 answers
2k 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. ...
dharmatech's user avatar
  • 1,264
8 votes
3 answers
1k 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 ...
ShreevatsaR's user avatar
7 votes
3 answers
822 views

How can I kill buffers based on mode?

I know about kill-matching-buffers but that searches buffer names, I want instead to search buffer modes. For example, I might want to kill all buffers that have "notmuch-" or "[Notmuch]...
Sandra's user avatar
  • 196
5 votes
1 answer
2k 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 ...
ideasman42's user avatar
  • 8,826
90 votes
25 answers
59k 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 ...
nixeagle's user avatar
  • 2,457
58 votes
1 answer
4k 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 ...
Sparx's user avatar
  • 1,121
26 votes
8 answers
7k 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?
nispio's user avatar
  • 8,235
19 votes
5 answers
4k 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 (...
Chillar Anand's user avatar
19 votes
1 answer
3k 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 ...
Łukasz Gruner's user avatar
14 votes
6 answers
1k 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 ...
Dan's user avatar
  • 33.1k
14 votes
1 answer
7k 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 ...
Harry Weston's user avatar
8 votes
2 answers
2k views

Saving open file list and buffer command history in between sessions

I've discovered desktop-save-mode which allows Emacs to be closed and when it reopens, it appears with the same files that were open before. I want to take this a bit further and I was wondering if I ...
Galder Zamarreño's user avatar
7 votes
1 answer
2k 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?
JCC's user avatar
  • 1,029
7 votes
1 answer
2k 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 ...
Veera's user avatar
  • 305
6 votes
1 answer
2k views

Revert-buffer ---> Discard unsaved changes without y/n prompt

(setq revert-without-query '(".*")) With this extra line in .emacs file, i have configured emacs to revert buffers without any prompt. It doesn't prompt for clean buffers but when the buffer has ...
Saravana's user avatar
  • 2,071
3 votes
1 answer
798 views

org mode not showing all the text in my file?

I am new to Emacs and struggling to learn it. I have a test.org file: * Heading ** Sub-Heading *** Third-level When I open the file, the buffer just displays: * Heading... Where did all the ...
tom_kp's user avatar
  • 81
1 vote
2 answers
390 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 ...
american-ninja-warrior's user avatar
0 votes
1 answer
60 views

Force one window when opening multiple files spacemacs

Looking for the spacemacs answer to this question. How do I have spacemacs open as if I had issued SPC w m (spacemacs/toggle-maximize-buffer)? I thought it might be dotspacemacs-maximized-at-startup, ...
mcp's user avatar
  • 556
29 votes
4 answers
3k 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 ...
b4hand's user avatar
  • 2,025
16 votes
1 answer
2k views

Switch window split orientation, fastest way

Say you have two buffers open like so: ------------------------------------ | | buffer 1 | buffer 2 | | | ------...
c-o-d's user avatar
  • 930
13 votes
4 answers
18k 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?
sid-kap's user avatar
  • 544
12 votes
2 answers
2k 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-...
Kevin Wright's user avatar
12 votes
4 answers
2k 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 ...
Kaushal Modi's user avatar
  • 25.7k
12 votes
3 answers
888 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 ...
Dan's user avatar
  • 33.1k
11 votes
3 answers
5k views

how to name buffers (*shell*)

I'm interested in naming Emacs buffers. In particular I'd like to give names to shell buffers that I've started. That way I can easily tell them apart when switching buffers.
m33lky's user avatar
  • 297
11 votes
2 answers
3k 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.
rgtk's user avatar
  • 414
10 votes
3 answers
2k 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 ...
kjo's user avatar
  • 3,247
8 votes
4 answers
4k 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. ...
Trevoke's user avatar
  • 2,450
8 votes
1 answer
941 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 ...
Bite Bytes's user avatar
8 votes
2 answers
3k 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 ...
wdkrnls's user avatar
  • 3,707
7 votes
1 answer
744 views

How to check, if a file is already visited?

I have the following code, which opens a file, inserts some text, saves the file and closes it. (defun batch (file) (find-file file) (end-of-buffer) (insert "nix") (save-buffer) (kill-...
ceving's user avatar
  • 1,378
6 votes
1 answer
871 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 ...
user avatar
6 votes
0 answers
267 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." ...
Tobias's user avatar
  • 33.3k
6 votes
1 answer
637 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 ...
Name's user avatar
  • 7,871
6 votes
1 answer
565 views

Function like save excursion for restoring buffers?

When I want to do something in another buffer and then restore the original, I currently do this: (let ((this-buffer (current-buffer))) (switch-to-buffer (other-buffer)) (insert "I was here!") (...
24HrRevengeTherapist's user avatar
6 votes
2 answers
474 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 ...
phonycollectibles's user avatar
6 votes
1 answer
437 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\...
Sean Allred's user avatar
  • 6,941
6 votes
1 answer
6k 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 (...
Bronze's user avatar
  • 113
5 votes
1 answer
609 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 ...
a_subscriber's user avatar
  • 4,124
5 votes
2 answers
511 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 ...
Carl's user avatar
  • 81
5 votes
1 answer
2k views

Remapping C-x C-b to Open List of Buffers in Same Window

I use Emacs across different machines and operating systems. I noticed that when I press C-x C-b to get a list of all buffers, on some machines the list opens in the same window where the cursor is ...
MadPhysicist's user avatar
5 votes
1 answer
246 views

How to make "M-x man" buffers use all the available width of the screen?

The problem When opening man in a terminal emulator, man tries to use as much width as possible. However, when opening man inside emacs, man doesn't use all the width (even after Man-update-manpage ...
doltes's user avatar
  • 587
5 votes
2 answers
2k 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 ...
sigrlami's user avatar
  • 151