comparison src/process.c @ 21656:bb39a5863a82

(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.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 19 Apr 1998 14:13:47 +0000
parents be8599b6636a
children 98f624ae5507
comparison
equal deleted inserted replaced
21655:cfb05eddeb55 21656:bb39a5863a82
845 return Qnil; 845 return Qnil;
846 else 846 else
847 return Qt; 847 return Qt;
848 } 848 }
849 849
850 DEFUN ("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\
854 If the second argument FLAG is non-nil, then the variable\n\
855 `buffer-file-coding-system' of the buffer associated with PROCESS\n\
856 will be bound to the value of the coding system used to decode\n\
857 the process output.\n\
858 \n\
859 This is useful when the coding system specified for the process buffer\n\
860 leaves either the character code conversion or the end-of-line conversion\n\
861 unspecified, or if the coding system used to decode the process output\n\
862 is more appropriate for saving the process buffer.\n\
863 \n\
864 Binding the variable `inherit-process-coding-system' to non-nil before\n\
865 starting the process is an alternative way of setting the inherit flag\n\
866 for 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
875 DEFUN ("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\
879 If this flag is t, `buffer-file-coding-system' of the buffer\n\
880 associated with PROCESS will inherit the coding system used to decode\n\
881 the 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
850 DEFUN ("process-kill-without-query", Fprocess_kill_without_query, 889 DEFUN ("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\
853 Optional second argument if non-nil says to require a query.\n\ 892 Optional second argument if non-nil says to require a query.\n\
854 Value is t if a query was formerly required.") 893 Value is t if a query was formerly required.")
1230 1269
1231 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 1270 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
1232 XPROCESS (proc)->decoding_carryover = make_number (0); 1271 XPROCESS (proc)->decoding_carryover = make_number (0);
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);
1274
1275 XPROCESS (proc)->inherit_coding_system_flag
1276 = (NILP (buffer) || !inherit_process_coding_system) ? 0 : 1;
1235 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);
1239 } 1281 }
2020 2062
2021 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 2063 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
2022 XPROCESS (proc)->decoding_carryover = make_number (0); 2064 XPROCESS (proc)->decoding_carryover = make_number (0);
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);
2067
2068 XPROCESS (proc)->inherit_coding_system_flag =
2069 NILP (buffer) || !inherit_process_coding_system ? 0 : 1;
2025 2070
2026 UNGCPRO; 2071 UNGCPRO;
2027 return proc; 2072 return proc;
2028 } 2073 }
2029 #endif /* HAVE_SOCKETS */ 2074 #endif /* HAVE_SOCKETS */
2868 #endif 2913 #endif
2869 2914
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))
2876 { 2934 {
2877 /* We inhibit quit here instead of just catching it so that 2935 /* We inhibit quit here instead of just catching it so that
4383 defsubr (&Sset_process_filter); 4441 defsubr (&Sset_process_filter);
4384 defsubr (&Sprocess_filter); 4442 defsubr (&Sprocess_filter);
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);
4391 defsubr (&Sprocess_list); 4451 defsubr (&Sprocess_list);
4392 defsubr (&Sstart_process); 4452 defsubr (&Sstart_process);
4415 #include <sys/types.h> 4475 #include <sys/types.h>
4416 #include <errno.h> 4476 #include <errno.h>
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
4423 extern int frame_garbaged; 4485 extern int frame_garbaged;
4424 4486
4650 register Lisp_Object name; 4712 register Lisp_Object name;
4651 { 4713 {
4652 return Qnil; 4714 return Qnil;
4653 } 4715 }
4654 4716
4717 DEFUN ("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. */
4658 4734
4659 void 4735 void
4667 } 4743 }
4668 4744
4669 syms_of_process () 4745 syms_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
4675 #endif /* not subprocesses */ 4752 #endif /* not subprocesses */