aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorEli Zaretskii1998-04-19 14:13:47 +0000
committerEli Zaretskii1998-04-19 14:13:47 +0000
commit52a1b8948046116ba7961e90e57cbec2e604e21e (patch)
tree1e7c1c5058b6c32012ed61a26f92be956bffae64 /src/process.c
parent23de5c5c225df8e80e674f1e6105c05742374026 (diff)
downloademacs-52a1b8948046116ba7961e90e57cbec2e604e21e.tar.gz
emacs-52a1b8948046116ba7961e90e57cbec2e604e21e.zip
(Fset_process_inherit_coding_system_flag,
Fprocess_inherit_coding_system_flag): New functions. (syms_of_process): Defsubr them. (Fstart_process, Fopen_network_stream): Initialize inherit_coding_system_flag. (read_process_output): If the process buffer isn't dead, call after-insert-file-set-buffer-file-coding-system.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/process.c b/src/process.c
index 0f1f702a348..623ab6b1dc7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -847,6 +847,45 @@ DEFUN ("set-process-window-size", Fset_process_window_size,
847 return Qt; 847 return Qt;
848} 848}
849 849
850DEFUN ("set-process-inherit-coding-system-flag",
851 Fset_process_inherit_coding_system_flag,
852 Sset_process_inherit_coding_system_flag, 2, 2, 0,
853 "Determine whether buffer of PROCESS will inherit coding-system.\n\
854If the second argument FLAG is non-nil, then the variable\n\
855`buffer-file-coding-system' of the buffer associated with PROCESS\n\
856will be bound to the value of the coding system used to decode\n\
857the process output.\n\
858\n\
859This is useful when the coding system specified for the process buffer\n\
860leaves either the character code conversion or the end-of-line conversion\n\
861unspecified, or if the coding system used to decode the process output\n\
862is more appropriate for saving the process buffer.\n\
863\n\
864Binding the variable `inherit-process-coding-system' to non-nil before\n\
865starting the process is an alternative way of setting the inherit flag\n\
866for the process which will run.")
867 (process, flag)
868 register Lisp_Object process, flag;
869{
870 CHECK_PROCESS (process, 0);
871 XPROCESS (process)->inherit_coding_system_flag = !Fnull (flag);
872 return flag;
873}
874
875DEFUN ("process-inherit-coding-system-flag",
876 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
877 1, 1, 0,
878 "Return the value of inherit-coding-system flag for PROCESS.\n\
879If this flag is t, `buffer-file-coding-system' of the buffer\n\
880associated with PROCESS will inherit the coding system used to decode\n\
881the process output.")
882 (process)
883 register Lisp_Object process;
884{
885 CHECK_PROCESS (process, 0);
886 return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil;
887}
888
850DEFUN ("process-kill-without-query", Fprocess_kill_without_query, 889DEFUN ("process-kill-without-query", Fprocess_kill_without_query,
851 Sprocess_kill_without_query, 1, 2, 0, 890 Sprocess_kill_without_query, 1, 2, 0,
852 "Say no query needed if PROCESS is running when Emacs is exited.\n\ 891 "Say no query needed if PROCESS is running when Emacs is exited.\n\
@@ -1233,6 +1272,9 @@ Remaining arguments are strings to give program as arguments.")
1233 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 1272 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
1234 XPROCESS (proc)->encoding_carryover = make_number (0); 1273 XPROCESS (proc)->encoding_carryover = make_number (0);
1235 1274
1275 XPROCESS (proc)->inherit_coding_system_flag
1276 = (NILP (buffer) || !inherit_process_coding_system) ? 0 : 1;
1277
1236 create_process (proc, (char **) new_argv, current_dir); 1278 create_process (proc, (char **) new_argv, current_dir);
1237 1279
1238 return unbind_to (count, proc); 1280 return unbind_to (count, proc);
@@ -2023,6 +2065,9 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\
2023 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 2065 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
2024 XPROCESS (proc)->encoding_carryover = make_number (0); 2066 XPROCESS (proc)->encoding_carryover = make_number (0);
2025 2067
2068 XPROCESS (proc)->inherit_coding_system_flag =
2069 NILP (buffer) || !inherit_process_coding_system ? 0 : 1;
2070
2026 UNGCPRO; 2071 UNGCPRO;
2027 return proc; 2072 return proc;
2028} 2073}
@@ -2870,6 +2915,19 @@ read_process_output (proc, channel)
2870 XSETINT (p->decoding_carryover, carryover); 2915 XSETINT (p->decoding_carryover, carryover);
2871 Vlast_coding_system_used = coding->symbol; 2916 Vlast_coding_system_used = coding->symbol;
2872 2917
2918 /* If the caller required, let the process associated buffer
2919 inherit the coding-system used to decode the process output. */
2920 if (p->inherit_coding_system_flag
2921 && !NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
2922 {
2923 struct buffer *prev_buf = current_buffer;
2924
2925 Fset_buffer (p->buffer);
2926 call1 (intern ("after-insert-file-set-buffer-file-coding-system"),
2927 make_number (nbytes));
2928 set_buffer_internal (prev_buf);
2929 }
2930
2873 /* Read and dispose of the process output. */ 2931 /* Read and dispose of the process output. */
2874 outstream = p->filter; 2932 outstream = p->filter;
2875 if (!NILP (outstream)) 2933 if (!NILP (outstream))
@@ -4385,6 +4443,8 @@ The value takes effect when `start-process' is called.");
4385 defsubr (&Sset_process_sentinel); 4443 defsubr (&Sset_process_sentinel);
4386 defsubr (&Sprocess_sentinel); 4444 defsubr (&Sprocess_sentinel);
4387 defsubr (&Sset_process_window_size); 4445 defsubr (&Sset_process_window_size);
4446 defsubr (&Sset_process_inherit_coding_system_flag);
4447 defsubr (&Sprocess_inherit_coding_system_flag);
4388 defsubr (&Sprocess_kill_without_query); 4448 defsubr (&Sprocess_kill_without_query);
4389 defsubr (&Sprocess_contact); 4449 defsubr (&Sprocess_contact);
4390 defsubr (&Slist_processes); 4450 defsubr (&Slist_processes);
@@ -4417,6 +4477,8 @@ The value takes effect when `start-process' is called.");
4417 4477
4418#include "lisp.h" 4478#include "lisp.h"
4419#include "systime.h" 4479#include "systime.h"
4480#include "charset.h"
4481#include "coding.h"
4420#include "termopts.h" 4482#include "termopts.h"
4421#include "sysselect.h" 4483#include "sysselect.h"
4422 4484
@@ -4652,6 +4714,20 @@ DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
4652 return Qnil; 4714 return Qnil;
4653} 4715}
4654 4716
4717DEFUN ("process-inherit-coding-system-flag",
4718 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
4719 1, 1, 0,
4720 /* Don't confuse make-docfile by having two doc strings for this function.
4721 make-docfile does not pay attention to #if, for good reason! */
4722 0)
4723 (process)
4724 register Lisp_Object process;
4725{
4726 /* Ignore the argument and return the value of
4727 inherit-process-coding-system. */
4728 return inherit_process_coding_system ? Qt : Qnil;
4729}
4730
4655/* Kill all processes associated with `buffer'. 4731/* Kill all processes associated with `buffer'.
4656 If `buffer' is nil, kill all processes. 4732 If `buffer' is nil, kill all processes.
4657 Since we have no subprocesses, this does nothing. */ 4733 Since we have no subprocesses, this does nothing. */
@@ -4669,6 +4745,7 @@ init_process ()
4669syms_of_process () 4745syms_of_process ()
4670{ 4746{
4671 defsubr (&Sget_buffer_process); 4747 defsubr (&Sget_buffer_process);
4748 defsubr (&Sprocess_inherit_coding_system_flag);
4672} 4749}
4673 4750
4674 4751