annotate lisp/mule/mule-process.el @ 139:2b5203979d01

Added tag r20-2b3 for changeset 6608ceec7cf8
author cvs
date Mon, 13 Aug 2007 09:31:48 +0200
parents fe104dbd9147
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 ;;; mule-process.el --- Process functions for XEmacs/Mule.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Amdahl Corporation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Sun Microsystems.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 ;; any later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 ;; General Public License for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24 ;;; Commentary:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 ;;; split off of mule.el.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 ;;; Code:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 (defun set-current-process-coding-system (input output)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32 (interactive
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33 "zCoding-system for process input: \nzCoding-system for process output: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 (let ((proc (get-buffer-process (current-buffer))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35 (if (null proc)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 (error "no process")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 (set-process-coding-system proc input output)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 (redraw-modeline t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 (defun code-convert-process-arguments (arguments coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 "Convert the code of ARGUMENTS passed to the process using
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 input coding-system of CODINGS-SYSTEMS. If you never wants to convert
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43 code of arguments, define this function just to return ARGUMENTS."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 (mapcar (function (lambda (arg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 (or (code-convert-string arg 'internal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 (cdr coding-systems))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 arg)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 arguments))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 (defvar call-process-hook nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 "A hook function to decide coding-systems for calling programs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 Before calling programs, call-process and call-process-region call
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 this function with arguments PROGRAM, BUFFER, START, END and ARGS,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 where START and END are nil when called from call-process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 The return value of this function should be a cons of coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 for input and output of the program. The input coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 is also used for converting ARGS.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 If the value is not cons object, further calling is suppressed.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 (defun call-process (program &optional infile buffer display &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 "Call PROGRAM synchronously in separate process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 The program's input comes from file INFILE (nil means `/dev/null').
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 Insert output in BUFFER before point; t means current buffer;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 nil for BUFFER means discard it; 0 means discard and don't wait.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 Remaining arguments are strings passed as command arguments to PROGRAM.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 If BUFFER is 0, returns immediately with value nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 Otherwise waits for PROGRAM to terminate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 and returns a numeric exit status or a signal description string.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 If you quit, the process is killed with SIGINT, or SIGKILL if you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 quit again.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 The coding-system used for converting ARGS and receiving the output
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 of PROGRAM default to car and cdr of default-process-coding-system,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74 but can be changed by `call-process-hook'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 See also `call-process-hook' and `call-process-internal'."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 (let ((coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 (if call-process-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 (apply call-process-hook program buffer nil nil args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 default-process-coding-system)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 (if (consp coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 (apply 'call-process-internal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 program infile buffer display (car coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 (code-convert-process-arguments args coding-systems)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 (defun call-process-region (start end program
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 &optional delete buffer display &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 "Send text from START to END to a process running PROGRAM.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 Delete the text if DELETE is non-nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 Insert output in BUFFER before point; t means current buffer;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 nil for BUFFER means discard it; 0 means discard and don't wait.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 Remaining args are passed to PROGRAM at startup as command args.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 Returns nil if BUFFER is 0; otherwise waits for PROGRAM to terminate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 and returns a numeric exit status or a signal description string.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 If you quit, the process is killed with SIGKILL.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 The coding-system used for receiving from the PROGRAM defaults to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 car of default-process-coding-system.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 The coding-system used for sending the region to the PROGRAM and converting
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 ARGS default to cdr of default-process-coding-system.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 But these can be changed by `call-process-hook'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 See also `call-process-hook' and `call-process'."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 (let ((temp (if (eq system-type 'ms-dos)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 (let* ((tem (or (getenv "TMP") (getenv "TEMP") "/"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 (temm (aref tem (1- (length tem)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 (make-temp-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 (concat tem
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 (if (or (eq temm ?/) (eq temm ?\\)) "" "/")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 "em")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 (make-temp-name "/tmp/emacs")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 (coding-systems (if call-process-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 (apply call-process-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 program buffer start end args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 default-process-coding-system))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114 status)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115 (if (consp coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 (unwind-protect
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 (let ((call-process-hook nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 (default-process-coding-system coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 (output-coding-system (cdr coding-systems)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 (write-region start end temp nil 'nomessage)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 (if delete (delete-region start end))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 (setq status
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 (apply 'call-process program temp buffer display args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124 (delete-file temp)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125 status))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
126
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
127 (defvar start-process-hook nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
128 "A hook function to decide coding-systems of process input and output.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129 Before starting process, start-process calls it with arguments
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130 NAME, BUFFER, PROGRAM, and ARGS [same as those given to start-process].
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 The return value of this function should be a cons of coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 used while sending and receiving to/from the started process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 If the value is not cons object, further calling is supressed.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 (if (not (eq system-type 'ms-dos))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
137 (defun start-process (name buf program &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138 "Start a program in a subprocess. Return the process object for it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
139 Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
140 NAME is name for process. It is modified if necessary to make it unique.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 BUFFER is the buffer or (buffer-name) to associate with the process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142 Process output goes at end of that buffer, unless you specify
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
143 an output stream or filter function to handle the output.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
144 BUFFER may be also nil, meaning that this process is not associated
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
145 with any buffer.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146 Third arg is program file name. It is searched for as in the shell.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147 Remaining arguments are strings to give program as arguments.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148 The coding-system used for sending and receiving to/from the process are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149 the value of default-process-coding-system, but can be changed by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 `start-process-hook'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 See also `start-process-hook' and `start-process-internal;."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 (let ((coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 (if start-process-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 (apply start-process-hook name buf program args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 default-process-coding-system)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 (if (consp coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 (let ((process
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 (apply 'start-process-internal name buf program
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 (code-convert-process-arguments args coding-systems))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 (set-process-input-coding-system (car coding-systems))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 (set-process-output-coding-system (cdr coding-systems))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 process))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 (defvar open-network-stream-hook nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 "A hook function to decide coding-systems of input and output for service.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 Before starting service, open-network-stream calls this function with arguments
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167 NAME, BUFFER, PROGRAM, and ARGS [same as those given to open-network-stream].
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 The return value of this function should be a cons of coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 used while sending and receiving to/from the network service.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 If the value is not cons object, further calling is supressed.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172 (defun open-network-stream (name buf host service)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 "Open a TCP connection for a service to a host.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 Returns a subprocess-object to represent the connection.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 Input and output work as for subprocesses; `delete-process' closes it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 Args are NAME BUFFER HOST SERVICE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 NAME is name for process. It is modified if necessary to make it unique.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 BUFFER is the buffer (or buffer-name) to associate with the process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 Process output goes at end of that buffer, unless you specify
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 an output stream or filter function to handle the output.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 BUFFER may be also nil, meaning that this process is not associated
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 with any buffer
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 Third arg is name of the host to connect to.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 Fourth arg SERVICE is name of the service desired, or an integer
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 specifying a port number to connect to.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 The coding system used for sending and receiving to/from the SERVICE are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
187 the value of default-process-coding-system, but can be changed by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
188 open-network-stream-hook.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
189 See also `open-network-stream-hook' and `open-network-stream-internal'."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
190 (let ((coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
191 (if open-network-stream-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
192 (funcall open-network-stream-hook name buf host service)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
193 default-process-coding-system)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
194 (if (consp coding-systems)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
195 (let ((process
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
196 (open-network-stream-internal
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
197 name buf host service)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
198 (set-process-input-coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
199 (car coding-systems))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
200 (set-process-output-coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
201 (cdr coding-systems))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
202 process))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
203
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
204 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
205
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
206 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
207 ;;; For process-coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
208 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
209
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
210 (defun default-start-process-hook (name buf program &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
211 (apply 'find-process-coding-system buf program nil args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
212
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
213 (defun default-open-network-stream-hook (name buf host service)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
214 (find-process-coding-system buf service t host))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
215
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
216 (defun default-call-process-hook (program buffer start end &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
217 (apply 'find-process-coding-system buffer program nil args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
218
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
219 (defun find-process-coding-system (buffer program
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
220 &optional servicep &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
221 "Arguments are BUFFER, PROGRAM, SERVICEP, and ARGS.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
222 BUFFER is output buffer (or its name) of a process or nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
223 If SERVICEP is nil, PROGRAM is a path name of a program to be executed
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
224 by start-process and ARGS is a list of the arguments.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
225 If SERVICEP is non-nil, PROGRAM is a name of a service
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
226 for open-network-stream and ARGS is a list of a host.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
227 The return value is a cons of coding-systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
228 for input and output for the process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
229 Please redefine this function as you wish."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
230 (if (eq buffer t) (setq buffer (buffer-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
231 (if (bufferp buffer) (setq buffer (buffer-name buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
232 (if (not (stringp buffer)) (setq buffer ""))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
233
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
234 (let ((place (if servicep
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
235 (find-service-coding-system program (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
236 (find-program-coding-system buffer program))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
237 (if place
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
238 (cond( (consp (cdr place)) (cdr place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
239 ( (null (cdr place)) '(nil nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
240 ( t (condition-case ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
241 (apply (cdr place) buffer program servicep args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
242 (error default-process-coding-system))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
243 default-process-coding-system)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 (setq start-process-hook 'default-start-process-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246 open-network-stream-hook 'default-open-network-stream-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
247 call-process-hook 'default-call-process-hook)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
248
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
249 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
250 ;;; program --> coding-system translation
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
251 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
252
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
253 (defun strict-string-match (regexp string &optional start)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 (and (eq 0 (string-match regexp string (or start 0)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 (eq (match-end 0) (length string))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
256
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257 (defvar program-coding-system-alist nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 (defun define-program-coding-system (buffer program code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260 (let* ((key (cons buffer program))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
261 (place (assoc key program-coding-system-alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
262 (if (coding-system-p code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
263 (setq code (cons code code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
264 (if place
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
265 (setcdr place code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
266 (setq place (cons key code))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
267 (setq program-coding-system-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
268 (cons place program-coding-system-alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
269 place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
270
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
271 (defun find-program-coding-system (buffer program)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
272 (let ((alist program-coding-system-alist) (place nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
273 (while (and alist (null place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
274 (if (program-coding-system-match buffer program (car (car alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
275 (setq place (car alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
276 (setq alist (cdr alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
277 place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
278
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
279 (defun program-coding-system-match (buffer program patpair)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
280 (let ((bpat (car patpair)) (ppat (cdr patpair)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
281 (if (and (symbolp ppat) (boundp ppat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
282 (stringp (symbol-value ppat)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
283 (setq ppat (symbol-value ppat)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
284 (and (or (null bpat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
285 (and (stringp bpat) (string-match bpat buffer)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
286 (or (null ppat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
287 (and (stringp ppat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
288 (or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
289 (strict-string-match ppat program)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
290 (strict-string-match ppat (file-name-nondirectory program))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
291 ))))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
292
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
293 (define-program-coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
294 nil "rsh" 'find-process-coding-system-rsh)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
295
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
296 (defun find-process-coding-system-rsh (buffer rsh &optional servicep host
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
297 &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
298 (if (equal (car args) "-l")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
299 (setq args (cdr (cdr args))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
300 (if (equal (car args) "-n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
301 (setq args (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
302 (apply 'find-process-coding-system buffer (car args) nil (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
303
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
304
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
305 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
306 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
307 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
308 (define-program-coding-system
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
309 nil (concat exec-directory "env") 'find-process-coding-system-env)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
310
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
311 ;;;(defun find-mc-process-code-env (buffer env &optional servicep &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
312 ;;; (while (string-match "[-=]" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
313 ;;; (setq args (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
314 ;;; (find-mc-process-code buffer (car args) nil (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
315
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
316 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
317 ;;; coded by nakagawa@titisa.is.titech.ac.jp 1989
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
318 ;;; modified by tomura@etl.go.jp
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
319 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
320 ;;; env command syntax: See etc/env.c
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
321 ;;; env [ - ]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
322 ;;; ;;; GNU env only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
323 ;;; { variable=value
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
324 ;;; | -u variable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
325 ;;; | -unset variable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
326 ;;; | -s variable value
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
327 ;;; | -set variable value }*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
328 ;;; [ - | -- ]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
329 ;;; ;;; end of GNU env only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
330 ;;; <program> <args>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
331 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
332
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
333 (defun find-process-coding-system-env (buffer env &optional servicep
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
334 &rest args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
335 (if (string= (car args) "-") (setq args (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
336 (while (or (string-match "=" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
337 (string= "-s" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
338 (string= "-set" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
339 (string= "-u" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
340 (string= "-unset" (car args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
341 (cond((or (string= "-s" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
342 (string= "-set" (car args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
343 (setq args (cdr(cdr(cdr args)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
344 ((or (string= "-u" (car args))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
345 (string= "-unset" (car args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
346 (setq args (cdr(cdr args))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
347 (t
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
348 (setq args (cdr args)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
349 (if (or (string= (car args) "-")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
350 (string= (car args) "--"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
351 (setq args (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
352 (apply 'find-process-coding-system buffer (car args) nil (cdr args)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
353
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
354 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
355 ;;; service --> mc code translation
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
356 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
357
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
358 (defvar service-coding-system-alist nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
359
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
360 (defun define-service-coding-system (service host code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
361 (let* ((key (cons service host))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
362 (place (assoc key service-coding-system-alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
363 (if (coding-system-p code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
364 (setq code (cons code code)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
365 (if place
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
366 (setcdr place code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
367 (setq place (cons key code)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
368 service-coding-system-alist (cons place service-coding-system-alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
369 place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
370
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
371 (defun find-service-coding-system (service host)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
372 (let ((alist service-coding-system-alist) (place nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
373 (while (and alist (null place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
374 (if (service-coding-system-match service host (car (car alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
375 (setq place (car alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
376 (setq alist (cdr alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
377 place))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
378
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
379 (defun service-coding-system-match (service host patpair)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
380 (let ((spat (car patpair)) (hpat (cdr patpair)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
381 (and (or (null spat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
382 (eq service spat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
383 (and (stringp spat) (stringp service)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
384 (strict-string-match spat service)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
385 (or (null hpat)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
386 (strict-string-match hpat host)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
387
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
388 (defvar default-process-coding-system (cons 'autodetect-unix nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
389 "Cons of default values used to receive from and send to process.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
390
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
391 (defun set-default-process-coding-system (input output)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
392 "Set default values of input and output coding-system for process to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
393 INPUT and OUTPUT, which should be symbols referring to coding systems."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
394 (interactive
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
395 "zDefault coding-system for process input: \nzDefault coding-system for process output: ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
396 (setq default-process-coding-system (cons input output))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
397 (redraw-modeline t))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
398
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
399 ;; For RMAIL and NEWS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
400 ;; Notice! In Korea for mail, use 'iso-2022-kr instead of 'junet.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
401 (define-program-coding-system nil ".*mail.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
402 (define-program-coding-system nil ".*inews.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
403 ;; For GNUS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
404 (define-service-coding-system "nntp" nil 'junet-unix)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
405 ;; For MH
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
406 (define-program-coding-system nil ".*scan.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
407 (define-program-coding-system nil ".*inc.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
408 (define-program-coding-system nil ".*mhl.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
409 ;; For MIME
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
410 (define-program-coding-system nil ".*anno.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
411 (define-program-coding-system nil ".*rcvstore.*" 'junet)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
412 (setq mh-before-send-letter-hook
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
413 '(lambda () (set-buffer-file-coding-system 'junet)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
414 ;; For VM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
415 (add-hook 'vm-mode-hooks
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
416 '(lambda ()
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
417 (set-buffer-file-coding-system 'junet)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
418 ;; For Wnn and cWnn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
419 (define-service-coding-system "wnn" nil 'no-conversion)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
420
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
421 ;; For shells -- commented out
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
422 ;;(define-program-coding-system nil ".*sh.*" '(nil . nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
423
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
424 ;; For gnus user only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
425 ;(setq gnus-your-domain "your.domain.address"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
426 ; gnus-your-organization "Your site name"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
427 ; gnus-use-generic-from t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
428
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
429 ;; For rnews user only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
430 (setq news-inews-program "/usr/lib/news/inews")