Skip to main content

Questions tagged [kill-buffer]

Filter by
Sorted by
Tagged with
1 vote
2 answers
174 views

How to ask for confirmation before killing any new modified buffer?

What's the best way to prompt for confirmation before killing any modified buffer, including new buffers created by evil-buffer-new, which creates a buffer without an associated filename. Modified ...
0 votes
2 answers
619 views

How to get kill-buffer-hook to detach a screen session prior to kill-buffer?

I keep many screen session running in the backgroud, which I access with M-x eshell-command "screen -r <myscreen>". Before I kill the *screen* buffer, I have to detach the session with C-a d. ...
0 votes
1 answer
83 views

How can I make closing *Help* kill the buffer?

When I close *Help* by using the GUI it leaves my screen and seemingly buries the buffer, but it does not kill it. To kill it, I need to manually C-x k it. How can I make closing *Help* in the GUI ...
1 vote
0 answers
56 views

how to get emacsclient to behave like emacs?

I don't like that emacsclient keeps buffers open. Is there a way so when I C-x C-c out of a session, it behaves like a regular emacs instance and kills all associated buffers? It'd also be nice if ...
1 vote
3 answers
6k views

Removing buffers from buffer list

This is my first day on Emacs, and I am really liking it so far, but I cannot seem to be able to work correctly with buffers. I am trying to kill specific buffers with C-x k, however upon checking the ...
-1 votes
2 answers
49 views

interactively prompt for a list (or regex) rather than just a single item

I have a function to kill buffers matching a given regex: ;; Like kill-matching-buffers, but doesn't prompt every time. ;; TODO: get this to use vertico (defun kill-matching-buffers-just-do-it () &...
1 vote
1 answer
271 views

Never prompt me again with the words "Buffer modified"

I would like to know how I can never again be prompted when I invoke the command kill-this-buffer with the words Buffer <name> modified; kill anyway? I would thus like to kill the buffer ...
0 votes
0 answers
33 views

How to kill process similar to kill buffer

Whenever I run into infinite loops in a script and it produces a lot of output, C-c C-c (comint-interrupt-subjob) does not reach the process and cannot be killed; being over SSH hangs communication as ...
1 vote
1 answer
815 views

How to make :q, in spacemacs' evil mode, kill the buffer and delete the window, but not kill Emacs?

How can I make :q in spacemacs' evil mode, kill the buffer and delete the window, but not kill Emacs? Coming from VI, the habit of closing with :q/:wq or ZZ/ZQ doesn't translate very well into Emacs. ...
5 votes
2 answers
2k views

How do i close the *compilation* buffer without visitinig its window?

