时不时地,在 Cx Cc Emacs 上宣布“这个 Emacs 会话有客户端;仍然退出?”。
(我在 Windows 7 上使用 Emacs 24beta,以防万一。)
我希望打开一些通过 emacsclientw.exe 打开的文件 - 但我没有看到任何文件。
(我有 git config --global core.editor "/c/lang/emacs-24beta/bin/emacsclientw.exe")
有没有办法找出哪些缓冲区有客户?(或者还有什么要寻找的吗?)
时不时地,在 Cx Cc Emacs 上宣布“这个 Emacs 会话有客户端;仍然退出?”。
(我在 Windows 7 上使用 Emacs 24beta,以防万一。)
我希望打开一些通过 emacsclientw.exe 打开的文件 - 但我没有看到任何文件。
(我有 git config --global core.editor "/c/lang/emacs-24beta/bin/emacsclientw.exe")
有没有办法找出哪些缓冲区有客户?(或者还有什么要寻找的吗?)
有没有办法找出哪些缓冲区有客户?
当缓冲区有客户端时,其server-buffer-clients
变量的值将非零。
我确信有更好的方法,但是这段代码应该提供一个带有客户端的缓冲区列表:
(需要'cl) (defvar 服务器缓冲区无) (defun show-server-buffers () (交互的) (setq 服务器缓冲区无) (让((原始缓冲区(当前缓冲区))) (循环在(缓冲区列表)中的 buf 做 (预测 (切换到缓冲区缓冲区) (如果(和 服务器缓冲区客户端 (buffer-live-p buf)) (添加到列表'服务器缓冲区 buf)))) (切换到缓冲区原始缓冲区) (消息“服务器缓冲区:%s”服务器缓冲区)))
我已经适应list-processes
了列出客户。您会使用新定义的命令获得一个客户进程列表list-clients
。每个客户端与将客户端作为第一个条目的服务器编辑缓冲区一起列出server-buffer-clients
。
(define-derived-mode client-menu-mode process-menu-mode "Client Menu"
"Major mode for listing the currently connected client processes."
(remove-hook 'tabulated-list-revert-hook #'list-processes--refresh t)
(add-hook 'tabulated-list-revert-hook #'server-list-clients--refresh nil t))
(defun server-list-clients (&optional query-only buffer)
"Display a list of all clients of this emacs session.
If optional argument QUERY-ONLY is non-nil, only processes with
the query-on-exit flag set are listed.
Any process listed as exited or signaled is actually eliminated
after the listing is made.
Optional argument BUFFER specifies a buffer to use, instead of
\"*Client List*\".
The return value is always nil."
(interactive)
(or (fboundp 'process-list)
(error "Asynchronous subprocesses are not supported on this system"))
(unless (bufferp buffer)
(setq buffer (get-buffer-create "*Client Process List*")))
(with-current-buffer buffer
(client-menu-mode)
(setq process-menu-query-only query-only)
(server-list-clients--refresh)
(tabulated-list-print))
(display-buffer buffer)
nil)
(defalias #'list-clients #'server-list-clients)
(defun server-client-buffer (client)
"Return buffer with client in `server-buffer-clients'."
(catch :found
(dolist (buf (buffer-list))
(if (memq client (with-current-buffer buf server-buffer-clients))
(throw :found buf)))))
(defun server-list-clients--refresh ()
"Recompute the list of client processes for the Client List buffer.
Also, delete any process that is exited or signaled."
(setq tabulated-list-entries nil)
(dolist (p server-clients)
(cond ((memq (process-status p) '(exit signal closed))
(delete-process p))
((or (not process-menu-query-only)
(process-query-on-exit-flag p))
(let* ((buf (server-client-buffer p))
(type (process-type p))
(name (process-name p))
(status (symbol-name (process-status p)))
(buf-label (if (buffer-live-p buf)
`(,(buffer-name buf)
face link
help-echo ,(format-message
"Visit buffer `%s'"
(buffer-name buf))
follow-link t
process-buffer ,buf
action process-menu-visit-buffer)
"--"))
(tty (or (process-tty-name p) "--"))
(cmd
(if (memq type '(network serial))
(let ((contact (process-contact p t)))
(if (eq type 'network)
(format "(%s %s)"
(if (plist-get contact :type)
"datagram"
"network")
(if (plist-get contact :server)
(format "server on %s"
(or
(plist-get contact :host)
(plist-get contact :local)))
(format "connection to %s"
(plist-get contact :host))))
(format "(serial port %s%s)"
(or (plist-get contact :port) "?")
(let ((speed (plist-get contact :speed)))
(if speed
(format " at %s b/s" speed)
"")))))
(mapconcat 'identity (process-command p) " "))))
(push (list p (vector name status buf-label tty cmd))
tabulated-list-entries))))))