all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Suggested enhancement: allow emacsclient to send arbitrary LISP expressions
@ 2003-01-02 20:48 tytso
  2003-01-05 18:34 ` expressions Richard Stallman
  2003-01-08 13:50 ` Suggested enhancement: allow emacsclient to send arbitrary LISP expressions Kim F. Storm
  0 siblings, 2 replies; 21+ messages in thread
From: tytso @ 2003-01-02 20:48 UTC (permalink / raw)



This patch allows the emacs client to pass in an arbitrary lisp
expression, which will be executed by the emacs server process.  

For example: emacsclient '(make-frame-on-display "localhost:12")'

The patch is fully backwards compatible with older versions of
emacsclient, since emacsclient always sends absolute pathnames to the
emacs server.  The leading open parenthesis is used to indicate that
string is a lisp expression which should be evalulated.

On the emacsclient side, currently we simply use a leading open
parenthesis to indicate that the argument is a LISP expression.  This
means that attempts to edit a file that begins with an open expression
will now be interpreted as a LISP expression.  In practice I don't
expect this to be a problem, although if this is a major concern, a
option such as --lisp could be added to emacsclient to inhibit adding
the absolute pathname to the argument, instead of always treating
arguments that begin with an open parenthesis as LISP expressions.

Note: If I were designing the emacsclient/emacsserver protocol all
over again from scratch, emacsclient would always pass s-expressions
which would be intepreted as lisp expressions by the emacs process.
This would eliminate the current kludgy, ad-hoc quoting that
emacsclient uses.

						- Ted


--- emacsclient.c	2003/01/02 19:33:41	1.2
+++ emacsclient.c	2003/01/02 19:34:43
@@ -326,7 +326,7 @@
 	  if (*p != 0)
 	    fprintf (out, "%s/", quote_file_name (cwd));
 	}
-      else if (*argv[i] != '/')
+      else if (*argv[i] != '/' && *argv[i] != '(')
 	fprintf (out, "%s/", quote_file_name (cwd));
 
       fprintf (out, "%s ", quote_file_name (argv[i]));
--- /home/tytso/em/server.el	2003-01-02 15:21:03.000000000 -0500
+++ /usr/share/emacs/20.7/lisp/server.el	1999-03-12 19:20:25.000000000 -0500
@@ -213,8 +213,7 @@
 	  (coding-system (and default-enable-multibyte-characters
 			      (or file-name-coding-system
 				  default-file-name-coding-system)))
-	  client nowait 
-	  (result "error in lisp expression")
+	  client nowait
 	  (files nil)
 	  (lineno 1))
       ;; Remove this line from STRING.
@@ -226,24 +225,6 @@
 	      (setq request (substring request (match-end 0)))
 	      (setq client (list (substring request 0 (string-match " " request))))
 	      (setq request (substring request (match-end 0)))
-	      (if (string-match "^(" request)
-		  (let ((q (read-from-string request))
-			arg
-			(pos 0))
-		    (setq arg (substring request 0 (cdr q)))
-		    (setq request (substring request (cdr q)))
-		    (while (string-match "&." arg pos)
-		      (setq pos (1+ (match-beginning 0)))
-		      (let ((nextchar (aref arg pos)))
-			(cond ((= nextchar ?&)
-			       (setq arg (replace-match "&" t t arg)))
-			      ((= nextchar ?-)
-			       (setq arg (replace-match "-" t t arg)))
-			      (t
-			       (setq arg (replace-match " " t t arg))))))
-		    (unwind-protect
-			(setq result (eval (car (read-from-string arg)))))
-		    ))
 	      (while (string-match "[^ ]+ " request)
 		(let ((arg
 		       (substring request (match-beginning 0) (1- (match-end 0))))
@@ -275,20 +256,14 @@
 			    (cons (list arg lineno)
 				  files))
 		      (setq lineno 1)))))
-	      (if files
-		  (progn 
-		    (server-visit-files files client nowait)
-		    ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
-		    (or nowait
-			(setq server-clients (cons client server-clients)))
-		    (server-switch-buffer (nth 1 client))
-		    (run-hooks 'server-switch-hook)
-		    (message (substitute-command-keys
-			      "When done with a buffer, type \\[server-edit]")))
-		(let ((logmsg (format "Close: %s %s\n" (car client) 
-				      (prin1-to-string result))))
-		  (send-string server-process logmsg)
-		  (server-log logmsg))))))))
+	      (server-visit-files files client nowait)
+	      ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
+	      (or nowait
+		  (setq server-clients (cons client server-clients)))
+	      (server-switch-buffer (nth 1 client))
+	      (run-hooks 'server-switch-hook)
+	      (message (substitute-command-keys
+			"When done with a buffer, type \\[server-edit]")))))))
   ;; Save for later any partial line that remains.
   (setq server-previous-string string))

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2003-01-14 18:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-02 20:48 Suggested enhancement: allow emacsclient to send arbitrary LISP expressions tytso
2003-01-05 18:34 ` expressions Richard Stallman
2003-01-05 19:55   ` expressions Bob Halley
2003-01-06  0:49     ` expressions Kim F. Storm
2003-01-06  1:55       ` expressions Bob Halley
2003-01-06 20:06         ` expressions chad
2003-01-06 20:32           ` expressions Bob Halley
2003-01-07 10:11             ` expressions Kim F. Storm
2003-01-07 19:23               ` expressions Luc Teirlinck
2003-01-11 19:48               ` expressions Stefan Monnier
2003-01-07 10:14       ` expressions Kai Großjohann
2003-01-06 17:13     ` expressions Richard Stallman
2003-01-06 20:37       ` expressions Bob Halley
2003-01-08 21:00       ` expressions Andreas Schwab
2003-01-07 11:53     ` expressions Theodore Ts'o
2003-01-08  8:00       ` expressions Richard Stallman
2003-01-11 19:47       ` expressions Stefan Monnier
2003-01-08 13:50 ` Suggested enhancement: allow emacsclient to send arbitrary LISP expressions Kim F. Storm
2003-01-09 23:13   ` Richard Stallman
2003-01-13 21:08     ` Theodore Ts'o
2003-01-14 18:55       ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.