Mercurial > hg > xemacs-beta
comparison src/buffer.c @ 408:501cfd01ee6d r21-2-34
Import from CVS: tag r21-2-34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:18:11 +0200 |
parents | b8cc9ab3f761 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
407:ed6218a7d4d3 | 408:501cfd01ee6d |
---|---|
1828 } | 1828 } |
1829 #else | 1829 #else |
1830 #define coding_system_is_binary(coding_system) 1 | 1830 #define coding_system_is_binary(coding_system) 1 |
1831 #endif | 1831 #endif |
1832 | 1832 |
1833 static Extbyte_dynarr *conversion_out_dynarr; | 1833 typedef struct |
1834 static Bufbyte_dynarr *conversion_in_dynarr; | 1834 { |
1835 Dynarr_declare (Bufbyte_dynarr *); | |
1836 } Bufbyte_dynarr_dynarr; | |
1837 | |
1838 typedef struct | |
1839 { | |
1840 Dynarr_declare (Extbyte_dynarr *); | |
1841 } Extbyte_dynarr_dynarr; | |
1842 | |
1843 static Extbyte_dynarr_dynarr *conversion_out_dynarr_list; | |
1844 static Bufbyte_dynarr_dynarr *conversion_in_dynarr_list; | |
1835 | 1845 |
1836 static int dfc_convert_to_external_format_in_use; | 1846 static int dfc_convert_to_external_format_in_use; |
1837 static int dfc_convert_to_internal_format_in_use; | 1847 static int dfc_convert_to_internal_format_in_use; |
1838 | 1848 |
1839 static Lisp_Object | 1849 static Lisp_Object |
1858 #endif | 1868 #endif |
1859 dfc_conversion_type sink_type, | 1869 dfc_conversion_type sink_type, |
1860 dfc_conversion_data *sink) | 1870 dfc_conversion_data *sink) |
1861 { | 1871 { |
1862 int count = specpdl_depth (); | 1872 int count = specpdl_depth (); |
1873 Extbyte_dynarr *conversion_out_dynarr; | |
1863 | 1874 |
1864 type_checking_assert | 1875 type_checking_assert |
1865 (((source_type == DFC_TYPE_DATA) || | 1876 (((source_type == DFC_TYPE_DATA) || |
1866 (source_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object)) || | 1877 (source_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object)) || |
1867 (source_type == DFC_TYPE_LISP_STRING && STRINGP (source->lisp_object))) | 1878 (source_type == DFC_TYPE_LISP_STRING && STRINGP (source->lisp_object))) |
1868 && | 1879 && |
1869 ((sink_type == DFC_TYPE_DATA) || | 1880 ((sink_type == DFC_TYPE_DATA) || |
1870 (sink_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object)))); | 1881 (sink_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object)))); |
1871 | 1882 |
1872 if (dfc_convert_to_external_format_in_use != 0) | |
1873 error ("Can't call a conversion function from a conversion function"); | |
1874 else | |
1875 dfc_convert_to_external_format_in_use = 1; | |
1876 | |
1877 record_unwind_protect (dfc_convert_to_external_format_reset_in_use, | 1883 record_unwind_protect (dfc_convert_to_external_format_reset_in_use, |
1878 Qzero); | 1884 make_int (dfc_convert_to_external_format_in_use)); |
1885 if (Dynarr_length (conversion_out_dynarr_list) <= | |
1886 dfc_convert_to_external_format_in_use) | |
1887 Dynarr_add (conversion_out_dynarr_list, Dynarr_new (Extbyte)); | |
1888 conversion_out_dynarr = Dynarr_at (conversion_out_dynarr_list, | |
1889 dfc_convert_to_external_format_in_use); | |
1890 dfc_convert_to_external_format_in_use++; | |
1891 Dynarr_reset (conversion_out_dynarr); | |
1879 | 1892 |
1880 #ifdef FILE_CODING | 1893 #ifdef FILE_CODING |
1881 coding_system = Fget_coding_system (coding_system); | 1894 coding_system = Fget_coding_system (coding_system); |
1882 #endif | 1895 #endif |
1883 | |
1884 Dynarr_reset (conversion_out_dynarr); | |
1885 | 1896 |
1886 /* Here we optimize in the case where the coding system does no | 1897 /* Here we optimize in the case where the coding system does no |
1887 conversion. However, we don't want to optimize in case the source | 1898 conversion. However, we don't want to optimize in case the source |
1888 or sink is an lstream, since writing to an lstream can cause a | 1899 or sink is an lstream, since writing to an lstream can cause a |
1889 garbage collection, and this could be problematic if the source | 1900 garbage collection, and this could be problematic if the source |
2013 #endif | 2024 #endif |
2014 dfc_conversion_type sink_type, | 2025 dfc_conversion_type sink_type, |
2015 dfc_conversion_data *sink) | 2026 dfc_conversion_data *sink) |
2016 { | 2027 { |
2017 int count = specpdl_depth (); | 2028 int count = specpdl_depth (); |
2029 Bufbyte_dynarr *conversion_in_dynarr; | |
2018 | 2030 |
2019 type_checking_assert | 2031 type_checking_assert |
2020 ((source_type == DFC_TYPE_DATA || | 2032 ((source_type == DFC_TYPE_DATA || |
2021 source_type == DFC_TYPE_LISP_LSTREAM) | 2033 source_type == DFC_TYPE_LISP_LSTREAM) |
2022 && | 2034 && |
2023 (sink_type == DFC_TYPE_DATA || | 2035 (sink_type == DFC_TYPE_DATA || |
2024 sink_type == DFC_TYPE_LISP_LSTREAM)); | 2036 sink_type == DFC_TYPE_LISP_LSTREAM)); |
2025 | 2037 |
2026 if (dfc_convert_to_internal_format_in_use != 0) | |
2027 error ("Can't call a conversion function from a conversion function"); | |
2028 else | |
2029 dfc_convert_to_internal_format_in_use = 1; | |
2030 | |
2031 record_unwind_protect (dfc_convert_to_internal_format_reset_in_use, | 2038 record_unwind_protect (dfc_convert_to_internal_format_reset_in_use, |
2032 Qzero); | 2039 make_int (dfc_convert_to_internal_format_in_use)); |
2040 if (Dynarr_length (conversion_in_dynarr_list) <= | |
2041 dfc_convert_to_internal_format_in_use) | |
2042 Dynarr_add (conversion_in_dynarr_list, Dynarr_new (Bufbyte)); | |
2043 conversion_in_dynarr = Dynarr_at (conversion_in_dynarr_list, | |
2044 dfc_convert_to_internal_format_in_use); | |
2045 dfc_convert_to_internal_format_in_use++; | |
2046 Dynarr_reset (conversion_in_dynarr); | |
2033 | 2047 |
2034 #ifdef FILE_CODING | 2048 #ifdef FILE_CODING |
2035 coding_system = Fget_coding_system (coding_system); | 2049 coding_system = Fget_coding_system (coding_system); |
2036 #endif | 2050 #endif |
2037 | |
2038 Dynarr_reset (conversion_in_dynarr); | |
2039 | 2051 |
2040 if (source_type != DFC_TYPE_LISP_LSTREAM && | 2052 if (source_type != DFC_TYPE_LISP_LSTREAM && |
2041 sink_type != DFC_TYPE_LISP_LSTREAM && | 2053 sink_type != DFC_TYPE_LISP_LSTREAM && |
2042 coding_system_is_binary (coding_system)) | 2054 coding_system_is_binary (coding_system)) |
2043 { | 2055 { |
2216 } | 2228 } |
2217 | 2229 |
2218 void | 2230 void |
2219 reinit_vars_of_buffer (void) | 2231 reinit_vars_of_buffer (void) |
2220 { | 2232 { |
2221 conversion_in_dynarr = Dynarr_new (Bufbyte); | 2233 conversion_in_dynarr_list = Dynarr_new2 (Bufbyte_dynarr_dynarr, |
2222 conversion_out_dynarr = Dynarr_new (Extbyte); | 2234 Bufbyte_dynarr *); |
2235 conversion_out_dynarr_list = Dynarr_new2 (Extbyte_dynarr_dynarr, | |
2236 Extbyte_dynarr *); | |
2223 | 2237 |
2224 staticpro_nodump (&Vbuffer_alist); | 2238 staticpro_nodump (&Vbuffer_alist); |
2225 Vbuffer_alist = Qnil; | 2239 Vbuffer_alist = Qnil; |
2226 current_buffer = 0; | 2240 current_buffer = 0; |
2227 } | 2241 } |
2659 */ ); | 2673 */ ); |
2660 | 2674 |
2661 DEFVAR_BUFFER_LOCAL ("modeline-format", modeline_format /* | 2675 DEFVAR_BUFFER_LOCAL ("modeline-format", modeline_format /* |
2662 Template for displaying modeline for current buffer. | 2676 Template for displaying modeline for current buffer. |
2663 Each buffer has its own value of this variable. | 2677 Each buffer has its own value of this variable. |
2664 Value may be a string, a symbol or a list or cons cell. | 2678 Value may be a string, symbol, glyph, generic specifier, list or cons cell. |
2665 For a symbol, its value is used (but it is ignored if t or nil). | 2679 For a symbol, its value is processed (but it is ignored if t or nil). |
2666 A string appearing directly as the value of a symbol is processed verbatim | 2680 A string appearing directly as the value of a symbol is processed verbatim |
2667 in that the %-constructs below are not recognized. | 2681 in that the %-constructs below are not recognized. |
2668 For a glyph, it is inserted as is. | 2682 For a glyph, it is inserted as is. |
2683 For a generic specifier (i.e. a specifier of type `generic'), its instance | |
2684 is computed in the current window using the equivalent of `specifier-instance' | |
2685 and the value is processed. | |
2669 For a list whose car is a symbol, the symbol's value is taken, | 2686 For a list whose car is a symbol, the symbol's value is taken, |
2670 and if that is non-nil, the cadr of the list is processed recursively. | 2687 and if that is non-nil, the cadr of the list is processed recursively. |
2671 Otherwise, the caddr of the list (if there is one) is processed. | 2688 Otherwise, the caddr of the list (if there is one) is processed. |
2672 For a list whose car is a string or list, each element is processed | 2689 For a list whose car is a string or list, each element is processed |
2673 recursively and the results are effectively concatenated. | 2690 recursively and the results are effectively concatenated. |
2674 For a list whose car is an integer, the cdr of the list is processed | 2691 For a list whose car is an integer, the cdr of the list is processed |
2675 and padded (if the number is positive) or truncated (if negative) | 2692 and padded (if the number is positive) or truncated (if negative) |
2676 to the width specified by that number. | 2693 to the width specified by that number. |
2677 For a list whose car is an extent, the cdr of the list is processed | 2694 For a list whose car is an extent, the cdr of the list is processed |
2678 normally but the results are displayed using the face of the | 2695 normally but the results are displayed using the face of the |
2679 extent, and mouse clicks over this section are processed using the | 2696 extent, and mouse clicks over this section are processed using the |
2680 keymap of the extent. (In addition, if the extent has a help-echo | 2697 keymap of the extent. (In addition, if the extent has a help-echo |
2681 property, that string will be echoed when the mouse moves over this | 2698 property, that string will be echoed when the mouse moves over this |
2682 section.) See `generated-modeline-string' for more information. | 2699 section.) If extents are nested, all keymaps are properly consulted |
2683 For a list whose car is a face, the cdr of the list is processed | 2700 when processing mouse clicks, but multiple faces are not correctly |
2684 normally but the results will be displayed using the face in the car. | 2701 merged (only the first face is used), and lists of faces are not |
2685 For a list whose car is a keymap, the cdr of the list is processed | 2702 correctly handled. See `generated-modeline-string' for more information. |
2686 normally but the keymap will apply for mouse clicks over the results, | |
2687 in addition to `modeline-map'. Nested keymap specifications are | |
2688 handled properly. | |
2689 A string is printed verbatim in the modeline except for %-constructs: | 2703 A string is printed verbatim in the modeline except for %-constructs: |
2690 (%-constructs are processed when the string is the entire modeline-format | 2704 (%-constructs are processed when the string is the entire modeline-format |
2691 or when it is found in a cons-cell or a list) | 2705 or when it is found in a cons-cell or a list) |
2692 %b -- print buffer name. %c -- print the current column number. | 2706 %b -- print buffer name. %c -- print the current column number. |
2693 %f -- print visited file name. | 2707 %f -- print visited file name. |