Questions tagged [kill-buffer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
28 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. ...
user avatar
1 vote
1 answer
44 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 ...
user avatar
  • 320
1 vote
2 answers
49 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 ...
user avatar
  • 173
1 vote
1 answer
96 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 - ...
user avatar
  • 11
1 vote
2 answers
181 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
user avatar
0 votes
0 answers
80 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 ...
user avatar
  • 11
0 votes
0 answers
61 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 ...
user avatar
6 votes
3 answers
508 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]...
user avatar
  • 185
2 votes
1 answer
240 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 ...
user avatar
0 votes
2 answers
310 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. ...
user avatar
0 votes
0 answers
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 (...
user avatar
2 votes
3 answers
780 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 ...
user avatar
  • 467
1 vote
1 answer
158 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 ...
user avatar
5 votes
1 answer
502 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 ...
user avatar
  • 1,061
0 votes
2 answers
3k 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 ...
user avatar
1 vote
2 answers
236 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....
user avatar
  • 3,435
2 votes
1 answer
209 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 ...
user avatar
  • 636
0 votes
1 answer
230 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?
user avatar
  • 567
2 votes
1 answer
108 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. ...
user avatar
  • 3,435
2 votes
1 answer
98 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 ...
user avatar
1 vote
1 answer
175 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). ...
user avatar
3 votes
2 answers
557 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 ...
user avatar
  • 135
2 votes
2 answers
235 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 ...
user avatar
  • 239
1 vote
5 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 ...
user avatar
  • 1,578
1 vote
1 answer
169 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 ...
user avatar
  • 86
0 votes
2 answers
368 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-...
user avatar
  • 823
2 votes
1 answer
60 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." (...
user avatar
  • 3,715
0 votes
1 answer
173 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-...
user avatar
  • 3
0 votes
1 answer
182 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-...
user avatar
  • 3,016
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 ...
user avatar
  • 484
3 votes
1 answer
383 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 ...
user avatar
  • 7,344
1 vote
1 answer
100 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? ...
user avatar
  • 1,618
5 votes
2 answers
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 ...
user avatar
  • 229
1 vote
2 answers
75 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 ...
user avatar
  • 661
1 vote
3 answers
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) ...
user avatar
  • 17.7k
1 vote
2 answers
3k 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 ...
user avatar
  • 1,163
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 ...
user avatar
  • 20.3k
0 votes
1 answer
197 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 ...
user avatar
18 votes
5 answers
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 (...
user avatar
2 votes
1 answer
756 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 ...
user avatar
  • 2,559
3 votes
3 answers
606 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 ...
user avatar
  • 1,618
38 votes
6 answers
6k 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....
user avatar
  • 2,559
8 votes
2 answers
287 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-...
user avatar
  • 19.2k