Killing buffers whose names start with a particular string

前端 未结 6 955
太阳男子
太阳男子 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:25

    To kill all other buffers

    (defun px-kill-other-buffers ()
      "Kill all other buffers."
      (interactive)
      (mapc 'kill-buffer (delq (current-buffer) (buffer-list))))
    

    To search the beginning of a string

    (defun string-starts-with-p (string prefix)
        "Return t if STRING starts with prefix."
        (and
         (string-match (rx-to-string `(: bos ,prefix) t) string)
         t))
    

提交回复
热议问题