【问题标题】:Emacs - emacsclient or new frame?Emacs - emacsclient 还是新框架?
【发布时间】:2010-12-05 03:56:11
【问题描述】:

这是一个相当初级的问题,但是在 emacs 的单独框架(make-new-frame)中打开新文件或在 emacsclient 实例中打开文件之间有什么实际区别?我可以看到,如果您通过终端工作,则区别很明显......但是 emacsclient 是否可以另外将 (buffer-menu) 或 ido-mode 访问的缓冲区列表限制为在该特定 emacsclient 实例中打开的缓冲区?

【问题讨论】:

    标签: emacs emacs23 emacsclient


    【解决方案1】:

    这两种情况实际上没有区别,除了服务器设置了一些本地缓冲区状态以启用C-x #(又名server-edit)。

    您可以按照以下建议限制M-x list-buffers 的行为:

    (defadvice list-buffers-noselect (before list-buffers-noselect-limit-to-those-for-emacsclient activate)
      "When the current buffer is a being viewed by an emacclient, restrict the buffers to those associated with the emacsclient"
      (when (and (null (ad-get-arg 1)) server-buffer-clients)
        (let ((blist (delete-dups (reduce 'append
                                           (mapcar (lambda (proc) (process-get proc 'buffers))
                                                   server-buffer-clients)))))
          (ad-set-arg 1 blist))))
    

    现在,当您在 emacsclient 访问的缓冲区中执行 M-x buffer-menu 时,您只会看到同一客户端访问的其他缓冲区。当emacsclient 没有访问缓冲区时,它会正常工作。

    我不使用ido,但我想自定义会是类似的(如果这个建议不起作用的话)。

    详细信息是,当您运行emacsclient 时,打开的缓冲区与服务器进程相关联(它可以是多个,因为您可以通过多次调用emacsclient 打开同一个文件)。缓冲区的服务器客户端存储在缓冲区局部变量server-buffer-clients 中。

    要找出与emacsclient 的特定调用相关联的缓冲区,请找到该 emacsclient 的进程,然后执行:(process-get proc 'buffers)(其中 proc 是特定的 emacsclient 进程 - 列表的元素之一发现于server-buffer-clients)。

    这就是建议的全部内容。

    【讨论】:

    • 谢谢!正如 Jed 提到的,打开新框架时似乎没有区别,但是当我使用 emacsclient -t 打开一个新文件时,上面的建议有效。有趣...我会针对 ido-mode 和可能的 ibuffer 进行研究。非常感谢!
    【解决方案2】:

    emacs 23 没有区别,只要 emacsserver 正在运行。缓冲区列表在每个中都是相同的。

    【讨论】:

    • 谢谢 - 是的,它看起来大部分是正确的,但正如 Trey 指出的那样,emacs 似乎对哪个客户端正在访问特定文件有所了解......但感谢您的输入!
    猜你喜欢
    • 1970-01-01
    • 2013-09-25
    • 1970-01-01
    • 2011-07-22
    • 1970-01-01
    • 2012-03-06
    • 2010-10-31
    • 2023-03-08
    • 2011-02-27
    相关资源
    最近更新 更多