Killing buffers whose names start with a particular string

前端 未结 6 1041
太阳男子
太阳男子 2020-12-31 05:41

Here\'s my problem: I use Emacs and get lots of buffers that are pretty useless all the time, like *Messages* or *Completions*.

I want to bind \\C-y to close all buf

6条回答
  •  轮回少年
    2020-12-31 06:39

    I found kill-matching-functions prompted me for unmodified buffers, which isn't what I wanted. The function below will kill buffers matching a prefix (as in the title of the question). Not exactly what you wanted, but maybe people like me who come here from Google will find this useful.

    (require 'cl)
    (defun kill-buffers-with-prefix (prefix)
      "Kill buffers whose names start with the given prefix"
      (interactive "sPrefix to kill: ")
      (loop for buffer in (buffer-list)
            do (if (string-prefix-p prefix (buffer-name buffer))
                   (kill-buffer buffer))))
    

提交回复
热议问题