3

Is there a way to modify the Emacs modeline so I'll be able to see all the emacsclients or just the number of emacsclients actually editing/displaying the buffer I'm currently working on?

I've found inside server.el.gz:

;; The buffer local variable "server-buffer-clients" lists 
;; the clients who are waiting for this buffer to be edited.
;; The global variable "server-clients" lists all the waiting clients,
;; and which files are yet to be edited for each.   

And this is one example of ouput when I call M-x describe-variable server-buffer-clients:

server-buffer-clients is a variable defined in `server.el'.                                                     
Its value is
(#<process server <5>> #<process server <3>> #<process server <1>>)

Local in buffer basics.hs; global value is nil

  Automatically becomes permanently buffer-local when set.

Documentation:
List of client processes requesting editing of current buffer.

I don't really understand how to interpret the line: (#<process server <5>> #<process server <3>> #<process server <1>>). Thanks for your suggestions.

  • #<...> indicates an object (in this case a process object) that doesn't have a read syntax, see Printed Representation – npostavs Apr 6 '15 at 17:15
  • Do you want the number of clients waiting for the buffer or the number of clients editing the buffer? The former should be simple, but rather useless I think. The latter sounds useful, but it's not very well since every client has the potential to edit every buffer (without even having to display it in a window). – Malabarba Apr 12 '15 at 19:56
  • @Malabarba The number of client editing the buffer. I'm editing the buffer, I leave, I come back later, and I launch another emacsclient to edit the buffer I left few hours ago. I'd like this new client to let me know that the buffer is already being edited in another old client. Please, let me know what's in your mind. – Nsukami _ Apr 12 '15 at 21:44
1

From the documentation you quoted, I think the following construct should give what you want.

'(:eval (when server-buffer-clients
          (format " %d" (length server-buffer-clients))))

Here's an example of how to add it to the mode-line, but you can also add it other places if preferred.

(push '(:eval (when server-buffer-clients
                (format " %d" (length server-buffer-clients))))
      global-mode-string)

Here is another example, closer to the left side.

(setq mode-line-client
      (list mode-line-client
            '(:eval (when server-buffer-clients
                      (format " %d" (length server-buffer-clients))))))
| improve this answer | |
  • Oh Lord, it was inside the docs :) Thanks a lot. – Nsukami _ Apr 13 '15 at 22:58
1

Not the answer that you hope for, but with Smart Mode Line you should be notified with a red M, to indicate that the buffer is edited in another Emacs Client.

| improve this answer | |

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.