[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r104072: Implement and document `serv
From: |
Lars Magne Ingebrigtsen |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r104072: Implement and document `server-eval-at'. |
Date: |
Mon, 02 May 2011 04:06:53 +0200 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 104072
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Mon 2011-05-02 04:06:53 +0200
message:
Implement and document `server-eval-at'.
modified:
doc/emacs/ChangeLog
doc/emacs/misc.texi
lisp/ChangeLog
lisp/server.el
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog 2011-04-24 18:47:17 +0000
+++ b/doc/emacs/ChangeLog 2011-05-02 02:06:53 +0000
@@ -1,3 +1,7 @@
+2011-05-02 Lars Magne Ingebrigtsen <address@hidden>
+
+ * misc.texi (Emacs Server): Document `server-eval-at'.
+
2011-04-24 Chong Yidong <address@hidden>
* maintaining.texi (List Tags): Document next-file. Suggested by
=== modified file 'doc/emacs/misc.texi'
--- a/doc/emacs/misc.texi 2011-03-03 07:00:23 +0000
+++ b/doc/emacs/misc.texi 2011-05-02 02:06:53 +0000
@@ -1495,6 +1495,15 @@
@samp{foo}. The @code{emacsclient} program can specify a server by
name, using the @samp{-s} option (@pxref{emacsclient Options}).
address@hidden server-eval-at
+ If you have defined a server by a unique server name, you can
+connect to this server from other Emacs instances and evaluate forms
+on it by using the @code{server-eval-at} function.
+
address@hidden(server-eval-at "foo" '(+ 1 2))} gives the result @code{3}, if
+there's a server with that name that is listening. If not, an error
+will be signaled.
+
@menu
* Invoking emacsclient:: Connecting to the Emacs server.
* emacsclient Options:: Emacs client startup options.
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-05-01 15:39:10 +0000
+++ b/lisp/ChangeLog 2011-05-02 02:06:53 +0000
@@ -1,3 +1,7 @@
+2011-05-02 Lars Magne Ingebrigtsen <address@hidden>
+
+ * server.el (server-eval-at): New function.
+
2011-05-01 Lars Magne Ingebrigtsen <address@hidden>
* net/network-stream.el (open-network-stream): Take a :nowait
=== modified file 'lisp/server.el'
--- a/lisp/server.el 2011-03-21 16:42:16 +0000
+++ b/lisp/server.el 2011-05-02 02:06:53 +0000
@@ -1484,6 +1484,41 @@
;; continue standard unloading
nil)
+(defun server-eval-at (server form)
+ "Eval FORM on Emacs Server SERVER."
+ (let ((auth-file (expand-file-name server server-auth-dir))
+ ;;(coding-system-for-read 'binary)
+ ;;(coding-system-for-write 'binary)
+ address port secret process)
+ (unless (file-exists-p auth-file)
+ (error "No such server definition: %s" auth-file))
+ (with-temp-buffer
+ (insert-file-contents auth-file)
+ (unless (looking-at "\\([0-9.]+\\):\\([0-9]+\\)")
+ (error "Invalid auth file"))
+ (setq address (match-string 1)
+ port (string-to-number (match-string 2)))
+ (forward-line 1)
+ (setq secret (buffer-substring (point) (line-end-position)))
+ (erase-buffer)
+ (unless (setq process (open-network-stream "eval-at" (current-buffer)
+ address port))
+ (error "Unable to contact the server"))
+ (set-process-query-on-exit-flag process nil)
+ (process-send-string
+ process
+ (concat "-auth " secret " -eval "
+ (replace-regexp-in-string
+ " " "&_" (format "%S" form))
+ "\n"))
+ (while (memq (process-status process) '(open run))
+ (accept-process-output process 0 10))
+ (goto-char (point-min))
+ ;; If the result is nil, there's nothing in the buffer. If the
+ ;; result is non-nil, it's after "-print ".
+ (and (search-forward "\n-print" nil t)
+ (read (current-buffer))))))
+
(provide 'server)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r104072: Implement and document `server-eval-at'.,
Lars Magne Ingebrigtsen <=