comparison lisp/server.el @ 84635:f539dbd0a615

(server-running-p): New function.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 19 Sep 2007 02:00:54 +0000
parents c38a9291ef0a
children 4f2e2dad61b9
comparison
equal deleted inserted replaced
84634:a5e09adf5e2e 84635:f539dbd0a615
389 "Notify the emacsclient process to suspend itself when its tty device is suspended." 389 "Notify the emacsclient process to suspend itself when its tty device is suspended."
390 (dolist (proc (server-clients-with 'terminal terminal)) 390 (dolist (proc (server-clients-with 'terminal terminal))
391 (server-log (format "server-handle-suspend-tty, terminal %s" terminal) proc) 391 (server-log (format "server-handle-suspend-tty, terminal %s" terminal) proc)
392 (condition-case err 392 (condition-case err
393 (server-send-string proc "-suspend \n") 393 (server-send-string proc "-suspend \n")
394 (file-error (ignore-errors (server-delete-client proc)))))) 394 (file-error ;The pipe/socket was closed.
395 (ignore-errors (server-delete-client proc))))))
395 396
396 (defun server-unquote-arg (arg) 397 (defun server-unquote-arg (arg)
397 "Remove &-quotation from ARG. 398 "Remove &-quotation from ARG.
398 See `server-quote-arg' and `server-process-filter'." 399 See `server-quote-arg' and `server-process-filter'."
399 (replace-regexp-in-string 400 (replace-regexp-in-string
523 (setq buffer-file-coding-system 'no-conversion) 524 (setq buffer-file-coding-system 'no-conversion)
524 (insert (format-network-address 525 (insert (format-network-address
525 (process-contact server-process :local)) 526 (process-contact server-process :local))
526 " " (int-to-string (emacs-pid)) 527 " " (int-to-string (emacs-pid))
527 "\n" auth-key))))))))) 528 "\n" auth-key)))))))))
529
530 (defun server-running-p (&optional name)
531 "Test whether server NAME is running."
532 (interactive
533 (list (if current-prefix-arg
534 (read-string "Server name: " nil nil server-name))))
535 (unless name (setq name server-name))
536 (condition-case nil
537 (progn
538 (delete-process
539 (make-network-process
540 :name "server-client-test" :family 'local :server nil :noquery t
541 :service (expand-file-name name server-socket-dir)))
542 t)
543 (file-error nil)))
528 544
529 ;;;###autoload 545 ;;;###autoload
530 (define-minor-mode server-mode 546 (define-minor-mode server-mode
531 "Toggle Server mode. 547 "Toggle Server mode.
532 With ARG, turn Server mode on if ARG is positive, off otherwise. 548 With ARG, turn Server mode on if ARG is positive, off otherwise.