gpt4 book ai didi

emacs - Emacs 中的缓冲区循环 : avoiding scratch and Messages buffer

转载 作者:行者123 更新时间:2023-12-02 11:57:36 25 4
gpt4 key购买 nike

您好,我已打开缓冲区循环,并将以下命令放入我的 .emacs

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

但是在循环时如何避免循环遍历消息和临时缓冲区始终存在于任何 emacs 缓冲区列表中。我从不使用这些缓冲区并变得令人眼花缭乱当循环浏览我的缓冲区列表时

最佳答案

如果您从不使用暂存缓冲区,只需将其添加到 .emacs 中即可自动关闭它:

(kill-buffer "*scratch*")

我还发现了this codeEmacs wiki这应该做你想做的事:

; 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,例如:

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

关于emacs - Emacs 中的缓冲区循环 : avoiding scratch and Messages buffer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7699870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com