Questions tagged [kill-buffer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
37
votes
6answers
5k 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....
18
votes
4answers
3k 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 (...
8
votes
2answers
265 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-...
6
votes
3answers
394 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]...
5
votes
1answer
383 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 ...
4
votes
1answer
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 ...
4
votes
1answer
1k 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 ...
3
votes
3answers
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
3answers
575 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 ...
3
votes
1answer
356 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 ...
2
votes
1answer
103 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
2answers
504 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 ...
2
votes
1answer
56 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." (...
2
votes
3answers
521 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
1answer
88 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 ...
2
votes
1answer
715 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 ...
2
votes
1answer
140 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 ...
2
votes
2answers
219 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
1answer
188 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 ...
1
vote
3answers
1k 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
1answer
97 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? ...
1
vote
4answers
1k 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
1answer
81 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
2answers
66 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
1
vote
1answer
159 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). ...
1
vote
2answers
216 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
1answer
139 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 ...
1
vote
2answers
61 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 ...
1
vote
2answers
2k 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 ...
1
vote
2answers
30 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 ...
1
vote
1answer
110 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 ...
0
votes
2answers
2k 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 ...
0
votes
1answer
172 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 ...
0
votes
2answers
344 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-...
0
votes
1answer
149 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?
0
votes
1answer
141 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-...
0
votes
1answer
158 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-...
0
votes
0answers
21 views

Why I keep receiving a message about inferior-lisp running after quiting the REPL?

I am developing an application using Slime and SBCL. My OS is Ubuntu 20.04 LTS. I am new to the Common Lisp, SBCL, Slime, and Emacs universe. I load the application with ,, then load-system and, ...
0
votes
0answers
43 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
0answers
43 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 ...
0
votes
2answers
207 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
0answers
30 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 (...