diff options
| author | Stefan Monnier | 2011-02-10 14:41:44 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-02-10 14:41:44 -0500 |
| commit | 59003be943b6a9e2b36a4ecc159430b78dff610e (patch) | |
| tree | 0b07a7c6f6a61bcd7a48e4f5a534f582c5d1e556 | |
| parent | 9517f8af147c034fd2242377a5212c8de4115e1f (diff) | |
| download | emacs-59003be943b6a9e2b36a4ecc159430b78dff610e.tar.gz emacs-59003be943b6a9e2b36a4ecc159430b78dff610e.zip | |
* lisp/server.el (server-process-filter): Use pcase.
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/server.el | 230 |
2 files changed, 115 insertions, 117 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e89003e724b..be1cc0b6a52 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2011-02-10 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-02-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * server.el (server-process-filter): Use pcase. | ||
| 4 | |||
| 3 | * emacs-lisp/smie.el (smie-blink-matching-open): Don't use `pos' in two | 5 | * emacs-lisp/smie.el (smie-blink-matching-open): Don't use `pos' in two |
| 4 | conflicting ways. | 6 | conflicting ways. |
| 5 | (smie-indent--parent): Extend to "parent of arg". | 7 | (smie-indent--parent): Extend to "parent of arg". |
diff --git a/lisp/server.el b/lisp/server.el index 62c59b41cee..df8cae0a6af 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -937,126 +937,122 @@ The following commands are accepted by the client: | |||
| 937 | tty-type ; string. | 937 | tty-type ; string. |
| 938 | files | 938 | files |
| 939 | filepos | 939 | filepos |
| 940 | command-line-args-left | 940 | args-left) |
| 941 | arg) | ||
| 942 | ;; Remove this line from STRING. | 941 | ;; Remove this line from STRING. |
| 943 | (setq string (substring string (match-end 0))) | 942 | (setq string (substring string (match-end 0))) |
| 944 | (setq command-line-args-left | 943 | (setq args-left |
| 945 | (mapcar 'server-unquote-arg (split-string request " " t))) | 944 | (mapcar 'server-unquote-arg (split-string request " " t))) |
| 946 | (while (setq arg (pop command-line-args-left)) | 945 | (while args-left |
| 947 | (cond | 946 | (pcase (pop args-left) |
| 948 | ;; -version CLIENT-VERSION: obsolete at birth. | 947 | ;; -version CLIENT-VERSION: obsolete at birth. |
| 949 | ((and (equal "-version" arg) command-line-args-left) | 948 | (`"-version" (pop args-left)) |
| 950 | (pop command-line-args-left)) | 949 | |
| 951 | 950 | ;; -nowait: Emacsclient won't wait for a result. | |
| 952 | ;; -nowait: Emacsclient won't wait for a result. | 951 | (`"-nowait" (setq nowait t)) |
| 953 | ((equal "-nowait" arg) (setq nowait t)) | 952 | |
| 954 | 953 | ;; -current-frame: Don't create frames. | |
| 955 | ;; -current-frame: Don't create frames. | 954 | (`"-current-frame" (setq use-current-frame t)) |
| 956 | ((equal "-current-frame" arg) (setq use-current-frame t)) | 955 | |
| 957 | 956 | ;; -display DISPLAY: | |
| 958 | ;; -display DISPLAY: | 957 | ;; Open X frames on the given display instead of the default. |
| 959 | ;; Open X frames on the given display instead of the default. | 958 | (`"-display" |
| 960 | ((and (equal "-display" arg) command-line-args-left) | 959 | (setq display (pop args-left)) |
| 961 | (setq display (pop command-line-args-left)) | 960 | (if (zerop (length display)) (setq display nil))) |
| 962 | (if (zerop (length display)) (setq display nil))) | 961 | |
| 963 | 962 | ;; -parent-id ID: | |
| 964 | ;; -parent-id ID: | 963 | ;; Open X frame within window ID, via XEmbed. |
| 965 | ;; Open X frame within window ID, via XEmbed. | 964 | (`"-parent-id" |
| 966 | ((and (equal "-parent-id" arg) command-line-args-left) | 965 | (setq parent-id (pop args-left)) |
| 967 | (setq parent-id (pop command-line-args-left)) | 966 | (if (zerop (length parent-id)) (setq parent-id nil))) |
| 968 | (if (zerop (length parent-id)) (setq parent-id nil))) | 967 | |
| 969 | 968 | ;; -window-system: Open a new X frame. | |
| 970 | ;; -window-system: Open a new X frame. | 969 | (`"-window-system" |
| 971 | ((equal "-window-system" arg) | 970 | (setq dontkill t) |
| 972 | (setq dontkill t) | 971 | (setq tty-name 'window-system)) |
| 973 | (setq tty-name 'window-system)) | 972 | |
| 974 | 973 | ;; -resume: Resume a suspended tty frame. | |
| 975 | ;; -resume: Resume a suspended tty frame. | 974 | (`"-resume" |
| 976 | ((equal "-resume" arg) | 975 | (lexical-let ((terminal (process-get proc 'terminal))) |
| 977 | (lexical-let ((terminal (process-get proc 'terminal))) | 976 | (setq dontkill t) |
| 978 | (setq dontkill t) | 977 | (push (lambda () |
| 979 | (push (lambda () | 978 | (when (eq (terminal-live-p terminal) t) |
| 980 | (when (eq (terminal-live-p terminal) t) | 979 | (resume-tty terminal))) |
| 981 | (resume-tty terminal))) | 980 | commands))) |
| 982 | commands))) | 981 | |
| 983 | 982 | ;; -suspend: Suspend the client's frame. (In case we | |
| 984 | ;; -suspend: Suspend the client's frame. (In case we | 983 | ;; get out of sync, and a C-z sends a SIGTSTP to |
| 985 | ;; get out of sync, and a C-z sends a SIGTSTP to | 984 | ;; emacsclient.) |
| 986 | ;; emacsclient.) | 985 | (`"-suspend" |
| 987 | ((equal "-suspend" arg) | 986 | (lexical-let ((terminal (process-get proc 'terminal))) |
| 988 | (lexical-let ((terminal (process-get proc 'terminal))) | 987 | (setq dontkill t) |
| 989 | (setq dontkill t) | 988 | (push (lambda () |
| 990 | (push (lambda () | 989 | (when (eq (terminal-live-p terminal) t) |
| 991 | (when (eq (terminal-live-p terminal) t) | 990 | (suspend-tty terminal))) |
| 992 | (suspend-tty terminal))) | 991 | commands))) |
| 993 | commands))) | 992 | |
| 994 | 993 | ;; -ignore COMMENT: Noop; useful for debugging emacsclient. | |
| 995 | ;; -ignore COMMENT: Noop; useful for debugging emacsclient. | 994 | ;; (The given comment appears in the server log.) |
| 996 | ;; (The given comment appears in the server log.) | 995 | (`"-ignore" |
| 997 | ((and (equal "-ignore" arg) command-line-args-left | 996 | (setq dontkill t) |
| 998 | (setq dontkill t) | 997 | (pop args-left)) |
| 999 | (pop command-line-args-left))) | 998 | |
| 1000 | 999 | ;; -tty DEVICE-NAME TYPE: Open a new tty frame at the client. | |
| 1001 | ;; -tty DEVICE-NAME TYPE: Open a new tty frame at the client. | 1000 | (`"-tty" |
| 1002 | ((and (equal "-tty" arg) | 1001 | (setq tty-name (pop args-left) |
| 1003 | (cdr command-line-args-left)) | 1002 | tty-type (pop args-left) |
| 1004 | (setq tty-name (pop command-line-args-left) | 1003 | dontkill (or dontkill |
| 1005 | tty-type (pop command-line-args-left) | 1004 | (not use-current-frame)))) |
| 1006 | dontkill (or dontkill | 1005 | |
| 1007 | (not use-current-frame)))) | 1006 | ;; -position LINE[:COLUMN]: Set point to the given |
| 1008 | 1007 | ;; position in the next file. | |
| 1009 | ;; -position LINE[:COLUMN]: Set point to the given | 1008 | (`"-position" |
| 1010 | ;; position in the next file. | 1009 | (if (not (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" |
| 1011 | ((and (equal "-position" arg) | 1010 | (car args-left))) |
| 1012 | command-line-args-left | 1011 | (error "Invalid -position command in client args")) |
| 1013 | (string-match "\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" | 1012 | (let ((arg (pop args-left))) |
| 1014 | (car command-line-args-left))) | 1013 | (setq filepos |
| 1015 | (setq arg (pop command-line-args-left)) | 1014 | (cons (string-to-number (match-string 1 arg)) |
| 1016 | (setq filepos | 1015 | (string-to-number (or (match-string 2 arg) |
| 1017 | (cons (string-to-number (match-string 1 arg)) | 1016 | "")))))) |
| 1018 | (string-to-number (or (match-string 2 arg) ""))))) | 1017 | |
| 1019 | 1018 | ;; -file FILENAME: Load the given file. | |
| 1020 | ;; -file FILENAME: Load the given file. | 1019 | (`"-file" |
| 1021 | ((and (equal "-file" arg) | 1020 | (let ((file (pop args-left))) |
| 1022 | command-line-args-left) | 1021 | (if coding-system |
| 1023 | (let ((file (pop command-line-args-left))) | 1022 | (setq file (decode-coding-string file coding-system))) |
| 1024 | (if coding-system | 1023 | (setq file (expand-file-name file dir)) |
| 1025 | (setq file (decode-coding-string file coding-system))) | 1024 | (push (cons file filepos) files) |
| 1026 | (setq file (expand-file-name file dir)) | 1025 | (server-log (format "New file: %s %s" |
| 1027 | (push (cons file filepos) files) | 1026 | file (or filepos "")) proc)) |
| 1028 | (server-log (format "New file: %s %s" | 1027 | (setq filepos nil)) |
| 1029 | file (or filepos "")) proc)) | 1028 | |
| 1030 | (setq filepos nil)) | 1029 | ;; -eval EXPR: Evaluate a Lisp expression. |
| 1031 | 1030 | (`"-eval" | |
| 1032 | ;; -eval EXPR: Evaluate a Lisp expression. | 1031 | (if use-current-frame |
| 1033 | ((and (equal "-eval" arg) | 1032 | (setq use-current-frame 'always)) |
| 1034 | command-line-args-left) | 1033 | (lexical-let ((expr (pop args-left))) |
| 1035 | (if use-current-frame | 1034 | (if coding-system |
| 1036 | (setq use-current-frame 'always)) | 1035 | (setq expr (decode-coding-string expr coding-system))) |
| 1037 | (lexical-let ((expr (pop command-line-args-left))) | 1036 | (push (lambda () (server-eval-and-print expr proc)) |
| 1038 | (if coding-system | 1037 | commands) |
| 1039 | (setq expr (decode-coding-string expr coding-system))) | 1038 | (setq filepos nil))) |
| 1040 | (push (lambda () (server-eval-and-print expr proc)) | 1039 | |
| 1041 | commands) | 1040 | ;; -env NAME=VALUE: An environment variable. |
| 1042 | (setq filepos nil))) | 1041 | (`"-env" |
| 1043 | 1042 | (let ((var (pop args-left))) | |
| 1044 | ;; -env NAME=VALUE: An environment variable. | 1043 | ;; XXX Variables should be encoded as in getenv/setenv. |
| 1045 | ((and (equal "-env" arg) command-line-args-left) | 1044 | (process-put proc 'env |
| 1046 | (let ((var (pop command-line-args-left))) | 1045 | (cons var (process-get proc 'env))))) |
| 1047 | ;; XXX Variables should be encoded as in getenv/setenv. | 1046 | |
| 1048 | (process-put proc 'env | 1047 | ;; -dir DIRNAME: The cwd of the emacsclient process. |
| 1049 | (cons var (process-get proc 'env))))) | 1048 | (`"-dir" |
| 1050 | 1049 | (setq dir (pop args-left)) | |
| 1051 | ;; -dir DIRNAME: The cwd of the emacsclient process. | 1050 | (if coding-system |
| 1052 | ((and (equal "-dir" arg) command-line-args-left) | 1051 | (setq dir (decode-coding-string dir coding-system))) |
| 1053 | (setq dir (pop command-line-args-left)) | 1052 | (setq dir (command-line-normalize-file-name dir))) |
| 1054 | (if coding-system | 1053 | |
| 1055 | (setq dir (decode-coding-string dir coding-system))) | 1054 | ;; Unknown command. |
| 1056 | (setq dir (command-line-normalize-file-name dir))) | 1055 | (arg (error "Unknown command: %s" arg)))) |
| 1057 | |||
| 1058 | ;; Unknown command. | ||
| 1059 | (t (error "Unknown command: %s" arg)))) | ||
| 1060 | 1056 | ||
| 1061 | (setq frame | 1057 | (setq frame |
| 1062 | (cond | 1058 | (cond |