aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kastrup2007-11-23 23:59:19 +0000
committerDavid Kastrup2007-11-23 23:59:19 +0000
commitbfb74e75a4a7978d9e009c75a61e80ced9a43006 (patch)
treef311f59d4792db7c8054c05dacda652c360eb2b5
parentab4c34c62692a5a4be6d60be06916daa61f730c9 (diff)
downloademacs-bfb74e75a4a7978d9e009c75a61e80ced9a43006.tar.gz
emacs-bfb74e75a4a7978d9e009c75a61e80ced9a43006.zip
* server.el (server-process-filter): Use `command-line-args-left'
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/server.el70
2 files changed, 34 insertions, 38 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b530f98fe64..c418612a5e7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3896,6 +3896,8 @@
3896 3896
38972007-09-30 David Kastrup <dak@gnu.org> 38972007-09-30 David Kastrup <dak@gnu.org>
3898 3898
3899 * server.el (server-process-filter): Use `command-line-args-left'
3900
3899 * startup.el (argv): Alias for `command-line-args-left' to use as 3901 * startup.el (argv): Alias for `command-line-args-left' to use as
3900 `(pop argv)' inside of --eval command sequences. Allows for 3902 `(pop argv)' inside of --eval command sequences. Allows for
3901 passing shell commands into Emacs verbatim without need for Lisp 3903 passing shell commands into Emacs verbatim without need for Lisp
diff --git a/lisp/server.el b/lisp/server.el
index 329010cc950..e6477b92d6f 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -811,17 +811,18 @@ The following commands are accepted by the client:
811 tty-type ;string. 811 tty-type ;string.
812 (files nil) 812 (files nil)
813 (lineno 1) 813 (lineno 1)
814 (columnno 0)) 814 (columnno 0)
815 command-line-args-left
816 arg)
815 ;; Remove this line from STRING. 817 ;; Remove this line from STRING.
816 (setq string (substring string (match-end 0))) 818 (setq string (substring string (match-end 0)))
817 (while (string-match " *[^ ]* " request) 819 (setq command-line-args-left
818 (let ((arg (substring request (match-beginning 0) 820 (mapcar 'server-unquote-arg (split-string request " " t)))
819 (1- (match-end 0))))) 821 (while (setq arg (pop command-line-args-left))
820 (setq request (substring request (match-end 0)))
821 (cond 822 (cond
822 ;; -version CLIENT-VERSION: obsolete at birth. 823 ;; -version CLIENT-VERSION: obsolete at birth.
823 ((and (equal "-version" arg) (string-match "[^ ]+ " request)) 824 ((and (equal "-version" arg) command-line-args-left)
824 (setq request (substring request (match-end 0)))) 825 (pop command-line-args-left))
825 826
826 ;; -nowait: Emacsclient won't wait for a result. 827 ;; -nowait: Emacsclient won't wait for a result.
827 ((equal "-nowait" arg) (setq nowait t)) 828 ((equal "-nowait" arg) (setq nowait t))
@@ -831,10 +832,8 @@ The following commands are accepted by the client:
831 832
832 ;; -display DISPLAY: 833 ;; -display DISPLAY:
833 ;; Open X frames on the given display instead of the default. 834 ;; Open X frames on the given display instead of the default.
834 ((and (equal "-display" arg) 835 ((and (equal "-display" arg) command-line-args-left)
835 (string-match "\\([^ ]*\\) " request)) 836 (setq display (pop command-line-args-left)))
836 (setq display (match-string 1 request))
837 (setq request (substring request (match-end 0))))
838 837
839 ;; -window-system: Open a new X frame. 838 ;; -window-system: Open a new X frame.
840 ((equal "-window-system" arg) 839 ((equal "-window-system" arg)
@@ -863,33 +862,32 @@ The following commands are accepted by the client:
863 862
864 ;; -ignore COMMENT: Noop; useful for debugging emacsclient. 863 ;; -ignore COMMENT: Noop; useful for debugging emacsclient.
865 ;; (The given comment appears in the server log.) 864 ;; (The given comment appears in the server log.)
866 ((and (equal "-ignore" arg) (string-match "[^ ]* " request)) 865 ((and (equal "-ignore" arg) command-line-args-left
867 (setq dontkill t 866 (setq dontkill t)
868 request (substring request (match-end 0)))) 867 (pop command-line-args-left)))
869 868
870 ;; -tty DEVICE-NAME TYPE: Open a new tty frame at the client. 869 ;; -tty DEVICE-NAME TYPE: Open a new tty frame at the client.
871 ((and (equal "-tty" arg) 870 ((and (equal "-tty" arg)
872 (string-match "\\([^ ]*\\) \\([^ ]*\\) " request)) 871 (cdr command-line-args-left))
873 (setq tty-name (match-string 1 request)) 872 (setq tty-name (pop command-line-args-left)
874 (setq tty-type (match-string 2 request)) 873 tty-type (pop command-line-args-left)
875 (setq dontkill t) 874 dontkill t))
876 (setq request (substring request (match-end 0))))
877 875
878 ;; -position LINE[:COLUMN]: Set point to the given 876 ;; -position LINE[:COLUMN]: Set point to the given
879 ;; position in the next file. 877 ;; position in the next file.
880 ((and (equal "-position" arg) 878 ((and (equal "-position" arg)
881 (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)? " 879 command-line-args-left
882 request)) 880 (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?"
883 (setq lineno (string-to-number (match-string 1 request)) 881 (car command-line-args-left)))
882 (setq arg (pop command-line-args-left))
883 (setq lineno (string-to-number (match-string 1 arg))
884 columnno (if (null (match-end 2)) 0 884 columnno (if (null (match-end 2)) 0
885 (string-to-number (match-string 2 request))) 885 (string-to-number (match-string 2 arg)))))
886 request (substring request (match-end 0))))
887 886
888 ;; -file FILENAME: Load the given file. 887 ;; -file FILENAME: Load the given file.
889 ((and (equal "-file" arg) 888 ((and (equal "-file" arg)
890 (string-match "\\([^ ]+\\) " request)) 889 command-line-args-left)
891 (let ((file (server-unquote-arg (match-string 1 request)))) 890 (let ((file (pop command-line-args-left)))
892 (setq request (substring request (match-end 0)))
893 (if coding-system 891 (if coding-system
894 (setq file (decode-coding-string file coding-system))) 892 (setq file (decode-coding-string file coding-system)))
895 (setq file (command-line-normalize-file-name file)) 893 (setq file (command-line-normalize-file-name file))
@@ -901,10 +899,8 @@ The following commands are accepted by the client:
901 899
902 ;; -eval EXPR: Evaluate a Lisp expression. 900 ;; -eval EXPR: Evaluate a Lisp expression.
903 ((and (equal "-eval" arg) 901 ((and (equal "-eval" arg)
904 (string-match "\\([^ ]+\\) " request)) 902 command-line-args-left)
905 (lexical-let ((expr (server-unquote-arg 903 (lexical-let ((expr (pop command-line-args-left)))
906 (match-string 1 request))))
907 (setq request (substring request (match-end 0)))
908 (if coding-system 904 (if coding-system
909 (setq expr (decode-coding-string expr coding-system))) 905 (setq expr (decode-coding-string expr coding-system)))
910 (push (lambda () (server-eval-and-print expr proc)) 906 (push (lambda () (server-eval-and-print expr proc))
@@ -913,23 +909,21 @@ The following commands are accepted by the client:
913 columnno 0))) 909 columnno 0)))
914 910
915 ;; -env NAME=VALUE: An environment variable. 911 ;; -env NAME=VALUE: An environment variable.
916 ((and (equal "-env" arg) (string-match "\\([^ ]+\\) " request)) 912 ((and (equal "-env" arg) command-line-args-left)
917 (let ((var (server-unquote-arg (match-string 1 request)))) 913 (let ((var (pop command-line-args-left)))
918 ;; XXX Variables should be encoded as in getenv/setenv. 914 ;; XXX Variables should be encoded as in getenv/setenv.
919 (setq request (substring request (match-end 0)))
920 (process-put proc 'env 915 (process-put proc 'env
921 (cons var (process-get proc 'env))))) 916 (cons var (process-get proc 'env)))))
922 917
923 ;; -dir DIRNAME: The cwd of the emacsclient process. 918 ;; -dir DIRNAME: The cwd of the emacsclient process.
924 ((and (equal "-dir" arg) (string-match "\\([^ ]+\\) " request)) 919 ((and (equal "-dir" arg) command-line-args-left)
925 (setq dir (server-unquote-arg (match-string 1 request))) 920 (setq dir (pop command-line-args-left))
926 (setq request (substring request (match-end 0)))
927 (if coding-system 921 (if coding-system
928 (setq dir (decode-coding-string dir coding-system))) 922 (setq dir (decode-coding-string dir coding-system)))
929 (setq dir (command-line-normalize-file-name dir))) 923 (setq dir (command-line-normalize-file-name dir)))
930 924
931 ;; Unknown command. 925 ;; Unknown command.
932 (t (error "Unknown command: %s" arg))))) 926 (t (error "Unknown command: %s" arg))))
933 927
934 (setq frame 928 (setq frame
935 (case tty-name 929 (case tty-name