You can do this with Helm
by entering a partial major-mode name prefixed with *. For example: *lisp, *sh etc. You can also use negation, e.g. !*org
to narrow down all non-Org mode buffers, or specify multiple
major modes, e.g. *!lisp,!sh,!fun etc.
Then press M-a to mark those buffers and M-D to kill them.
For example, to kill all dired buffers:
Just following up I ended up going with a simplified version of the example code (https://github.com/emacsorphanage/god-mode#change-modeline-color) and adding cursor change:
;; Update cursor
(defun my-god-mode-update-cursor ()
(setq cursor-type (if (or god-local-mode buffer-read-only)
If you use Icicles then, with any command that completes against buffer names, you can filter (include or exclude) the candidates by mode (either exact mode match or derived-mode-p).
And with Icicles you can act on all matching candidates at once, with C-!.
If you use a plain prefix arg (C-u) with a command with buffer candidates then the candidates are only ...
You can use M-x ibuffer which I recommend binding to C-xC-b to replace the default (or whatever binding you prefer).
Use %m to mark buffers by matching a regexp against the displayed mode-name (e.g. Emacs-Lisp). Then use D to kill the marked buffers.
"notmuch-" or "[Notmuch]"
Note that, as we're dealing with regexps, you would need to ...
In general, if you don't know the exact name of the buffer, you need to call buffer-list to obtain the list of buffers and filter the result to only act on the desired buffer(s).
(defun erase-buffers-matching (regexp)
"Erase the content of all buffers whose name matches REGEXP."
(interactive "sErase buffers matching: ")
If this is something you want to do often, you could define a function for it in your .emacs file. Otherwise you could type it out in scratch, evaluate it and then assign it a key binding?
You could try:
(defun my/clear_buffer ()
(let ((tmp (buffer-name)))
(if (get-buffer "<buffer name>") ;; check if buffer ...
I think you have to write a tiny bit of Lisp. Type the following into M-: (M-x eval-expression). You don't need line breaks, they're just for readability.
(with-current-buffer "name of buffer"
(let (kill-buffer-hook kill-buffer-query-functions)
In this particular case, C-u M-x shell helps by giving each shell buffer a unique name, using a counter that increments every time.
If you want to give them more meaningful names, M-x rename-buffer RET foo RET will do the deed.
They're "visited" in the order given, and the buffer list you see sorts them (by default) by order of "recency".
But you can sort them some other way, such as alphabetically: move the cursor into the column of buffer names and press S to sort them by their name.
I found this solution in the following way:
- C-h m showed me the description of buffer-menu-...
Probably the easiest way to do this is to use emacs-client to run the compilation inside a *compilation* buffer:
utman emacs-client --eval '(compile "make debug unit test")'
utman is my script to watch for changes in source files and then run the rest as command: https://github.com/thoni56/utman, but that could be replaced with any file-watcher, or ...