Mercurial > emacs
comparison src/buffer.c @ 109144:7dceae91724c
Convert most remaining function definitions to standard C.
* buffer.c, cm.c, eval.c, keyboard.c, process.c, term.c, vm-limit.c,
* xdisp.c: Convert function definitions to standard C.
* cm.c (cmputc): Arg C is now int, not char.
* process.c (Fmake_network_process): Cast sockaddr_in* to sockaddr*.
| author | Juanma Barranquero <lekktu@gmail.com> |
|---|---|
| date | Mon, 05 Jul 2010 12:36:06 +0200 |
| parents | 2bc9a0c04c87 |
| children | 750db9f3e6d8 |
comparison
equal
deleted
inserted
replaced
| 109143:a08a6559b47b | 109144:7dceae91724c |
|---|---|
| 178 | 178 |
| 179 /* For debugging; temporary. See set_buffer_internal. */ | 179 /* For debugging; temporary. See set_buffer_internal. */ |
| 180 /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ | 180 /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ |
| 181 | 181 |
| 182 void | 182 void |
| 183 nsberror (spec) | 183 nsberror (Lisp_Object spec) |
| 184 Lisp_Object spec; | |
| 185 { | 184 { |
| 186 if (STRINGP (spec)) | 185 if (STRINGP (spec)) |
| 187 error ("No buffer named %s", SDATA (spec)); | 186 error ("No buffer named %s", SDATA (spec)); |
| 188 error ("Invalid buffer argument"); | 187 error ("Invalid buffer argument"); |
| 189 } | 188 } |
| 246 /* Like Fassoc, but use Fstring_equal to compare | 245 /* Like Fassoc, but use Fstring_equal to compare |
| 247 (which ignores text properties), | 246 (which ignores text properties), |
| 248 and don't ever QUIT. */ | 247 and don't ever QUIT. */ |
| 249 | 248 |
| 250 static Lisp_Object | 249 static Lisp_Object |
| 251 assoc_ignore_text_properties (key, list) | 250 assoc_ignore_text_properties (register Lisp_Object key, Lisp_Object list) |
| 252 register Lisp_Object key; | |
| 253 Lisp_Object list; | |
| 254 { | 251 { |
| 255 register Lisp_Object tail; | 252 register Lisp_Object tail; |
| 256 for (tail = list; CONSP (tail); tail = XCDR (tail)) | 253 for (tail = list; CONSP (tail); tail = XCDR (tail)) |
| 257 { | 254 { |
| 258 register Lisp_Object elt, tem; | 255 register Lisp_Object elt, tem; |
| 310 } | 307 } |
| 311 return Qnil; | 308 return Qnil; |
| 312 } | 309 } |
| 313 | 310 |
| 314 Lisp_Object | 311 Lisp_Object |
| 315 get_truename_buffer (filename) | 312 get_truename_buffer (register Lisp_Object filename) |
| 316 register Lisp_Object filename; | |
| 317 { | 313 { |
| 318 register Lisp_Object tail, buf, tem; | 314 register Lisp_Object tail, buf, tem; |
| 319 | 315 |
| 320 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) | 316 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
| 321 { | 317 { |
| 435 | 431 |
| 436 /* Return a list of overlays which is a copy of the overlay list | 432 /* Return a list of overlays which is a copy of the overlay list |
| 437 LIST, but for buffer B. */ | 433 LIST, but for buffer B. */ |
| 438 | 434 |
| 439 static struct Lisp_Overlay * | 435 static struct Lisp_Overlay * |
| 440 copy_overlays (b, list) | 436 copy_overlays (struct buffer *b, struct Lisp_Overlay *list) |
| 441 struct buffer *b; | |
| 442 struct Lisp_Overlay *list; | |
| 443 { | 437 { |
| 444 Lisp_Object buffer; | 438 Lisp_Object buffer; |
| 445 struct Lisp_Overlay *result = NULL, *tail = NULL; | 439 struct Lisp_Overlay *result = NULL, *tail = NULL; |
| 446 | 440 |
| 447 XSETBUFFER (buffer, b); | 441 XSETBUFFER (buffer, b); |
| 487 following exceptions: (1) TO's name is left untouched, (2) markers | 481 following exceptions: (1) TO's name is left untouched, (2) markers |
| 488 are copied and made to refer to TO, and (3) overlay lists are | 482 are copied and made to refer to TO, and (3) overlay lists are |
| 489 copied. */ | 483 copied. */ |
| 490 | 484 |
| 491 static void | 485 static void |
| 492 clone_per_buffer_values (from, to) | 486 clone_per_buffer_values (struct buffer *from, struct buffer *to) |
| 493 struct buffer *from, *to; | |
| 494 { | 487 { |
| 495 Lisp_Object to_buffer; | 488 Lisp_Object to_buffer; |
| 496 int offset; | 489 int offset; |
| 497 | 490 |
| 498 XSETBUFFER (to_buffer, to); | 491 XSETBUFFER (to_buffer, to); |
| 656 | 649 |
| 657 return buf; | 650 return buf; |
| 658 } | 651 } |
| 659 | 652 |
| 660 void | 653 void |
| 661 delete_all_overlays (b) | 654 delete_all_overlays (struct buffer *b) |
| 662 struct buffer *b; | |
| 663 { | 655 { |
| 664 Lisp_Object overlay; | 656 Lisp_Object overlay; |
| 665 | 657 |
| 666 /* `reset_buffer' blindly sets the list of overlays to NULL, so we | 658 /* `reset_buffer' blindly sets the list of overlays to NULL, so we |
| 667 have to empty the list, otherwise we end up with overlays that | 659 have to empty the list, otherwise we end up with overlays that |
| 687 should be deleted before calling this function, otherwise we end up | 679 should be deleted before calling this function, otherwise we end up |
| 688 with overlays that claim to belong to the buffer but the buffer | 680 with overlays that claim to belong to the buffer but the buffer |
| 689 claims it doesn't belong to it. */ | 681 claims it doesn't belong to it. */ |
| 690 | 682 |
| 691 void | 683 void |
| 692 reset_buffer (b) | 684 reset_buffer (register struct buffer *b) |
| 693 register struct buffer *b; | |
| 694 { | 685 { |
| 695 b->filename = Qnil; | 686 b->filename = Qnil; |
| 696 b->file_truename = Qnil; | 687 b->file_truename = Qnil; |
| 697 b->directory = (current_buffer) ? current_buffer->directory : Qnil; | 688 b->directory = (current_buffer) ? current_buffer->directory : Qnil; |
| 698 b->modtime = 0; | 689 b->modtime = 0; |
| 732 If PERMANENT_TOO is 1, then we reset permanent | 723 If PERMANENT_TOO is 1, then we reset permanent |
| 733 buffer-local variables. If PERMANENT_TOO is 0, | 724 buffer-local variables. If PERMANENT_TOO is 0, |
| 734 we preserve those. */ | 725 we preserve those. */ |
| 735 | 726 |
| 736 static void | 727 static void |
| 737 reset_buffer_local_variables (b, permanent_too) | 728 reset_buffer_local_variables (register struct buffer *b, int permanent_too) |
| 738 register struct buffer *b; | |
| 739 int permanent_too; | |
| 740 { | 729 { |
| 741 register int offset; | 730 register int offset; |
| 742 int i; | 731 int i; |
| 743 | 732 |
| 744 /* Reset the major mode to Fundamental, together with all the | 733 /* Reset the major mode to Fundamental, together with all the |
| 991 /* Return an alist of the Lisp-level buffer-local bindings of | 980 /* Return an alist of the Lisp-level buffer-local bindings of |
| 992 buffer BUF. That is, don't include the variables maintained | 981 buffer BUF. That is, don't include the variables maintained |
| 993 in special slots in the buffer object. */ | 982 in special slots in the buffer object. */ |
| 994 | 983 |
| 995 static Lisp_Object | 984 static Lisp_Object |
| 996 buffer_lisp_local_variables (buf) | 985 buffer_lisp_local_variables (struct buffer *buf) |
| 997 struct buffer *buf; | |
| 998 { | 986 { |
| 999 Lisp_Object result = Qnil; | 987 Lisp_Object result = Qnil; |
| 1000 register Lisp_Object tail; | 988 register Lisp_Object tail; |
| 1001 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) | 989 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) |
| 1002 { | 990 { |
| 1291 If no other buffer exists, the buffer `*scratch*' is returned. | 1279 If no other buffer exists, the buffer `*scratch*' is returned. |
| 1292 If BUFFER is omitted or nil, some interesting buffer is returned. */) | 1280 If BUFFER is omitted or nil, some interesting buffer is returned. */) |
| 1293 (buffer, visible_ok, frame) | 1281 (buffer, visible_ok, frame) |
| 1294 register Lisp_Object buffer, visible_ok, frame; | 1282 register Lisp_Object buffer, visible_ok, frame; |
| 1295 { | 1283 { |
| 1296 Lisp_Object Fset_buffer_major_mode (); | 1284 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer); |
| 1297 register Lisp_Object tail, buf, notsogood, tem, pred, add_ons; | 1285 register Lisp_Object tail, buf, notsogood, tem, pred, add_ons; |
| 1298 notsogood = Qnil; | 1286 notsogood = Qnil; |
| 1299 | 1287 |
| 1300 if (NILP (frame)) | 1288 if (NILP (frame)) |
| 1301 frame = selected_frame; | 1289 frame = selected_frame; |
| 1616 we do this each time BUF is selected visibly, the more recently | 1604 we do this each time BUF is selected visibly, the more recently |
| 1617 selected buffers are always closer to the front of the list. This | 1605 selected buffers are always closer to the front of the list. This |
| 1618 means that other_buffer is more likely to choose a relevant buffer. */ | 1606 means that other_buffer is more likely to choose a relevant buffer. */ |
| 1619 | 1607 |
| 1620 void | 1608 void |
| 1621 record_buffer (buf) | 1609 record_buffer (Lisp_Object buf) |
| 1622 Lisp_Object buf; | |
| 1623 { | 1610 { |
| 1624 register Lisp_Object link, prev; | 1611 register Lisp_Object link, prev; |
| 1625 Lisp_Object frame; | 1612 Lisp_Object frame; |
| 1626 frame = selected_frame; | 1613 frame = selected_frame; |
| 1627 | 1614 |
| 1732 | 1719 |
| 1733 /* Switch to buffer BUFFER in the selected window. | 1720 /* Switch to buffer BUFFER in the selected window. |
| 1734 If NORECORD is non-nil, don't call record_buffer. */ | 1721 If NORECORD is non-nil, don't call record_buffer. */ |
| 1735 | 1722 |
| 1736 Lisp_Object | 1723 Lisp_Object |
| 1737 switch_to_buffer_1 (buffer_or_name, norecord) | 1724 switch_to_buffer_1 (Lisp_Object buffer_or_name, Lisp_Object norecord) |
| 1738 Lisp_Object buffer_or_name, norecord; | |
| 1739 { | 1725 { |
| 1740 register Lisp_Object buffer; | 1726 register Lisp_Object buffer; |
| 1741 | 1727 |
| 1742 if (NILP (buffer_or_name)) | 1728 if (NILP (buffer_or_name)) |
| 1743 buffer = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil); | 1729 buffer = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil); |
| 1829 information on a buffer-basis. Every action affecting other | 1815 information on a buffer-basis. Every action affecting other |
| 1830 windows than the selected one requires a select_window at some | 1816 windows than the selected one requires a select_window at some |
| 1831 time, and that increments windows_or_buffers_changed. */ | 1817 time, and that increments windows_or_buffers_changed. */ |
| 1832 | 1818 |
| 1833 void | 1819 void |
| 1834 set_buffer_internal (b) | 1820 set_buffer_internal (register struct buffer *b) |
| 1835 register struct buffer *b; | |
| 1836 { | 1821 { |
| 1837 if (current_buffer != b) | 1822 if (current_buffer != b) |
| 1838 set_buffer_internal_1 (b); | 1823 set_buffer_internal_1 (b); |
| 1839 } | 1824 } |
| 1840 | 1825 |
| 1841 /* Set the current buffer to B, and do not set windows_or_buffers_changed. | 1826 /* Set the current buffer to B, and do not set windows_or_buffers_changed. |
| 1842 This is used by redisplay. */ | 1827 This is used by redisplay. */ |
| 1843 | 1828 |
| 1844 void | 1829 void |
| 1845 set_buffer_internal_1 (b) | 1830 set_buffer_internal_1 (register struct buffer *b) |
| 1846 register struct buffer *b; | |
| 1847 { | 1831 { |
| 1848 register struct buffer *old_buf; | 1832 register struct buffer *old_buf; |
| 1849 register Lisp_Object tail; | 1833 register Lisp_Object tail; |
| 1850 | 1834 |
| 1851 #ifdef USE_MMAP_FOR_BUFFERS | 1835 #ifdef USE_MMAP_FOR_BUFFERS |
| 1937 | 1921 |
| 1938 /* Switch to buffer B temporarily for redisplay purposes. | 1922 /* Switch to buffer B temporarily for redisplay purposes. |
| 1939 This avoids certain things that don't need to be done within redisplay. */ | 1923 This avoids certain things that don't need to be done within redisplay. */ |
| 1940 | 1924 |
| 1941 void | 1925 void |
| 1942 set_buffer_temp (b) | 1926 set_buffer_temp (struct buffer *b) |
| 1943 struct buffer *b; | |
| 1944 { | 1927 { |
| 1945 register struct buffer *old_buf; | 1928 register struct buffer *old_buf; |
| 1946 | 1929 |
| 1947 if (current_buffer == b) | 1930 if (current_buffer == b) |
| 1948 return; | 1931 return; |
| 2017 } | 2000 } |
| 2018 | 2001 |
| 2019 /* Set the current buffer to BUFFER provided it is alive. */ | 2002 /* Set the current buffer to BUFFER provided it is alive. */ |
| 2020 | 2003 |
| 2021 Lisp_Object | 2004 Lisp_Object |
| 2022 set_buffer_if_live (buffer) | 2005 set_buffer_if_live (Lisp_Object buffer) |
| 2023 Lisp_Object buffer; | |
| 2024 { | 2006 { |
| 2025 if (! NILP (XBUFFER (buffer)->name)) | 2007 if (! NILP (XBUFFER (buffer)->name)) |
| 2026 Fset_buffer (buffer); | 2008 Fset_buffer (buffer); |
| 2027 return Qnil; | 2009 return Qnil; |
| 2028 } | 2010 } |
| 2118 XSETFASTINT (current_buffer->save_length, 0); | 2100 XSETFASTINT (current_buffer->save_length, 0); |
| 2119 return Qnil; | 2101 return Qnil; |
| 2120 } | 2102 } |
| 2121 | 2103 |
| 2122 void | 2104 void |
| 2123 validate_region (b, e) | 2105 validate_region (register Lisp_Object *b, register Lisp_Object *e) |
| 2124 register Lisp_Object *b, *e; | |
| 2125 { | 2106 { |
| 2126 CHECK_NUMBER_COERCE_MARKER (*b); | 2107 CHECK_NUMBER_COERCE_MARKER (*b); |
| 2127 CHECK_NUMBER_COERCE_MARKER (*e); | 2108 CHECK_NUMBER_COERCE_MARKER (*e); |
| 2128 | 2109 |
| 2129 if (XINT (*b) > XINT (*e)) | 2110 if (XINT (*b) > XINT (*e)) |
| 2139 | 2120 |
| 2140 /* Advance BYTE_POS up to a character boundary | 2121 /* Advance BYTE_POS up to a character boundary |
| 2141 and return the adjusted position. */ | 2122 and return the adjusted position. */ |
| 2142 | 2123 |
| 2143 static int | 2124 static int |
| 2144 advance_to_char_boundary (byte_pos) | 2125 advance_to_char_boundary (int byte_pos) |
| 2145 int byte_pos; | |
| 2146 { | 2126 { |
| 2147 int c; | 2127 int c; |
| 2148 | 2128 |
| 2149 if (byte_pos == BEG) | 2129 if (byte_pos == BEG) |
| 2150 /* Beginning of buffer is always a character boundary. */ | 2130 /* Beginning of buffer is always a character boundary. */ |
| 2642 | 2622 |
| 2643 /* Make sure no local variables remain set up with buffer B | 2623 /* Make sure no local variables remain set up with buffer B |
| 2644 for their current values. */ | 2624 for their current values. */ |
| 2645 | 2625 |
| 2646 static void | 2626 static void |
| 2647 swap_out_buffer_local_variables (b) | 2627 swap_out_buffer_local_variables (struct buffer *b) |
| 2648 struct buffer *b; | |
| 2649 { | 2628 { |
| 2650 Lisp_Object oalist, alist, buffer; | 2629 Lisp_Object oalist, alist, buffer; |
| 2651 | 2630 |
| 2652 XSETBUFFER (buffer, b); | 2631 XSETBUFFER (buffer, b); |
| 2653 oalist = b->local_var_alist; | 2632 oalist = b->local_var_alist; |
| 2688 If CHANGE_REQ is true, then any position written into *PREV_PTR or | 2667 If CHANGE_REQ is true, then any position written into *PREV_PTR or |
| 2689 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the | 2668 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the |
| 2690 default (BEGV or ZV). */ | 2669 default (BEGV or ZV). */ |
| 2691 | 2670 |
| 2692 int | 2671 int |
| 2693 overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) | 2672 overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, int *len_ptr, |
| 2694 EMACS_INT pos; | 2673 EMACS_INT *next_ptr, EMACS_INT *prev_ptr, int change_req) |
| 2695 int extend; | |
| 2696 Lisp_Object **vec_ptr; | |
| 2697 int *len_ptr; | |
| 2698 EMACS_INT *next_ptr; | |
| 2699 EMACS_INT *prev_ptr; | |
| 2700 int change_req; | |
| 2701 { | 2674 { |
| 2702 Lisp_Object overlay, start, end; | 2675 Lisp_Object overlay, start, end; |
| 2703 struct Lisp_Overlay *tail; | 2676 struct Lisp_Overlay *tail; |
| 2704 int idx = 0; | 2677 int idx = 0; |
| 2705 int len = *len_ptr; | 2678 int len = *len_ptr; |
| 2833 If EXTEND is zero, we never extend the vector, | 2806 If EXTEND is zero, we never extend the vector, |
| 2834 and we store only as many overlays as will fit. | 2807 and we store only as many overlays as will fit. |
| 2835 But we still return the total number of overlays. */ | 2808 But we still return the total number of overlays. */ |
| 2836 | 2809 |
| 2837 static int | 2810 static int |
| 2838 overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) | 2811 overlays_in (int beg, int end, int extend, Lisp_Object **vec_ptr, int *len_ptr, |
| 2839 int beg, end; | 2812 int *next_ptr, int *prev_ptr) |
| 2840 int extend; | |
| 2841 Lisp_Object **vec_ptr; | |
| 2842 int *len_ptr; | |
| 2843 int *next_ptr; | |
| 2844 int *prev_ptr; | |
| 2845 { | 2813 { |
| 2846 Lisp_Object overlay, ostart, oend; | 2814 Lisp_Object overlay, ostart, oend; |
| 2847 struct Lisp_Overlay *tail; | 2815 struct Lisp_Overlay *tail; |
| 2848 int idx = 0; | 2816 int idx = 0; |
| 2849 int len = *len_ptr; | 2817 int len = *len_ptr; |
| 2960 | 2928 |
| 2961 /* Return non-zero if there exists an overlay with a non-nil | 2929 /* Return non-zero if there exists an overlay with a non-nil |
| 2962 `mouse-face' property overlapping OVERLAY. */ | 2930 `mouse-face' property overlapping OVERLAY. */ |
| 2963 | 2931 |
| 2964 int | 2932 int |
| 2965 mouse_face_overlay_overlaps (overlay) | 2933 mouse_face_overlay_overlaps (Lisp_Object overlay) |
| 2966 Lisp_Object overlay; | |
| 2967 { | 2934 { |
| 2968 int start = OVERLAY_POSITION (OVERLAY_START (overlay)); | 2935 int start = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 2969 int end = OVERLAY_POSITION (OVERLAY_END (overlay)); | 2936 int end = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 2970 int n, i, size; | 2937 int n, i, size; |
| 2971 Lisp_Object *v, tem; | 2938 Lisp_Object *v, tem; |
| 2990 | 2957 |
| 2991 | 2958 |
| 2992 | 2959 |
| 2993 /* Fast function to just test if we're at an overlay boundary. */ | 2960 /* Fast function to just test if we're at an overlay boundary. */ |
| 2994 int | 2961 int |
| 2995 overlay_touches_p (pos) | 2962 overlay_touches_p (int pos) |
| 2996 int pos; | |
| 2997 { | 2963 { |
| 2998 Lisp_Object overlay; | 2964 Lisp_Object overlay; |
| 2999 struct Lisp_Overlay *tail; | 2965 struct Lisp_Overlay *tail; |
| 3000 | 2966 |
| 3001 for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2967 for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 3036 int beg, end; | 3002 int beg, end; |
| 3037 int priority; | 3003 int priority; |
| 3038 }; | 3004 }; |
| 3039 | 3005 |
| 3040 static int | 3006 static int |
| 3041 compare_overlays (v1, v2) | 3007 compare_overlays (const void *v1, const void *v2) |
| 3042 const void *v1, *v2; | |
| 3043 { | 3008 { |
| 3044 const struct sortvec *s1 = (const struct sortvec *) v1; | 3009 const struct sortvec *s1 = (const struct sortvec *) v1; |
| 3045 const struct sortvec *s2 = (const struct sortvec *) v2; | 3010 const struct sortvec *s2 = (const struct sortvec *) v2; |
| 3046 if (s1->priority != s2->priority) | 3011 if (s1->priority != s2->priority) |
| 3047 return s1->priority - s2->priority; | 3012 return s1->priority - s2->priority; |
| 3054 | 3019 |
| 3055 /* Sort an array of overlays by priority. The array is modified in place. | 3020 /* Sort an array of overlays by priority. The array is modified in place. |
| 3056 The return value is the new size; this may be smaller than the original | 3021 The return value is the new size; this may be smaller than the original |
| 3057 size if some of the overlays were invalid or were window-specific. */ | 3022 size if some of the overlays were invalid or were window-specific. */ |
| 3058 int | 3023 int |
| 3059 sort_overlays (overlay_vec, noverlays, w) | 3024 sort_overlays (Lisp_Object *overlay_vec, int noverlays, struct window *w) |
| 3060 Lisp_Object *overlay_vec; | |
| 3061 int noverlays; | |
| 3062 struct window *w; | |
| 3063 { | 3025 { |
| 3064 int i, j; | 3026 int i, j; |
| 3065 struct sortvec *sortvec; | 3027 struct sortvec *sortvec; |
| 3066 sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec)); | 3028 sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec)); |
| 3067 | 3029 |
| 3137 /* Allocated length of overlay_str_buf. */ | 3099 /* Allocated length of overlay_str_buf. */ |
| 3138 static int overlay_str_len; | 3100 static int overlay_str_len; |
| 3139 | 3101 |
| 3140 /* A comparison function suitable for passing to qsort. */ | 3102 /* A comparison function suitable for passing to qsort. */ |
| 3141 static int | 3103 static int |
| 3142 cmp_for_strings (as1, as2) | 3104 cmp_for_strings (const void *as1, const void *as2) |
| 3143 char *as1, *as2; | |
| 3144 { | 3105 { |
| 3145 struct sortstr *s1 = (struct sortstr *)as1; | 3106 struct sortstr *s1 = (struct sortstr *)as1; |
| 3146 struct sortstr *s2 = (struct sortstr *)as2; | 3107 struct sortstr *s2 = (struct sortstr *)as2; |
| 3147 if (s1->size != s2->size) | 3108 if (s1->size != s2->size) |
| 3148 return s2->size - s1->size; | 3109 return s2->size - s1->size; |
| 3150 return s1->priority - s2->priority; | 3111 return s1->priority - s2->priority; |
| 3151 return 0; | 3112 return 0; |
| 3152 } | 3113 } |
| 3153 | 3114 |
| 3154 static void | 3115 static void |
| 3155 record_overlay_string (ssl, str, str2, pri, size) | 3116 record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str2, Lisp_Object pri, int size) |
| 3156 struct sortstrlist *ssl; | |
| 3157 Lisp_Object str, str2, pri; | |
| 3158 int size; | |
| 3159 { | 3117 { |
| 3160 int nbytes; | 3118 int nbytes; |
| 3161 | 3119 |
| 3162 if (ssl->used == ssl->size) | 3120 if (ssl->used == ssl->size) |
| 3163 { | 3121 { |
| 3209 Returns the string length, and stores the contents indirectly through | 3167 Returns the string length, and stores the contents indirectly through |
| 3210 PSTR, if that variable is non-null. The string may be overwritten by | 3168 PSTR, if that variable is non-null. The string may be overwritten by |
| 3211 subsequent calls. */ | 3169 subsequent calls. */ |
| 3212 | 3170 |
| 3213 int | 3171 int |
| 3214 overlay_strings (pos, w, pstr) | 3172 overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) |
| 3215 EMACS_INT pos; | |
| 3216 struct window *w; | |
| 3217 unsigned char **pstr; | |
| 3218 { | 3173 { |
| 3219 Lisp_Object overlay, window, str; | 3174 Lisp_Object overlay, window, str; |
| 3220 struct Lisp_Overlay *ov; | 3175 struct Lisp_Overlay *ov; |
| 3221 int startpos, endpos; | 3176 int startpos, endpos; |
| 3222 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); | 3177 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
| 3335 } | 3290 } |
| 3336 | 3291 |
| 3337 /* Shift overlays in BUF's overlay lists, to center the lists at POS. */ | 3292 /* Shift overlays in BUF's overlay lists, to center the lists at POS. */ |
| 3338 | 3293 |
| 3339 void | 3294 void |
| 3340 recenter_overlay_lists (buf, pos) | 3295 recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) |
| 3341 struct buffer *buf; | |
| 3342 EMACS_INT pos; | |
| 3343 { | 3296 { |
| 3344 Lisp_Object overlay, beg, end; | 3297 Lisp_Object overlay, beg, end; |
| 3345 struct Lisp_Overlay *prev, *tail, *next; | 3298 struct Lisp_Overlay *prev, *tail, *next; |
| 3346 | 3299 |
| 3347 /* See if anything in overlays_before should move to overlays_after. */ | 3300 /* See if anything in overlays_before should move to overlays_after. */ |
| 3486 | 3439 |
| 3487 buf->overlay_center = pos; | 3440 buf->overlay_center = pos; |
| 3488 } | 3441 } |
| 3489 | 3442 |
| 3490 void | 3443 void |
| 3491 adjust_overlays_for_insert (pos, length) | 3444 adjust_overlays_for_insert (EMACS_INT pos, EMACS_INT length) |
| 3492 EMACS_INT pos; | |
| 3493 EMACS_INT length; | |
| 3494 { | 3445 { |
| 3495 /* After an insertion, the lists are still sorted properly, | 3446 /* After an insertion, the lists are still sorted properly, |
| 3496 but we may need to update the value of the overlay center. */ | 3447 but we may need to update the value of the overlay center. */ |
| 3497 if (current_buffer->overlay_center >= pos) | 3448 if (current_buffer->overlay_center >= pos) |
| 3498 current_buffer->overlay_center += length; | 3449 current_buffer->overlay_center += length; |
| 3499 } | 3450 } |
| 3500 | 3451 |
| 3501 void | 3452 void |
| 3502 adjust_overlays_for_delete (pos, length) | 3453 adjust_overlays_for_delete (EMACS_INT pos, EMACS_INT length) |
| 3503 EMACS_INT pos; | |
| 3504 EMACS_INT length; | |
| 3505 { | 3454 { |
| 3506 if (current_buffer->overlay_center < pos) | 3455 if (current_buffer->overlay_center < pos) |
| 3507 /* The deletion was to our right. No change needed; the before- and | 3456 /* The deletion was to our right. No change needed; the before- and |
| 3508 after-lists are still consistent. */ | 3457 after-lists are still consistent. */ |
| 3509 ; | 3458 ; |
| 3524 endpoint in this range will need to be unlinked from the overlay | 3473 endpoint in this range will need to be unlinked from the overlay |
| 3525 list and reinserted in its proper place. | 3474 list and reinserted in its proper place. |
| 3526 Such an overlay might even have negative size at this point. | 3475 Such an overlay might even have negative size at this point. |
| 3527 If so, we'll make the overlay empty. */ | 3476 If so, we'll make the overlay empty. */ |
| 3528 void | 3477 void |
| 3529 fix_start_end_in_overlays (start, end) | 3478 fix_start_end_in_overlays (register int start, register int end) |
| 3530 register int start, end; | |
| 3531 { | 3479 { |
| 3532 Lisp_Object overlay; | 3480 Lisp_Object overlay; |
| 3533 struct Lisp_Overlay *before_list, *after_list; | 3481 struct Lisp_Overlay *before_list, *after_list; |
| 3534 /* These are either nil, indicating that before_list or after_list | 3482 /* These are either nil, indicating that before_list or after_list |
| 3535 should be assigned, or the cons cell the cdr of which should be | 3483 should be assigned, or the cons cell the cdr of which should be |
| 3671 This function fixes ordering of overlays in the slot | 3619 This function fixes ordering of overlays in the slot |
| 3672 `overlays_before' of the buffer *BP. Before the insertion, `point' | 3620 `overlays_before' of the buffer *BP. Before the insertion, `point' |
| 3673 was at PREV, and now is at POS. */ | 3621 was at PREV, and now is at POS. */ |
| 3674 | 3622 |
| 3675 void | 3623 void |
| 3676 fix_overlays_before (bp, prev, pos) | 3624 fix_overlays_before (struct buffer *bp, EMACS_INT prev, EMACS_INT pos) |
| 3677 struct buffer *bp; | |
| 3678 EMACS_INT prev, pos; | |
| 3679 { | 3625 { |
| 3680 /* If parent is nil, replace overlays_before; otherwise, parent->next. */ | 3626 /* If parent is nil, replace overlays_before; otherwise, parent->next. */ |
| 3681 struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair; | 3627 struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair; |
| 3682 Lisp_Object tem; | 3628 Lisp_Object tem; |
| 3683 EMACS_INT end; | 3629 EMACS_INT end; |
| 3839 } | 3785 } |
| 3840 | 3786 |
| 3841 /* Mark a section of BUF as needing redisplay because of overlays changes. */ | 3787 /* Mark a section of BUF as needing redisplay because of overlays changes. */ |
| 3842 | 3788 |
| 3843 static void | 3789 static void |
| 3844 modify_overlay (buf, start, end) | 3790 modify_overlay (struct buffer *buf, EMACS_INT start, EMACS_INT end) |
| 3845 struct buffer *buf; | |
| 3846 EMACS_INT start, end; | |
| 3847 { | 3791 { |
| 3848 if (start > end) | 3792 if (start > end) |
| 3849 { | 3793 { |
| 3850 int temp = start; | 3794 int temp = start; |
| 3851 start = end; | 3795 start = end; |
| 3868 | 3812 |
| 3869 ++BUF_OVERLAY_MODIFF (buf); | 3813 ++BUF_OVERLAY_MODIFF (buf); |
| 3870 } | 3814 } |
| 3871 | 3815 |
| 3872 | 3816 |
| 3873 Lisp_Object Fdelete_overlay (); | 3817 Lisp_Object Fdelete_overlay (Lisp_Object overlay); |
| 3874 | 3818 |
| 3875 static struct Lisp_Overlay * | 3819 static struct Lisp_Overlay * |
| 3876 unchain_overlay (list, overlay) | 3820 unchain_overlay (struct Lisp_Overlay *list, struct Lisp_Overlay *overlay) |
| 3877 struct Lisp_Overlay *list, *overlay; | |
| 3878 { | 3821 { |
| 3879 struct Lisp_Overlay *tmp, *prev; | 3822 struct Lisp_Overlay *tmp, *prev; |
| 3880 for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next) | 3823 for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next) |
| 3881 if (tmp == overlay) | 3824 if (tmp == overlay) |
| 3882 { | 3825 { |
| 4331 | 4274 |
| 4332 /* Add one functionlist/overlay pair | 4275 /* Add one functionlist/overlay pair |
| 4333 to the end of last_overlay_modification_hooks. */ | 4276 to the end of last_overlay_modification_hooks. */ |
| 4334 | 4277 |
| 4335 static void | 4278 static void |
| 4336 add_overlay_mod_hooklist (functionlist, overlay) | 4279 add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay) |
| 4337 Lisp_Object functionlist, overlay; | |
| 4338 { | 4280 { |
| 4339 int oldsize = XVECTOR (last_overlay_modification_hooks)->size; | 4281 int oldsize = XVECTOR (last_overlay_modification_hooks)->size; |
| 4340 | 4282 |
| 4341 if (last_overlay_modification_hooks_used == oldsize) | 4283 if (last_overlay_modification_hooks_used == oldsize) |
| 4342 last_overlay_modification_hooks = larger_vector | 4284 last_overlay_modification_hooks = larger_vector |
| 4360 When AFTER is nonzero, they are the start position, | 4302 When AFTER is nonzero, they are the start position, |
| 4361 the position after the inserted new text, | 4303 the position after the inserted new text, |
| 4362 and the length of deleted or replaced old text. */ | 4304 and the length of deleted or replaced old text. */ |
| 4363 | 4305 |
| 4364 void | 4306 void |
| 4365 report_overlay_modification (start, end, after, arg1, arg2, arg3) | 4307 report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, |
| 4366 Lisp_Object start, end; | 4308 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) |
| 4367 int after; | |
| 4368 Lisp_Object arg1, arg2, arg3; | |
| 4369 { | 4309 { |
| 4370 Lisp_Object prop, overlay; | 4310 Lisp_Object prop, overlay; |
| 4371 struct Lisp_Overlay *tail; | 4311 struct Lisp_Overlay *tail; |
| 4372 /* 1 if this change is an insertion. */ | 4312 /* 1 if this change is an insertion. */ |
| 4373 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); | 4313 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); |
| 4488 } | 4428 } |
| 4489 UNGCPRO; | 4429 UNGCPRO; |
| 4490 } | 4430 } |
| 4491 | 4431 |
| 4492 static void | 4432 static void |
| 4493 call_overlay_mod_hooks (list, overlay, after, arg1, arg2, arg3) | 4433 call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, |
| 4494 Lisp_Object list, overlay; | 4434 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) |
| 4495 int after; | |
| 4496 Lisp_Object arg1, arg2, arg3; | |
| 4497 { | 4435 { |
| 4498 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 4436 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 4499 | 4437 |
| 4500 GCPRO4 (list, arg1, arg2, arg3); | 4438 GCPRO4 (list, arg1, arg2, arg3); |
| 4501 | 4439 |
| 4511 } | 4449 } |
| 4512 | 4450 |
| 4513 /* Delete any zero-sized overlays at position POS, if the `evaporate' | 4451 /* Delete any zero-sized overlays at position POS, if the `evaporate' |
| 4514 property is set. */ | 4452 property is set. */ |
| 4515 void | 4453 void |
| 4516 evaporate_overlays (pos) | 4454 evaporate_overlays (EMACS_INT pos) |
| 4517 EMACS_INT pos; | |
| 4518 { | 4455 { |
| 4519 Lisp_Object overlay, hit_list; | 4456 Lisp_Object overlay, hit_list; |
| 4520 struct Lisp_Overlay *tail; | 4457 struct Lisp_Overlay *tail; |
| 4521 | 4458 |
| 4522 hit_list = Qnil; | 4459 hit_list = Qnil; |
| 4550 | 4487 |
| 4551 /* Somebody has tried to store a value with an unacceptable type | 4488 /* Somebody has tried to store a value with an unacceptable type |
| 4552 in the slot with offset OFFSET. */ | 4489 in the slot with offset OFFSET. */ |
| 4553 | 4490 |
| 4554 void | 4491 void |
| 4555 buffer_slot_type_mismatch (newval, type) | 4492 buffer_slot_type_mismatch (Lisp_Object newval, int type) |
| 4556 Lisp_Object newval; | |
| 4557 int type; | |
| 4558 { | 4493 { |
| 4559 Lisp_Object predicate; | 4494 Lisp_Object predicate; |
| 4560 | 4495 |
| 4561 switch (type) | 4496 switch (type) |
| 4562 { | 4497 { |
| 5039 | 4974 |
| 5040 | 4975 |
| 5041 /* Allocate NBYTES bytes for buffer B's text buffer. */ | 4976 /* Allocate NBYTES bytes for buffer B's text buffer. */ |
| 5042 | 4977 |
| 5043 static void | 4978 static void |
| 5044 alloc_buffer_text (b, nbytes) | 4979 alloc_buffer_text (struct buffer *b, size_t nbytes) |
| 5045 struct buffer *b; | |
| 5046 size_t nbytes; | |
| 5047 { | 4980 { |
| 5048 POINTER_TYPE *p; | 4981 POINTER_TYPE *p; |
| 5049 | 4982 |
| 5050 BLOCK_INPUT; | 4983 BLOCK_INPUT; |
| 5051 #if defined USE_MMAP_FOR_BUFFERS | 4984 #if defined USE_MMAP_FOR_BUFFERS |
| 5096 | 5029 |
| 5097 | 5030 |
| 5098 /* Free buffer B's text buffer. */ | 5031 /* Free buffer B's text buffer. */ |
| 5099 | 5032 |
| 5100 static void | 5033 static void |
| 5101 free_buffer_text (b) | 5034 free_buffer_text (struct buffer *b) |
| 5102 struct buffer *b; | |
| 5103 { | 5035 { |
| 5104 BLOCK_INPUT; | 5036 BLOCK_INPUT; |
| 5105 | 5037 |
| 5106 #if defined USE_MMAP_FOR_BUFFERS | 5038 #if defined USE_MMAP_FOR_BUFFERS |
| 5107 mmap_free ((POINTER_TYPE **) &b->text->beg); | 5039 mmap_free ((POINTER_TYPE **) &b->text->beg); |
| 5120 /*********************************************************************** | 5052 /*********************************************************************** |
| 5121 Initialization | 5053 Initialization |
| 5122 ***********************************************************************/ | 5054 ***********************************************************************/ |
| 5123 | 5055 |
| 5124 void | 5056 void |
| 5125 init_buffer_once () | 5057 init_buffer_once (void) |
| 5126 { | 5058 { |
| 5127 int idx; | 5059 int idx; |
| 5128 | 5060 |
| 5129 bzero (buffer_permanent_local_flags, sizeof buffer_permanent_local_flags); | 5061 bzero (buffer_permanent_local_flags, sizeof buffer_permanent_local_flags); |
| 5130 | 5062 |
| 5316 | 5248 |
| 5317 inhibit_modification_hooks = 0; | 5249 inhibit_modification_hooks = 0; |
| 5318 } | 5250 } |
| 5319 | 5251 |
| 5320 void | 5252 void |
| 5321 init_buffer () | 5253 init_buffer (void) |
| 5322 { | 5254 { |
| 5323 char *pwd; | 5255 char *pwd; |
| 5324 Lisp_Object temp; | 5256 Lisp_Object temp; |
| 5325 int len; | 5257 int len; |
| 5326 | 5258 |
| 5400 static struct Lisp_Buffer_Objfwd bo_fwd; \ | 5332 static struct Lisp_Buffer_Objfwd bo_fwd; \ |
| 5401 defvar_per_buffer (&bo_fwd, lname, vname, type, 0); \ | 5333 defvar_per_buffer (&bo_fwd, lname, vname, type, 0); \ |
| 5402 } while (0) | 5334 } while (0) |
| 5403 | 5335 |
| 5404 static void | 5336 static void |
| 5405 defvar_per_buffer (bo_fwd, namestring, address, type, doc) | 5337 defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, char *namestring, |
| 5406 struct Lisp_Buffer_Objfwd *bo_fwd; | 5338 Lisp_Object *address, Lisp_Object type, char *doc) |
| 5407 char *namestring; | |
| 5408 Lisp_Object *address; | |
| 5409 Lisp_Object type; | |
| 5410 char *doc; | |
| 5411 { | 5339 { |
| 5412 struct Lisp_Symbol *sym; | 5340 struct Lisp_Symbol *sym; |
| 5413 int offset; | 5341 int offset; |
| 5414 | 5342 |
| 5415 sym = XSYMBOL (intern (namestring)); | 5343 sym = XSYMBOL (intern (namestring)); |
| 5433 } | 5361 } |
| 5434 | 5362 |
| 5435 | 5363 |
| 5436 /* initialize the buffer routines */ | 5364 /* initialize the buffer routines */ |
| 5437 void | 5365 void |
| 5438 syms_of_buffer () | 5366 syms_of_buffer (void) |
| 5439 { | 5367 { |
| 5440 staticpro (&last_overlay_modification_hooks); | 5368 staticpro (&last_overlay_modification_hooks); |
| 5441 last_overlay_modification_hooks | 5369 last_overlay_modification_hooks |
| 5442 = Fmake_vector (make_number (10), Qnil); | 5370 = Fmake_vector (make_number (10), Qnil); |
| 5443 | 5371 |
| 6336 defsubr (&Soverlay_put); | 6264 defsubr (&Soverlay_put); |
| 6337 defsubr (&Srestore_buffer_modified_p); | 6265 defsubr (&Srestore_buffer_modified_p); |
| 6338 } | 6266 } |
| 6339 | 6267 |
| 6340 void | 6268 void |
| 6341 keys_of_buffer () | 6269 keys_of_buffer (void) |
| 6342 { | 6270 { |
| 6343 initial_define_key (control_x_map, 'b', "switch-to-buffer"); | 6271 initial_define_key (control_x_map, 'b', "switch-to-buffer"); |
| 6344 initial_define_key (control_x_map, 'k', "kill-buffer"); | 6272 initial_define_key (control_x_map, 'k', "kill-buffer"); |
| 6345 | 6273 |
| 6346 /* This must not be in syms_of_buffer, because Qdisabled is not | 6274 /* This must not be in syms_of_buffer, because Qdisabled is not |
