Mercurial > emacs
changeset 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 | cfb05eddeb55 |
children | 373f809e0b95 |
files | src/process.c |
diffstat | 1 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/process.c Sun Apr 19 03:46:53 1998 +0000 +++ b/src/process.c Sun Apr 19 14:13:47 1998 +0000 @@ -847,6 +847,45 @@ return Qt; } +DEFUN ("set-process-inherit-coding-system-flag", + Fset_process_inherit_coding_system_flag, + Sset_process_inherit_coding_system_flag, 2, 2, 0, + "Determine whether buffer of PROCESS will inherit coding-system.\n\ +If the second argument FLAG is non-nil, then the variable\n\ +`buffer-file-coding-system' of the buffer associated with PROCESS\n\ +will be bound to the value of the coding system used to decode\n\ +the process output.\n\ +\n\ +This is useful when the coding system specified for the process buffer\n\ +leaves either the character code conversion or the end-of-line conversion\n\ +unspecified, or if the coding system used to decode the process output\n\ +is more appropriate for saving the process buffer.\n\ +\n\ +Binding the variable `inherit-process-coding-system' to non-nil before\n\ +starting the process is an alternative way of setting the inherit flag\n\ +for the process which will run.") + (process, flag) + register Lisp_Object process, flag; +{ + CHECK_PROCESS (process, 0); + XPROCESS (process)->inherit_coding_system_flag = !Fnull (flag); + return flag; +} + +DEFUN ("process-inherit-coding-system-flag", + Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, + 1, 1, 0, + "Return the value of inherit-coding-system flag for PROCESS.\n\ +If this flag is t, `buffer-file-coding-system' of the buffer\n\ +associated with PROCESS will inherit the coding system used to decode\n\ +the process output.") + (process) + register Lisp_Object process; +{ + CHECK_PROCESS (process, 0); + return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil; +} + DEFUN ("process-kill-without-query", Fprocess_kill_without_query, Sprocess_kill_without_query, 1, 2, 0, "Say no query needed if PROCESS is running when Emacs is exited.\n\ @@ -1233,6 +1272,9 @@ XPROCESS (proc)->encoding_buf = make_uninit_string (0); XPROCESS (proc)->encoding_carryover = make_number (0); + XPROCESS (proc)->inherit_coding_system_flag + = (NILP (buffer) || !inherit_process_coding_system) ? 0 : 1; + create_process (proc, (char **) new_argv, current_dir); return unbind_to (count, proc); @@ -2023,6 +2065,9 @@ XPROCESS (proc)->encoding_buf = make_uninit_string (0); XPROCESS (proc)->encoding_carryover = make_number (0); + XPROCESS (proc)->inherit_coding_system_flag = + NILP (buffer) || !inherit_process_coding_system ? 0 : 1; + UNGCPRO; return proc; } @@ -2870,6 +2915,19 @@ XSETINT (p->decoding_carryover, carryover); Vlast_coding_system_used = coding->symbol; + /* If the caller required, let the process associated buffer + inherit the coding-system used to decode the process output. */ + if (p->inherit_coding_system_flag + && !NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) + { + struct buffer *prev_buf = current_buffer; + + Fset_buffer (p->buffer); + call1 (intern ("after-insert-file-set-buffer-file-coding-system"), + make_number (nbytes)); + set_buffer_internal (prev_buf); + } + /* Read and dispose of the process output. */ outstream = p->filter; if (!NILP (outstream)) @@ -4385,6 +4443,8 @@ defsubr (&Sset_process_sentinel); defsubr (&Sprocess_sentinel); defsubr (&Sset_process_window_size); + defsubr (&Sset_process_inherit_coding_system_flag); + defsubr (&Sprocess_inherit_coding_system_flag); defsubr (&Sprocess_kill_without_query); defsubr (&Sprocess_contact); defsubr (&Slist_processes); @@ -4417,6 +4477,8 @@ #include "lisp.h" #include "systime.h" +#include "charset.h" +#include "coding.h" #include "termopts.h" #include "sysselect.h" @@ -4652,6 +4714,20 @@ return Qnil; } +DEFUN ("process-inherit-coding-system-flag", + Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, + 1, 1, 0, + /* Don't confuse make-docfile by having two doc strings for this function. + make-docfile does not pay attention to #if, for good reason! */ + 0) + (process) + register Lisp_Object process; +{ + /* Ignore the argument and return the value of + inherit-process-coding-system. */ + return inherit_process_coding_system ? Qt : Qnil; +} + /* Kill all processes associated with `buffer'. If `buffer' is nil, kill all processes. Since we have no subprocesses, this does nothing. */ @@ -4669,6 +4745,7 @@ syms_of_process () { defsubr (&Sget_buffer_process); + defsubr (&Sprocess_inherit_coding_system_flag); }