後,我打開與emacsclient的東西,當我殺死緩衝區(C-X K)我得到一個確認對話框:如何刪除提示以殺死emacsclient緩衝區?
Buffer `blah' still has clients; kill it? (yes or no)
但是,當我殺了緩衝區直接打開從Emacs的我不知道。當emacsclient打開它們時,有沒有辦法讓它們得到它們?
後,我打開與emacsclient的東西,當我殺死緩衝區(C-X K)我得到一個確認對話框:如何刪除提示以殺死emacsclient緩衝區?
Buffer `blah' still has clients; kill it? (yes or no)
但是,當我殺了緩衝區直接打開從Emacs的我不知道。當emacsclient打開它們時,有沒有辦法讓它們得到它們?
這爲我工作:
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
有一個關於Using Emacsclient blog entry的更多信息。
我不知道這是否適合我upvote這個答案,但據我所知,這是正確的,所以:-) – ShreevatsaR 2008-11-06 16:31:08
這不會工作,如果emacs開始使用emacsclient的「ALTERNATE_EDITOR」行爲...在你可以做 (defun server-remove-kill-buffer-hook() (remove-hook'kill-buffer-query-functions'server-kill-buffer-query-function)) (add-hook' server-visit-hook'server-remove-kill-buffer-hook) – 2013-01-30 15:00:14
該代碼片段中的`*`是什麼。 – Tshepang 2013-05-26 08:55:18
另一種選擇是使用-n
選項與emacsclient
,以便在退出之前不等待文件被編輯。
例如:
emacsclient -n myfile.txt
無論出於何種原因,我必須手動啓動上emacs23的移除鉤溶液,也許是因爲服務器的某些部分被加載在加載的.emacs後。在(remove-hook ...)之前添加虛擬(服務器啓動)行到我的.emacs沒有幫助。所以我選擇了下面,少原則性的解決方案:
(defalias 'server-kill-buffer-query-function '(lambda() t))
你可以設置鍵盤命令C-值X k,這樣它標誌着客戶端緩衝區爲已完成,並殺死正常緩衝區。
我無恥地竊取了此代碼段從Emacs的維基Emacs Client項:
(add-hook 'server-switch-hook
(lambda()
(when (current-local-map)
(use-local-map (copy-keymap (current-local-map))))
(when server-buffer-clients
(local-set-key (kbd "C-x k") 'server-edit))))
雖然這並不殺死緩衝液(如M-x list-buffers
),它應該是在其他方面幫助通過尊重某些shell腳本期望的Emacs客戶端行爲來保證安全。
這裏是你的Emacs發行的文件server.el摘錄可能揭示了我的意思一盞小燈:
;; When you finish editing a Server buffer, again call server-edit
;; to mark that buffer as done for the client and switch to the next
;; Server buffer. When all the buffers for a client have been edited
;; and exited with server-edit, the client "editor" will return
;; to the program that invoked it.
後來,有一個明確的警告,一個緩衝不該「T被殺死,但釋放(至少這是我如何理解它):
;; Ask before killing a server buffer.
;; It was suggested to release its client instead,
;; but I think that is dangerous--the client would proceed
;; using whatever is on disk in that file. -- rms.
注意,當您使用emacsclient編輯文件時,Emacs會告訴你用`CX#`你什麼時候告訴服務器已完成該文件。如果你這樣做(而不是`C-x k`),你不會被問到這個問題。 – phils 2014-06-19 22:18:59