I like to work with a vertically split frame with code in both windows. When i call M-x compile the *compilation* buffer shows in the other window (wich is fine as M-g n would show problematic code in ...
2 votes
1 answer
311 views

Kill buffers in *Buffer List* by file path

I have a lot of buffers in *Buffer List*. a.hs 1708 Haskell ~/src/my-project/src/a.hs b.hs 581 Haskell ~/src/my-project/src/b.hs c.hs 1711 Haskell ...
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 (...
1 vote
4 answers
2k views

How to kill magit-diff's buffers on quit?

After making a commit in magit, magit will leave around a magit-diff buffer containing just: Staged changes (empty) [back] This is pretty useless and clutters up my buffers, and I'd just like that ...
1 vote
1 answer
132 views

How to automatically open the debugger whenever `kill-buffer` is invoked?

I'm using Elpy for Python development, and when I run code with C-c C-c the source buffer closes -- which I don't want. Have to constantly reopen. One idea is to set a breakpoint in kill-buffer - ...
1 vote
2 answers
633 views

How to kill all buffers except the buffer current one and *other*?

I use this: (defun kill-other-buffers () "kill all other buffers." (interactive) (mapc 'kill-buffer (delq (current-buffer) (buffer-list)))) I need to add one more buffer
0 votes
0 answers
239 views

Kill buffers - how to make *scratch* and *Messages* last

Any setting I can use to get back the old behavior where killing a buffer I get to the next buffer for the files I have given on the command line? I have been using Emacs like this for years Open ...
0 votes
0 answers
141 views

How to kill a transient buffer?

I'm a emacs 28.0.50 user (compiled by my own) and my config is based on spacemacs v0.200.8 I've noticed that, when I'm on a transient buffer and type 'q', the buffer goes away but still in my buffers ...
7 votes
3 answers
909 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]...
2 votes
1 answer
690 views

force kill a buffer?

I have a buffer (belonging to ein mode that got into a bad state) that throws an elisp error every time I try to kill it (using ibuffer, M-x kill-this-buffer, etc.) Backtrace suggests that the buffer ...
0 votes
0 answers
32 views

How to find what is creating and killing so many buffers?

A bunch of creating and killing buffers in my setup and I can't track down what is it. Here is my debug code: (add-hook 'kill-buffer-hook (lambda() (message "Killed: %s / %s" major-mode (...
4 votes
3 answers
2k views

Killing current buffer reliably

I try to add a nicer key binding to kill the current buffer. An obvious solution is to use kill-this-buffer, but often it does not work, or e.g. does not work the first time. The key binding for it ...
2 votes
2 answers
298 views

How select and kill desire many buffers in ido mode?

Emacs 26.1. ido, smex If I want to kill one buffer I use command C-x k Here result: As result I can kill ONE desire buffer. But suppose I need to kill the next buffers: build.gradle, approfile....
1 vote
1 answer
404 views

How to return focus to dired window after killing buffer opened from dired?

Sometimes I use dired to view or edit several files in one folder, one after the other. Dired is open in one window, and I open the files in another window by typing o in dired. When I finish with one ...
6 votes
1 answer
866 views

How to automatically kill a shell buffer when the shell process exits

In shell-mode when you exit the shell process (e.g. by typing exit) the buffer still hangs around (with the message "Process shell<1> finished"). How can I automatically kill the shell buffer when ...
2 votes
1 answer
308 views

Elfeed - Kill buffers on quit

I've been using Elfeed for some time, and I like it very much. However, there is one small thing I'd like to adjust. When leaving the search window (with elfeed-search-quit-window bound to q in the ...
0 votes
1 answer
577 views

is there a way to kill buffers when using the `switch-to-buffer` view

when using C-x b followed by TAB, a list of buffers are brought up. Is there a way to quickly kill the buffers that are not needed (by pressing <delete> or d) on the selected buffer?
2 votes
2 answers
258 views

replace-buffer-in-windows issues in switching from emacs 24.5 to emacs 25.2

I installed Emacs 25.2 on a new system and cannot get the desired behavior with killing buffers when an Emacs frame is split into multiple windows. For example, I have C-x 3 bound to a variation of ...
2 votes
1 answer
121 views

Kill default buffer (with cursor)

Windows 10, Emacs 25.1, Helm I open 3 buffers (3 files). Show only 2 buffers. As you can see the current buffer is my_buffer_1 because cursor is in this buffer. I want to kill this current buffer. ...
2 votes
1 answer
110 views

How do I kill all buffers that were opened from browsing rgrep results?

I had a set of buffers open that I want to keep. Then I started a search with M-x rgrep (SPC f g on Spacemacs). While browsing results with n and p, each file containing a result is opened in a new ...
4 votes
1 answer
1k views

server-edit vs kill-buffer to kill an emacsclient buffer

I use emacsclient to open files from my webrowser (pdfs, text files etc). When I'm done with the file, I know I need to close it with C-x # (server-edit); if I use C-x k (kill-buffer) I get a warning ...
1 vote
1 answer
207 views

emacs split window doesn't avoid other pane content

I'll get terminology wrong here, so be gentle with that (only). cd ~/src/ ./emacs * C-x 2 So I've got two windows here, one above the other, and a bunch of files in my buffer list (more than 2). ...
4 votes
2 answers
758 views

Delete word backward without coping it to buffer [duplicate]

(I feel like there should be duplicate for this, but I could not find it. Pardon me.) Question How can I delete word backwards without it being copied to buffer? Explanation I developed a habit of ...
0 votes
1 answer
219 views

undo-kill-buffer and save-place-mode

I use this function to reopen a file killed by mistake. (defun undo-kill-buffer () (interactive) (let ((active-files (loop for buf in (buffer-list) when (buffer-...
39 votes
6 answers
7k views

How to reopen just killed buffer, like C-S-t in Firefox Browser?

Sometimes I accidentally kill a buffer and want to reopen it, just like C-S-t to undo closed tab in Firefox, but there is no built-in command in Emacs, the defun undo-kill-buffer in http://www....
1 vote
1 answer
236 views

Want to select asterisk buffers after killing the current buffer

I am facing the question about the buffer selected after killing the current buffer. When I kill the current buffer, the recent file buffer is selected ignoring asterisk buffers. Unless there are no ...
0 votes
2 answers
472 views

kill-process doesn't kill process

Why does the following sexp hang? (let ((buf "*Async Shell Command*")) (async-shell-command "cat") (while (get-buffer-process buf) (message "still has proc") (kill-...
1 vote
2 answers
82 views

Reload single file in every window

I have this function that reload a file but it don't work when I have same buffer opened in 2 different windows: (defun reload () "Reload a file it will kill buffer, open file again and jump to ...
2 votes
1 answer
62 views

How modify this function, that it will detect the visibile buffers in all windows?

I found a function, that will kill all buffers except the current buffer that's open. (defun kill-other-buffers () "Kill all buffers but the current one. Doesn't mess with special buffers." (...
0 votes
1 answer
220 views

Adding to kill-buffer-hook results in "setq: Wrong type argument"

Subtract a buffer's (the file's) size from a variable before killing it. Emacs 26. (defvar cumulative-open-bytes '0 ) (defun buffer-settings-calc-bytes () (interactive) (let ((current-open-file-...
3 votes
3 answers
1k views

Dired-like browser for buffers?

I use Spacemacs, and I often use SPC b b to list buffers so that I can kill the buffers I no longer want. Unfortunately, this process takes a while because I have to repeatedly press SPC b b, navigate ...
3 votes
1 answer
466 views

How to kill all duplicates of the current frame

The command make-frame creates a duplicate frame of a given frame. Is there a reverse command which kills all duplicates (if any) of the current frame? More precisely assume that the current frame ...
3 votes
3 answers
694 views

Rename scratch buffer and ask confirmation to kill non-file buffers created by user

I tend to use often non-file buffers kinda like post-it-notes and it is way too easy to kill them inadvertently, as there is no confirmation to kill. Even if you enforce the habit of writing only in ...
1 vote
1 answer
121 views

Detect interactive use of `kill-buffer` in `kill-buffer-hook`

As per title, I want to define a kill buffer hook with the variable kill-buffer-hook and the function should be able to detect when (kill-buffer ) has been called interactively. Is this possible? ...
0 votes
1 answer
270 views

How to override default keybindings?

I am new to the world of Emacs, so please forgive me if my question is too trivial. I am trying to use standard console keybindings for Emacs too, by editing the configuration file. A few of them are ...
1 vote
3 answers
2k views

kill-buffer with y-or-n-p instead of yes-or-no-p

Q:  How can I use y-or-n-p -- instead of yes-or-no-p -- when calling kill-buffer for just the duration of a particular function? In other words, I want the behavior of (fset 'yes-or-no-p 'y-or-n-p) ...
1 vote
2 answers
4k views

How can I close the current frame upon killing a buffer if that frame was only opened for it?

When I open a file in Emacs.app, via Finder, via the edit-server or during merging on an SVN update, it shows up in a new frame. When I kill that buffer, I pretty much always also want close the frame ...
2 votes
1 answer
882 views

How can I delete all the gdb related windows/buffers after `q` in gdb CLI window

I use (setq gdb-many-windows t) and (setq gdb-show-main t) configurations in my init.el, so after executing M-x gdb, there will be six windows in the frame, after typing q in the main gdb cli window ...
8 votes
2 answers
429 views

Kill-buffer prompt with option to diff the changes

The save-some-buffers command prompts to save or ignore each modified file, and also provides an option to diff the modified file against the file it is visiting. I'd like the same behavior from kill-...