# HG changeset patch # User David Kastrup # Date 1195862359 0 # Node ID 2f0cad6a4f81b2d844e5d9859032933f96e845a4 # Parent 2ac1a9b705807c7b6390069c7f9eac16d2f6ac9a * server.el (server-process-filter): Use `command-line-args-left' diff -r 2ac1a9b70580 -r 2f0cad6a4f81 lisp/ChangeLog --- a/lisp/ChangeLog Fri Nov 23 22:49:40 2007 +0000 +++ b/lisp/ChangeLog Fri Nov 23 23:59:19 2007 +0000 @@ -3896,6 +3896,8 @@ 2007-09-30 David Kastrup + * server.el (server-process-filter): Use `command-line-args-left' + * startup.el (argv): Alias for `command-line-args-left' to use as `(pop argv)' inside of --eval command sequences. Allows for passing shell commands into Emacs verbatim without need for Lisp diff -r 2ac1a9b70580 -r 2f0cad6a4f81 lisp/server.el --- a/lisp/server.el Fri Nov 23 22:49:40 2007 +0000 +++ b/lisp/server.el Fri Nov 23 23:59:19 2007 +0000 @@ -811,17 +811,18 @@ tty-type ;string. (files nil) (lineno 1) - (columnno 0)) + (columnno 0) + command-line-args-left + arg) ;; Remove this line from STRING. (setq string (substring string (match-end 0))) - (while (string-match " *[^ ]* " request) - (let ((arg (substring request (match-beginning 0) - (1- (match-end 0))))) - (setq request (substring request (match-end 0))) + (setq command-line-args-left + (mapcar 'server-unquote-arg (split-string request " " t))) + (while (setq arg (pop command-line-args-left)) (cond ;; -version CLIENT-VERSION: obsolete at birth. - ((and (equal "-version" arg) (string-match "[^ ]+ " request)) - (setq request (substring request (match-end 0)))) + ((and (equal "-version" arg) command-line-args-left) + (pop command-line-args-left)) ;; -nowait: Emacsclient won't wait for a result. ((equal "-nowait" arg) (setq nowait t)) @@ -831,10 +832,8 @@ ;; -display DISPLAY: ;; Open X frames on the given display instead of the default. - ((and (equal "-display" arg) - (string-match "\\([^ ]*\\) " request)) - (setq display (match-string 1 request)) - (setq request (substring request (match-end 0)))) + ((and (equal "-display" arg) command-line-args-left) + (setq display (pop command-line-args-left))) ;; -window-system: Open a new X frame. ((equal "-window-system" arg) @@ -863,33 +862,32 @@ ;; -ignore COMMENT: Noop; useful for debugging emacsclient. ;; (The given comment appears in the server log.) - ((and (equal "-ignore" arg) (string-match "[^ ]* " request)) - (setq dontkill t - request (substring request (match-end 0)))) + ((and (equal "-ignore" arg) command-line-args-left + (setq dontkill t) + (pop command-line-args-left))) ;; -tty DEVICE-NAME TYPE: Open a new tty frame at the client. ((and (equal "-tty" arg) - (string-match "\\([^ ]*\\) \\([^ ]*\\) " request)) - (setq tty-name (match-string 1 request)) - (setq tty-type (match-string 2 request)) - (setq dontkill t) - (setq request (substring request (match-end 0)))) + (cdr command-line-args-left)) + (setq tty-name (pop command-line-args-left) + tty-type (pop command-line-args-left) + dontkill t)) ;; -position LINE[:COLUMN]: Set point to the given ;; position in the next file. ((and (equal "-position" arg) - (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)? " - request)) - (setq lineno (string-to-number (match-string 1 request)) + command-line-args-left + (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" + (car command-line-args-left))) + (setq arg (pop command-line-args-left)) + (setq lineno (string-to-number (match-string 1 arg)) columnno (if (null (match-end 2)) 0 - (string-to-number (match-string 2 request))) - request (substring request (match-end 0)))) + (string-to-number (match-string 2 arg))))) ;; -file FILENAME: Load the given file. ((and (equal "-file" arg) - (string-match "\\([^ ]+\\) " request)) - (let ((file (server-unquote-arg (match-string 1 request)))) - (setq request (substring request (match-end 0))) + command-line-args-left) + (let ((file (pop command-line-args-left))) (if coding-system (setq file (decode-coding-string file coding-system))) (setq file (command-line-normalize-file-name file)) @@ -901,10 +899,8 @@ ;; -eval EXPR: Evaluate a Lisp expression. ((and (equal "-eval" arg) - (string-match "\\([^ ]+\\) " request)) - (lexical-let ((expr (server-unquote-arg - (match-string 1 request)))) - (setq request (substring request (match-end 0))) + command-line-args-left) + (lexical-let ((expr (pop command-line-args-left))) (if coding-system (setq expr (decode-coding-string expr coding-system))) (push (lambda () (server-eval-and-print expr proc)) @@ -913,23 +909,21 @@ columnno 0))) ;; -env NAME=VALUE: An environment variable. - ((and (equal "-env" arg) (string-match "\\([^ ]+\\) " request)) - (let ((var (server-unquote-arg (match-string 1 request)))) + ((and (equal "-env" arg) command-line-args-left) + (let ((var (pop command-line-args-left))) ;; XXX Variables should be encoded as in getenv/setenv. - (setq request (substring request (match-end 0))) (process-put proc 'env (cons var (process-get proc 'env))))) ;; -dir DIRNAME: The cwd of the emacsclient process. - ((and (equal "-dir" arg) (string-match "\\([^ ]+\\) " request)) - (setq dir (server-unquote-arg (match-string 1 request))) - (setq request (substring request (match-end 0))) + ((and (equal "-dir" arg) command-line-args-left) + (setq dir (pop command-line-args-left)) (if coding-system (setq dir (decode-coding-string dir coding-system))) (setq dir (command-line-normalize-file-name dir))) ;; Unknown command. - (t (error "Unknown command: %s" arg))))) + (t (error "Unknown command: %s" arg)))) (setq frame (case tty-name