comparison src/fileio.c @ 50530:987ee3ecc0a8

* fileio.c (Vafter_insert_file_adjust_coding_function): New variable. (syms_of_fileio): Declare it as a lisp variable. (Finsert_file_contents): Call Vafter_insert_file_adjust_coding_function before calling decode-format.
author Kenichi Handa <handa@m17n.org>
date Thu, 10 Apr 2003 12:01:10 +0000
parents 8fcca6e6a7a1
children 4a06e3332577
comparison
equal deleted inserted replaced
50529:6f2a35c77d07 50530:987ee3ecc0a8
174 /* Function to be called to decide a coding system of a reading file. */ 174 /* Function to be called to decide a coding system of a reading file. */
175 Lisp_Object Vset_auto_coding_function; 175 Lisp_Object Vset_auto_coding_function;
176 176
177 /* Functions to be called to process text properties in inserted file. */ 177 /* Functions to be called to process text properties in inserted file. */
178 Lisp_Object Vafter_insert_file_functions; 178 Lisp_Object Vafter_insert_file_functions;
179
180 /* Function to be called to adjust buffer-file-coding-system and the
181 multibyteness of the current buffer after inserting a file. */
182 Lisp_Object Vafter_insert_file_adjust_coding_function;
179 183
180 /* Functions to be called to create text property annotations for file. */ 184 /* Functions to be called to create text property annotations for file. */
181 Lisp_Object Vwrite_region_annotate_functions; 185 Lisp_Object Vwrite_region_annotate_functions;
182 186
183 /* During build_annotations, each time an annotation function is called, 187 /* During build_annotations, each time an annotation function is called,
4538 Fsignal (Qfile_error, 4542 Fsignal (Qfile_error,
4539 Fcons (build_string ("not a regular file"), 4543 Fcons (build_string ("not a regular file"),
4540 Fcons (orig_filename, Qnil))); 4544 Fcons (orig_filename, Qnil)));
4541 } 4545 }
4542 4546
4547 if (set_coding_system)
4548 Vlast_coding_system_used = coding.symbol;
4549
4550 if (FUNCTIONP (Vafter_insert_file_adjust_coding_function))
4551 {
4552 insval = call1 (Vafter_insert_file_adjust_coding_function,
4553 make_number (inserted));
4554 if (! NILP (insval))
4555 {
4556 CHECK_NUMBER (insval);
4557 inserted = XFASTINT (insval);
4558 }
4559 }
4560
4543 /* Decode file format */ 4561 /* Decode file format */
4544 if (inserted > 0) 4562 if (inserted > 0)
4545 { 4563 {
4546 int empty_undo_list_p = 0; 4564 int empty_undo_list_p = 0;
4547 4565
4560 inserted = XFASTINT (insval); 4578 inserted = XFASTINT (insval);
4561 4579
4562 if (!NILP (visit)) 4580 if (!NILP (visit))
4563 current_buffer->undo_list = empty_undo_list_p ? Qnil : Qt; 4581 current_buffer->undo_list = empty_undo_list_p ? Qnil : Qt;
4564 } 4582 }
4565
4566 if (set_coding_system)
4567 Vlast_coding_system_used = coding.symbol;
4568 4583
4569 /* Call after-change hooks for the inserted text, aside from the case 4584 /* Call after-change hooks for the inserted text, aside from the case
4570 of normal visiting (not with REPLACE), which is done in a new buffer 4585 of normal visiting (not with REPLACE), which is done in a new buffer
4571 "before" the buffer is changed. */ 4586 "before" the buffer is changed. */
4572 if (inserted > 0 && total > 0 4587 if (inserted > 0 && total > 0
6411 If no coding system is decided, it should check a coding system 6426 If no coding system is decided, it should check a coding system
6412 specified in the heading lines with the format: 6427 specified in the heading lines with the format:
6413 -*- ... coding: CODING-SYSTEM; ... -*- 6428 -*- ... coding: CODING-SYSTEM; ... -*-
6414 or local variable spec of the tailing lines with `coding:' tag. */); 6429 or local variable spec of the tailing lines with `coding:' tag. */);
6415 Vset_auto_coding_function = Qnil; 6430 Vset_auto_coding_function = Qnil;
6431
6432 DEFVAR_LISP ("after-insert-file-adjust-coding-function",
6433 &Vafter_insert_file_adjust_coding_function,
6434 doc: /* Function to call to adjust buffer-file-coding-system after inserting a file.
6435 The function is called with one arguemnt, the number of characters inserted.
6436 It should adjust `buffer-file-coding-system' and the multibyteness of
6437 the current buffer, and return the new character count. */);
6438 Vafter_insert_file_adjust_coding_function = Qnil;
6416 6439
6417 DEFVAR_LISP ("after-insert-file-functions", &Vafter_insert_file_functions, 6440 DEFVAR_LISP ("after-insert-file-functions", &Vafter_insert_file_functions,
6418 doc: /* A list of functions to be called at the end of `insert-file-contents'. 6441 doc: /* A list of functions to be called at the end of `insert-file-contents'.
6419 Each is passed one argument, the number of characters inserted. 6442 Each is passed one argument, the number of characters inserted.
6420 It should return the new character count, and leave point the same. 6443 It should return the new character count, and leave point the same.