Emacs缓冲区循环:避免划伤和消息缓冲区 [英] Buffer cycling in Emacs: avoiding scratch and Messages buffer

查看:143
本文介绍了Emacs缓冲区循环:避免划伤和消息缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经打开了缓冲区循环,将以下命令放在我的.emacs中。

Hi I have turned on buffer cycling placing following commands in my .emacs

(global-set-key (kbd "<C-tab>") 'bury-buffer)

但骑自行车时如何避免骑自行车通过消息和scrbatch缓冲区,
始终存在于任何emacs缓冲区列表中。我从来没有使用那些缓冲区,并且在循环浏览我的缓冲区列表时变成一个眼睛

But while cycling how do I avoid cycling through the Messages and the scrratch buffers which are always present in any emacs buffer list. I never use those buffers and become an eye-sore when cycling through my buffer-list

推荐答案

使用临时缓冲区,只需将其添加到.emacs中即可自动关闭它:

If you never use the scratch buffer, just add this to your .emacs to automatically close it:


(kill-buffer* scratch *)

(kill-buffer "*scratch*")

我还发现 Emacs wiki 中的这段代码应该做你想要的:

I also found this code on the Emacs wiki which should do what you want:

; necessary support function for buffer burial
(defun crs-delete-these (delete-these from-this-list)
  "Delete DELETE-THESE FROM-THIS-LIST."
  (cond
   ((car delete-these)
    (if (member (car delete-these) from-this-list)
        (crs-delete-these (cdr delete-these) (delete (car delete-these)
                                                 from-this-list))
      (crs-delete-these (cdr delete-these) from-this-list)))
   (t from-this-list)))
; this is the list of buffers I never want to see
(defvar crs-hated-buffers
  '("KILL" "*Compile-Log*"))
; might as well use this for both
(setq iswitchb-buffer-ignore (append '("^ " "*Buffer") crs-hated-buffers))
(defun crs-hated-buffers ()
  "List of buffers I never want to see, converted from names to buffers."
  (delete nil
          (append
           (mapcar 'get-buffer crs-hated-buffers)
           (mapcar (lambda (this-buffer)
                     (if (string-match "^ " (buffer-name this-buffer))
                         this-buffer))
                   (buffer-list)))))
; I'm sick of switching buffers only to find KILL right in front of me
(defun crs-bury-buffer (&optional n)
  (interactive)
  (unless n
    (setq n 1))
  (let ((my-buffer-list (crs-delete-these (crs-hated-buffers)
                                          (buffer-list (selected-frame)))))
    (switch-to-buffer
     (if (< n 0)
         (nth (+ (length my-buffer-list) n)
              my-buffer-list)
       (bury-buffer)
       (nth n my-buffer-list)))))
(global-set-key [(control tab)] 'crs-bury-buffer)
(global-set-key [(control meta tab)] (lambda ()
                                       (interactive)
                                       (crs-bury-buffer -1)))

您将需要将零碎缓冲区添加到变量 crs-hated-buffers ,例如:

You will need to add the scratch and message buffers to the variable crs-hated-buffers, e.g.:

(add-to-list 'crs-hated-buffers "*Messages*")
(add-to-list 'crs-hated-buffers "*scratch*")

这篇关于Emacs缓冲区循环:避免划伤和消息缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