【问题标题】:Emacs creates too many buffersEmacs 创建了太多的缓冲区
【发布时间】:2012-03-21 21:51:24
【问题描述】:

Emacs 会创建太多的缓冲区,比如它启动时的缓冲区:

Loading /home/david/.recentf...done
Cleaning up the recentf list...done (0 removed)
For information about GNU Emacs and the GNU system, type C-h C-a.

当我想要自动完成时,其他人喜欢以下内容:

Click <mouse-2> on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
perl-backward-to-noncomment     perl-beginning-of-function
perl-electric-terminator    perl-end-of-function
perl-indent-command     perl-indent-exp
perl-mark-function  perl-mode
perldb

有没有一种方法可以让 emacs 杀死自动完成缓冲区而不是在开始时创建那个缓冲区?谢谢。

【问题讨论】:

  • 我认为它们有时很有用,但是为什么要禁止它们,因为它们通常不会妨碍您。?
  • 您接受的答案太少。
  • 见 harpo 的回答。当您想切换到缓冲区时,不应以线性顺序遍历缓冲区列表。这是非常低效的。只需使用iswitchb,您就不必担心您有多少打开的缓冲区。
  • 当我第一次学习 emacs 时,我遇到了很多关于缓冲区的问题,所以我问了这个问题:stackoverflow.com/questions/3145332/…。那里的很多建议帮助了我,尤其是 ido-mode:emacswiki.org/emacs/InteractivelyDoThings

标签: emacs


【解决方案1】:

当我第一次开始使用 emacs 时,我就有这种感觉。虽然我通常会在完成这些“临时”缓冲区后关闭它们,但更一般的答案是,您只需要将它们从脑海中抛开,并开发一个工作流程,您可以在其中访问您 所做的缓冲区 想要。否则,当您的自己的缓冲区不相关时,您将开始将它们视为混乱,并浪费精力关闭它们。

iswitchb-mode 是一个好的开始。

【讨论】:

    【解决方案2】:

    顺便说一句,如果您选择 iswitchb,您也可以将其设置为忽略某些缓冲区。只需将以下代码添加到您的 emacs 初始化文件中:

    (add-to-list 'iswitchb-buffer-ignore "*Messages*")
    (add-to-list 'iswitchb-buffer-ignore "*scratch")
    (add-to-list 'iswitchb-buffer-ignore "*Completions")
    

    【讨论】:

    • 警告(初始化):加载/home/david/.emacs.el': Symbol's value as variable is void: iswitchb-buffer-ignore To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the --debug-init' 选项以查看完整的错误回溯时出错。当我将这三行添加到配置文件时,我明白了,谢谢!
    • 那可能是因为你没有安装iswitchb。所以你必须先安装它。为此,您应该在其他之前添加 (iswitchb-mode 1)。即:(iswitchb-mode 1) (add-to-list 'iswitchb-buffer-ignore "*Messages*") (add-to-list 'iswitchb-buffer-ignore "*scratch") (add-to-list 'iswitchb-buffer-ignore "*Completions") 我相信这会有所帮助。
    • 我添加了,但我仍然得到起始缓冲区“正在加载 /home/david/.recentf...done (...)”
    【解决方案3】:

    在 emacs 24 中有 elisp 函数:

    清理缓冲区列表

    这是由MidnightMode 提供的,可以添加到其他版本中。

    顾名思义,也可以预定。

    【讨论】:

      【解决方案4】:

      iswitchb 模式的替代方案是ido-mode,它非常相似,但看起来更干净一些,它也使C-x-C-f(查找文件)看起来更好。

      【讨论】:

        【解决方案5】:

        或者只是完全禁用暂存、消息和完成缓冲区,而不破坏任何内容:

        先发here,下面贴:

        把它放在你的 .emacs 中:

        ;; Makes *scratch* empty.
        (setq initial-scratch-message "")
        
        ;; Removes *scratch* from buffer after the mode has been set.
        (defun remove-scratch-buffer ()
          (if (get-buffer "*scratch*")
              (kill-buffer "*scratch*")))
        (add-hook 'after-change-major-mode-hook 'remove-scratch-buffer)
        
        ;; Removes *messages* from the buffer.
        (setq-default message-log-max nil)
        (kill-buffer "*Messages*")
        
        ;; Removes *Completions* from buffer after you've opened a file.
        (add-hook 'minibuffer-exit-hook
              '(lambda ()
                 (let ((buffer "*Completions*"))
                   (and (get-buffer buffer)
                        (kill-buffer buffer)))))
        
        ;; Don't show *Buffer list* when opening multiple files at the same time.
        (setq inhibit-startup-buffer-menu t)
        
        ;; Show only one active window when opening multiple files at the same time.
        (add-hook 'window-setup-hook 'delete-other-windows)
        

        奖金:

        ;; No more typing the whole yes or no. Just y or n will do.
        (fset 'yes-or-no-p 'y-or-n-p)
        

        【讨论】:

          猜你喜欢
          • 2013-05-13
          • 1970-01-01
          • 2012-02-08
          • 1970-01-01
          • 1970-01-01
          • 2013-01-16
          • 1970-01-01
          • 1970-01-01
          • 2010-11-18
          相关资源
          最近更新 更多