Mercurial > emacs
comparison src/fileio.c @ 50829:a4f8713c4753
(Qwrite_region_annotate_functions): New var.
(build_annotations): Use it to process the global part of the hook.
(syms_of_fileio): Init and staticpro it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 05 May 2003 18:13:08 +0000 |
parents | 4a06e3332577 |
children | 85431fbc6ac5 |
comparison
equal
deleted
inserted
replaced
50828:997060f8dbbb | 50829:a4f8713c4753 |
---|---|
181 multibyteness of the current buffer after inserting a file. */ | 181 multibyteness of the current buffer after inserting a file. */ |
182 Lisp_Object Qafter_insert_file_set_coding; | 182 Lisp_Object Qafter_insert_file_set_coding; |
183 | 183 |
184 /* Functions to be called to create text property annotations for file. */ | 184 /* Functions to be called to create text property annotations for file. */ |
185 Lisp_Object Vwrite_region_annotate_functions; | 185 Lisp_Object Vwrite_region_annotate_functions; |
186 Lisp_Object Qwrite_region_annotate_functions; | |
186 | 187 |
187 /* During build_annotations, each time an annotation function is called, | 188 /* During build_annotations, each time an annotation function is called, |
188 this holds the annotations made by the previous functions. */ | 189 this holds the annotations made by the previous functions. */ |
189 Lisp_Object Vwrite_region_annotations_so_far; | 190 Lisp_Object Vwrite_region_annotations_so_far; |
190 | 191 |
5215 { | 5216 { |
5216 Lisp_Object annotations; | 5217 Lisp_Object annotations; |
5217 Lisp_Object p, res; | 5218 Lisp_Object p, res; |
5218 struct gcpro gcpro1, gcpro2; | 5219 struct gcpro gcpro1, gcpro2; |
5219 Lisp_Object original_buffer; | 5220 Lisp_Object original_buffer; |
5220 int i; | 5221 int i, used_global = 0; |
5221 | 5222 |
5222 XSETBUFFER (original_buffer, current_buffer); | 5223 XSETBUFFER (original_buffer, current_buffer); |
5223 | 5224 |
5224 annotations = Qnil; | 5225 annotations = Qnil; |
5225 p = Vwrite_region_annotate_functions; | 5226 p = Vwrite_region_annotate_functions; |
5226 GCPRO2 (annotations, p); | 5227 GCPRO2 (annotations, p); |
5227 while (CONSP (p)) | 5228 while (CONSP (p)) |
5228 { | 5229 { |
5229 struct buffer *given_buffer = current_buffer; | 5230 struct buffer *given_buffer = current_buffer; |
5231 if (EQ (Qt, XCAR (p)) && !used_global) | |
5232 { /* Use the global value of the hook. */ | |
5233 Lisp_Object arg[2]; | |
5234 used_global = 1; | |
5235 arg[0] = Fdefault_value (Qwrite_region_annotate_functions); | |
5236 arg[1] = XCDR (p); | |
5237 p = Fappend (2, arg); | |
5238 continue; | |
5239 } | |
5230 Vwrite_region_annotations_so_far = annotations; | 5240 Vwrite_region_annotations_so_far = annotations; |
5231 res = call2 (XCAR (p), start, end); | 5241 res = call2 (XCAR (p), start, end); |
5232 /* If the function makes a different buffer current, | 5242 /* If the function makes a different buffer current, |
5233 assume that means this buffer contains altered text to be output. | 5243 assume that means this buffer contains altered text to be output. |
5234 Reset START and END from the buffer bounds | 5244 Reset START and END from the buffer bounds |
6447 of the form (POSITION . STRING), consisting of strings to be effectively | 6457 of the form (POSITION . STRING), consisting of strings to be effectively |
6448 inserted at the specified positions of the file being written (1 means to | 6458 inserted at the specified positions of the file being written (1 means to |
6449 insert before the first byte written). The POSITIONs must be sorted into | 6459 insert before the first byte written). The POSITIONs must be sorted into |
6450 increasing order. If there are several functions in the list, the several | 6460 increasing order. If there are several functions in the list, the several |
6451 lists are merged destructively. Alternatively, the function can return | 6461 lists are merged destructively. Alternatively, the function can return |
6452 with a different buffer current and value nil.*/); | 6462 with a different buffer current; in that case it should pay attention |
6463 to the annotations returned by previous functions and listed in | |
6464 `write-region-annotations-so-far'.*/); | |
6453 Vwrite_region_annotate_functions = Qnil; | 6465 Vwrite_region_annotate_functions = Qnil; |
6466 staticpro (&Qwrite_region_annotate_functions); | |
6467 Qwrite_region_annotate_functions | |
6468 = intern ("write-region-annotate-functions"); | |
6454 | 6469 |
6455 DEFVAR_LISP ("write-region-annotations-so-far", | 6470 DEFVAR_LISP ("write-region-annotations-so-far", |
6456 &Vwrite_region_annotations_so_far, | 6471 &Vwrite_region_annotations_so_far, |
6457 doc: /* When an annotation function is called, this holds the previous annotations. | 6472 doc: /* When an annotation function is called, this holds the previous annotations. |
6458 These are the annotations made by other annotation functions | 6473 These are the annotations made by other annotation functions |