1

First I ran emacs --daemon.

Then in one shell, I ran emacsclient -nw and open several files in the buffer.

Then in another shell, I did the same thing. At the same time I found that the file buffers I opened in the second client also appear in the first client.

When I exit the second client with ctrl-x ctrl-c, the buffers created in the second client also disappear from the first client. Can I exit the second client without closing the first client's buffers that were opened in the second client?

Thanks.

My init.el

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                                                                                                                                 

;; 1. markdown.el for markdown languages                                                                                                                                          

;; place `markdown-mode.el` somewhere in the load-path and add                                                                                                                    
(add-to-list 'load-path "~/.emacs.d/elisp/markdown/") ;; added by me                                                                                                              

;; autoload the el file                                                                                                                                                           
(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)

;; the following lines to your `.emacs` file to associate markdown-mode                                                                                                           
;; with `.text`, `.markdown`, and `.md` files:                                                                                                                                    
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                                                                                                                                   
;; Added by me                                                                                                                                                                    

;; 2. ESS for R language,                                                                                                                                                         
;; (require 'ess-site) ;; TODO: not working                                                                                                                                       

;;;;;;;;;;;;;;;;;;;;                                                                                                                                                              

;; 3. go-mode for go language                                                                                                                                                     
(add-to-list 'load-path "~/.emacs.d/elisp/go-mode/")
(require 'go-mode-autoloads)

;;;;;;;;;;;;;;;;;;;;                                                                                                                                                              

; 4. Enable installation of packages from MELPA                                                                                                                                   

(require 'package) ;; You might already have this line                                                                                                                            
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib                                                                                                                            
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line                                                                                                                          

;;;;;;;;;;;;;;;;                                                                                                                                                                  
; 5. for saving emacs sessions                                                                                                                                                    
(desktop-save-mode 1)
  • I couldn't reproduce this. Can you do this without any init file -Q? – DoMiNeLa10 May 29 '18 at 22:38
  • Do I need to terminate the emacs daemon right now and restart it as emacs -daemon -Q? Or do you mean I just run emacsclient -nw -Q? – Tim May 29 '18 at 22:43
  • You want to start the daemon without loading init files, clients just connect to it, and I don't think this option is even supported at all by emacsclient. – DoMiNeLa10 May 29 '18 at 22:45
  • I have to load settings in init.el and can't terminate the daemon right now. My init.el isn't complicated. See my update. – Tim May 29 '18 at 22:49
  • C-x C-c shouldn't kill buffers under any circumstance according to docstrings, and desktop-mode doesn't mention changing how that key behaves. – DoMiNeLa10 May 29 '18 at 22:57
1

When the client is closed, server-delete-client is going to kill all (unmodified) buffers which were explicitly associated with (only) that client.

You can prevent that by customizing server-kill-new-buffers to nil

  • Thanks. Is (server-kill-new-buffers nil) the correct one to put inside init.el? How would you modify init.el for that purpose? – Tim May 30 '18 at 1:35
  • It's a variable (and a user option), so either (setq server-kill-new-buffers nil) or use M-x customize-option RET server-kill-new-buffers – phils May 30 '18 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.