Mercurial > emacs
annotate src/marker.c @ 74577:eb977be26d8c
(erc-ezb-init-session-list): Doc fix.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Sun, 10 Dec 2006 23:45:53 +0000 |
parents | 21b2a6ce1aa9 |
children | e90d04cd455a 6588c6259dfb |
rev | line source |
---|---|
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
1 /* Markers: examining, setting and deleting. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1985, 1997, 1998, 2002, 2003, 2004, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65713
diff
changeset
|
3 2005, 2006 Free Software Foundation, Inc. |
118 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
12244 | 9 the Free Software Foundation; either version 2, or (at your option) |
118 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
118 | 21 |
22 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
484
diff
changeset
|
23 #include <config.h> |
118 | 24 #include "lisp.h" |
25 #include "buffer.h" | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
26 #include "charset.h" |
118 | 27 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
28 /* Record one cached position found recently by |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
29 buf_charpos_to_bytepos or buf_bytepos_to_charpos. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
30 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
31 static int cached_charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
32 static int cached_bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
33 static struct buffer *cached_buffer; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
34 static int cached_modiff; |
20678
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
35 |
31830
cf1b4094811a
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
28417
diff
changeset
|
36 static void byte_char_debug_check P_ ((struct buffer *, int, int)); |
cf1b4094811a
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
28417
diff
changeset
|
37 |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
38 /* Nonzero means enable debugging checks on byte/char correspondences. */ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
39 |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
40 static int byte_debug_flag; |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
41 |
21514 | 42 void |
20678
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
43 clear_charpos_cache (b) |
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
44 struct buffer *b; |
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
45 { |
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
46 if (cached_buffer == b) |
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
47 cached_buffer = 0; |
4c69e3503cfc
(clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20563
diff
changeset
|
48 } |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
49 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
50 /* Converting between character positions and byte positions. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
51 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
52 /* There are several places in the buffer where we know |
44651
392bc50108e8
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
44560
diff
changeset
|
53 the correspondence: BEG, BEGV, PT, GPT, ZV and Z, |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
54 and everywhere there is a marker. So we find the one of these places |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
55 that is closest to the specified position, and scan from there. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
56 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
57 /* charpos_to_bytepos returns the byte position corresponding to CHARPOS. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
58 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
59 /* This macro is a subroutine of charpos_to_bytepos. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
60 Note that it is desirable that BYTEPOS is not evaluated |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
61 except when we really want its value. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
62 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
63 #define CONSIDER(CHARPOS, BYTEPOS) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
64 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
65 int this_charpos = (CHARPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
66 int changed = 0; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
67 \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
68 if (this_charpos == charpos) \ |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
69 { \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
70 int value = (BYTEPOS); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
71 if (byte_debug_flag) \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
72 byte_char_debug_check (b, charpos, value); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
73 return value; \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
74 } \ |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
75 else if (this_charpos > charpos) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
76 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
77 if (this_charpos < best_above) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
78 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
79 best_above = this_charpos; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
80 best_above_byte = (BYTEPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
81 changed = 1; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
82 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
83 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
84 else if (this_charpos > best_below) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
85 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
86 best_below = this_charpos; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
87 best_below_byte = (BYTEPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
88 changed = 1; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
89 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
90 \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
91 if (changed) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
92 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
93 if (best_above - best_below == best_above_byte - best_below_byte) \ |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
94 { \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
95 int value = best_below_byte + (charpos - best_below); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
96 if (byte_debug_flag) \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
97 byte_char_debug_check (b, charpos, value); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
98 return value; \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
99 } \ |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
100 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
101 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
102 |
31830
cf1b4094811a
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
28417
diff
changeset
|
103 static void |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
104 byte_char_debug_check (b, charpos, bytepos) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
105 struct buffer *b; |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
106 int charpos, bytepos; |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
107 { |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
108 int nchars = 0; |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
109 |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
110 if (bytepos > BUF_GPT_BYTE (b)) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
111 { |
21219
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
112 nchars = multibyte_chars_in_text (BUF_BEG_ADDR (b), |
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
113 BUF_GPT_BYTE (b) - BUF_BEG_BYTE (b)); |
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
114 nchars += multibyte_chars_in_text (BUF_GAP_END_ADDR (b), |
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
115 bytepos - BUF_GPT_BYTE (b)); |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
116 } |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
117 else |
21219
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
118 nchars = multibyte_chars_in_text (BUF_BEG_ADDR (b), |
29d2cf14040a
(byte_char_debug_check): Call multibyte_chars_in_text
Kenichi Handa <handa@m17n.org>
parents:
20872
diff
changeset
|
119 bytepos - BUF_BEG_BYTE (b)); |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
120 |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
121 if (charpos - 1 != nchars) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
122 abort (); |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
123 } |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
124 |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
125 int |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
126 charpos_to_bytepos (charpos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
127 int charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
128 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
129 return buf_charpos_to_bytepos (current_buffer, charpos); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
130 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
131 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
132 int |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
133 buf_charpos_to_bytepos (b, charpos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
134 struct buffer *b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
135 int charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
136 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
137 struct Lisp_Marker *tail; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
138 int best_above, best_above_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
139 int best_below, best_below_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
140 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
141 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
142 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
143 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
144 best_above = BUF_Z (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
145 best_above_byte = BUF_Z_BYTE (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
146 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
147 /* If this buffer has as many characters as bytes, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
148 each character must be one byte. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
149 This takes care of the case where enable-multibyte-characters is nil. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
150 if (best_above == best_above_byte) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
151 return charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
152 |
44328
ed296e71aa64
(buf_charpos_to_bytepos, buf_bytepos_to_charpos): Use BEG and BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41235
diff
changeset
|
153 best_below = BEG; |
ed296e71aa64
(buf_charpos_to_bytepos, buf_bytepos_to_charpos): Use BEG and BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41235
diff
changeset
|
154 best_below_byte = BEG_BYTE; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
155 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
156 /* We find in best_above and best_above_byte |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
157 the closest known point above CHARPOS, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
158 and in best_below and best_below_byte |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
159 the closest known point below CHARPOS, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
160 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
161 If at any point we can tell that the space between those |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
162 two best approximations is all single-byte, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
163 we interpolate the result immediately. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
164 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
165 CONSIDER (BUF_PT (b), BUF_PT_BYTE (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
166 CONSIDER (BUF_GPT (b), BUF_GPT_BYTE (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
167 CONSIDER (BUF_BEGV (b), BUF_BEGV_BYTE (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
168 CONSIDER (BUF_ZV (b), BUF_ZV_BYTE (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
169 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
170 if (b == cached_buffer && BUF_MODIFF (b) == cached_modiff) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
171 CONSIDER (cached_charpos, cached_bytepos); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
172 |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
173 for (tail = BUF_MARKERS (b); tail; tail = tail->next) |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
174 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
175 CONSIDER (tail->charpos, tail->bytepos); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
176 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
177 /* If we are down to a range of 50 chars, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
178 don't bother checking any other markers; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
179 scan the intervening chars directly now. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
180 if (best_above - best_below < 50) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
181 break; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
182 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
183 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
184 /* We get here if we did not exactly hit one of the known places. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
185 We have one known above and one known below. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
186 Scan, counting characters, from whichever one is closer. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
187 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
188 if (charpos - best_below < best_above - charpos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
189 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
190 int record = charpos - best_below > 5000; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
191 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
192 while (best_below != charpos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
193 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
194 best_below++; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
195 BUF_INC_POS (b, best_below_byte); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
196 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
197 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
198 /* If this position is quite far from the nearest known position, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
199 cache the correspondence by creating a marker here. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
200 It will last until the next GC. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
201 if (record) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
202 { |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
203 Lisp_Object marker, buffer; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
204 marker = Fmake_marker (); |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
205 XSETBUFFER (buffer, b); |
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
206 set_marker_both (marker, buffer, best_below, best_below_byte); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
207 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
208 |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
209 if (byte_debug_flag) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
210 byte_char_debug_check (b, charpos, best_below_byte); |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
211 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
212 cached_buffer = b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
213 cached_modiff = BUF_MODIFF (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
214 cached_charpos = best_below; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
215 cached_bytepos = best_below_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
216 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
217 return best_below_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
218 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
219 else |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
220 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
221 int record = best_above - charpos > 5000; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
222 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
223 while (best_above != charpos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
224 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
225 best_above--; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
226 BUF_DEC_POS (b, best_above_byte); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
227 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
228 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
229 /* If this position is quite far from the nearest known position, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
230 cache the correspondence by creating a marker here. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
231 It will last until the next GC. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
232 if (record) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
233 { |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
234 Lisp_Object marker, buffer; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
235 marker = Fmake_marker (); |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
236 XSETBUFFER (buffer, b); |
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
237 set_marker_both (marker, buffer, best_above, best_above_byte); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
238 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
239 |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
240 if (byte_debug_flag) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
241 byte_char_debug_check (b, charpos, best_above_byte); |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
242 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
243 cached_buffer = b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
244 cached_modiff = BUF_MODIFF (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
245 cached_charpos = best_above; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
246 cached_bytepos = best_above_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
247 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
248 return best_above_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
249 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
250 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
251 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
252 #undef CONSIDER |
50472
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
253 |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
254 /* Used for debugging: recompute the bytepos corresponding to CHARPOS |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
255 in the simplest, most reliable way. */ |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
256 |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
257 int |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
258 verify_bytepos (charpos) |
65713
ad24f42046b1
* xlwmenu.c (find_next_selectable):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64770
diff
changeset
|
259 int charpos; |
50472
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
260 { |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
261 int below = 1; |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
262 int below_byte = 1; |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
263 |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
264 while (below != charpos) |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
265 { |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
266 below++; |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
267 BUF_INC_POS (current_buffer, below_byte); |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
268 } |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
269 |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
270 return below_byte; |
674bfa5d582d
(verify_bytepos): New function.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
271 } |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
272 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
273 /* bytepos_to_charpos returns the char position corresponding to BYTEPOS. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
274 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
275 /* This macro is a subroutine of bytepos_to_charpos. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
276 It is used when BYTEPOS is actually the byte position. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
277 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
278 #define CONSIDER(BYTEPOS, CHARPOS) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
279 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
280 int this_bytepos = (BYTEPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
281 int changed = 0; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
282 \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
283 if (this_bytepos == bytepos) \ |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
284 { \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
285 int value = (CHARPOS); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
286 if (byte_debug_flag) \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
287 byte_char_debug_check (b, value, bytepos); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
288 return value; \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
289 } \ |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
290 else if (this_bytepos > bytepos) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
291 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
292 if (this_bytepos < best_above_byte) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
293 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
294 best_above = (CHARPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
295 best_above_byte = this_bytepos; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
296 changed = 1; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
297 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
298 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
299 else if (this_bytepos > best_below_byte) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
300 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
301 best_below = (CHARPOS); \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
302 best_below_byte = this_bytepos; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
303 changed = 1; \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
304 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
305 \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
306 if (changed) \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
307 { \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
308 if (best_above - best_below == best_above_byte - best_below_byte) \ |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
309 { \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
310 int value = best_below + (bytepos - best_below_byte); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
311 if (byte_debug_flag) \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
312 byte_char_debug_check (b, value, bytepos); \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
313 return value; \ |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
314 } \ |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
315 } \ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
316 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
317 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
318 int |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
319 bytepos_to_charpos (bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
320 int bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
321 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
322 return buf_bytepos_to_charpos (current_buffer, bytepos); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
323 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
324 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
325 int |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
326 buf_bytepos_to_charpos (b, bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
327 struct buffer *b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
328 int bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
329 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
330 struct Lisp_Marker *tail; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
331 int best_above, best_above_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
332 int best_below, best_below_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
333 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
334 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
335 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
336 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
337 best_above = BUF_Z (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
338 best_above_byte = BUF_Z_BYTE (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
339 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
340 /* If this buffer has as many characters as bytes, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
341 each character must be one byte. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
342 This takes care of the case where enable-multibyte-characters is nil. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
343 if (best_above == best_above_byte) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
344 return bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
345 |
44328
ed296e71aa64
(buf_charpos_to_bytepos, buf_bytepos_to_charpos): Use BEG and BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41235
diff
changeset
|
346 best_below = BEG; |
ed296e71aa64
(buf_charpos_to_bytepos, buf_bytepos_to_charpos): Use BEG and BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41235
diff
changeset
|
347 best_below_byte = BEG_BYTE; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
348 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
349 CONSIDER (BUF_PT_BYTE (b), BUF_PT (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
350 CONSIDER (BUF_GPT_BYTE (b), BUF_GPT (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
351 CONSIDER (BUF_BEGV_BYTE (b), BUF_BEGV (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
352 CONSIDER (BUF_ZV_BYTE (b), BUF_ZV (b)); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
353 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
354 if (b == cached_buffer && BUF_MODIFF (b) == cached_modiff) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
355 CONSIDER (cached_bytepos, cached_charpos); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
356 |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
357 for (tail = BUF_MARKERS (b); tail; tail = tail->next) |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
358 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
359 CONSIDER (tail->bytepos, tail->charpos); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
360 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
361 /* If we are down to a range of 50 chars, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
362 don't bother checking any other markers; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
363 scan the intervening chars directly now. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
364 if (best_above - best_below < 50) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
365 break; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
366 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
367 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
368 /* We get here if we did not exactly hit one of the known places. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
369 We have one known above and one known below. |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
370 Scan, counting characters, from whichever one is closer. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
371 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
372 if (bytepos - best_below_byte < best_above_byte - bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
373 { |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
374 int record = bytepos - best_below_byte > 5000; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
375 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
376 while (best_below_byte < bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
377 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
378 best_below++; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
379 BUF_INC_POS (b, best_below_byte); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
380 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
381 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
382 /* If this position is quite far from the nearest known position, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
383 cache the correspondence by creating a marker here. |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
384 It will last until the next GC. |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
385 But don't do it if BUF_MARKERS is nil; |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
386 that is a signal from Fset_buffer_multibyte. */ |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
387 if (record && BUF_MARKERS (b)) |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
388 { |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
389 Lisp_Object marker, buffer; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
390 marker = Fmake_marker (); |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
391 XSETBUFFER (buffer, b); |
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
392 set_marker_both (marker, buffer, best_below, best_below_byte); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
393 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
394 |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
395 if (byte_debug_flag) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
396 byte_char_debug_check (b, best_below, bytepos); |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
397 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
398 cached_buffer = b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
399 cached_modiff = BUF_MODIFF (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
400 cached_charpos = best_below; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
401 cached_bytepos = best_below_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
402 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
403 return best_below; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
404 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
405 else |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
406 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
407 int record = best_above_byte - bytepos > 5000; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
408 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
409 while (best_above_byte > bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
410 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
411 best_above--; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
412 BUF_DEC_POS (b, best_above_byte); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
413 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
414 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
415 /* If this position is quite far from the nearest known position, |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
416 cache the correspondence by creating a marker here. |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
417 It will last until the next GC. |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
418 But don't do it if BUF_MARKERS is nil; |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
419 that is a signal from Fset_buffer_multibyte. */ |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
420 if (record && BUF_MARKERS (b)) |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
421 { |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
422 Lisp_Object marker, buffer; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
423 marker = Fmake_marker (); |
21497
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
424 XSETBUFFER (buffer, b); |
837148a1541f
(buf_charpos_to_bytepos, buf_bytepos_to_charpos):
Karl Heuer <kwzh@gnu.org>
parents:
21458
diff
changeset
|
425 set_marker_both (marker, buffer, best_above, best_above_byte); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
426 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
427 |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
428 if (byte_debug_flag) |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
429 byte_char_debug_check (b, best_above, bytepos); |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
430 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
431 cached_buffer = b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
432 cached_modiff = BUF_MODIFF (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
433 cached_charpos = best_above; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
434 cached_bytepos = best_above_byte; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
435 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
436 return best_above; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
437 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
438 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
439 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
440 #undef CONSIDER |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
441 |
118 | 442 /* Operations on markers. */ |
443 | |
444 DEFUN ("marker-buffer", Fmarker_buffer, Smarker_buffer, 1, 1, 0, | |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
445 doc: /* Return the buffer that MARKER points into, or nil if none. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
446 Returns nil if MARKER points into a dead buffer. */) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
447 (marker) |
118 | 448 register Lisp_Object marker; |
449 { | |
450 register Lisp_Object buf; | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
451 CHECK_MARKER (marker); |
118 | 452 if (XMARKER (marker)->buffer) |
453 { | |
9275
bb50d17f7441
(Fmarker_buffer): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9121
diff
changeset
|
454 XSETBUFFER (buf, XMARKER (marker)->buffer); |
118 | 455 /* Return marker's buffer only if it is not dead. */ |
484 | 456 if (!NILP (XBUFFER (buf)->name)) |
118 | 457 return buf; |
458 } | |
459 return Qnil; | |
460 } | |
461 | |
462 DEFUN ("marker-position", Fmarker_position, Smarker_position, 1, 1, 0, | |
72625
b7e16dcc0668
(Fmarker_position): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
71840
diff
changeset
|
463 doc: /* Return the position MARKER points at, as a character number. |
b7e16dcc0668
(Fmarker_position): Doc fix.
Juri Linkov <juri@jurta.org>
parents:
71840
diff
changeset
|
464 Returns nil if MARKER points nowhere. */) |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
465 (marker) |
118 | 466 Lisp_Object marker; |
467 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
468 CHECK_MARKER (marker); |
118 | 469 if (XMARKER (marker)->buffer) |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
470 return make_number (XMARKER (marker)->charpos); |
118 | 471 |
472 return Qnil; | |
473 } | |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
474 |
118 | 475 DEFUN ("set-marker", Fset_marker, Sset_marker, 2, 3, 0, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
476 doc: /* Position MARKER before character number POSITION in BUFFER. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
477 BUFFER defaults to the current buffer. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
478 If POSITION is nil, makes marker point nowhere. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
479 Then it no longer slows down editing in any buffer. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
480 Returns MARKER. */) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
481 (marker, position, buffer) |
14082
c6a1708f37d4
(Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13327
diff
changeset
|
482 Lisp_Object marker, position, buffer; |
118 | 483 { |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
484 register int charno, bytepos; |
118 | 485 register struct buffer *b; |
486 register struct Lisp_Marker *m; | |
487 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
488 CHECK_MARKER (marker); |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
489 m = XMARKER (marker); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
490 |
118 | 491 /* If position is nil or a marker that points nowhere, |
492 make this marker point nowhere. */ | |
14082
c6a1708f37d4
(Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13327
diff
changeset
|
493 if (NILP (position) |
c6a1708f37d4
(Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13327
diff
changeset
|
494 || (MARKERP (position) && !XMARKER (position)->buffer)) |
118 | 495 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
496 unchain_marker (m); |
118 | 497 return marker; |
498 } | |
499 | |
484 | 500 if (NILP (buffer)) |
118 | 501 b = current_buffer; |
502 else | |
503 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
504 CHECK_BUFFER (buffer); |
118 | 505 b = XBUFFER (buffer); |
506 /* If buffer is dead, set marker to point nowhere. */ | |
507 if (EQ (b->name, Qnil)) | |
508 { | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
509 unchain_marker (m); |
118 | 510 return marker; |
511 } | |
512 } | |
513 | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
514 /* Optimize the special case where we are copying the position |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
515 of an existing marker, and MARKER is already in the same buffer. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
516 if (MARKERP (position) && b == XMARKER (position)->buffer |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
517 && b == m->buffer) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
518 { |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
519 m->bytepos = XMARKER (position)->bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
520 m->charpos = XMARKER (position)->charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
521 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
522 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
523 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
524 CHECK_NUMBER_COERCE_MARKER (position); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
525 |
14082
c6a1708f37d4
(Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13327
diff
changeset
|
526 charno = XINT (position); |
118 | 527 |
528 if (charno < BUF_BEG (b)) | |
529 charno = BUF_BEG (b); | |
530 if (charno > BUF_Z (b)) | |
531 charno = BUF_Z (b); | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
532 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
533 bytepos = buf_charpos_to_bytepos (b, charno); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
534 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
535 /* Every character is at least one byte. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
536 if (charno > bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
537 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
538 |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
539 m->bytepos = bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
540 m->charpos = charno; |
118 | 541 |
542 if (m->buffer != b) | |
543 { | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
544 unchain_marker (m); |
118 | 545 m->buffer = b; |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
546 m->next = BUF_MARKERS (b); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
547 BUF_MARKERS (b) = m; |
118 | 548 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
549 |
118 | 550 return marker; |
551 } | |
552 | |
553 /* This version of Fset_marker won't let the position | |
554 be outside the visible part. */ | |
555 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
556 Lisp_Object |
118 | 557 set_marker_restricted (marker, pos, buffer) |
558 Lisp_Object marker, pos, buffer; | |
559 { | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
560 register int charno, bytepos; |
118 | 561 register struct buffer *b; |
562 register struct Lisp_Marker *m; | |
563 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
564 CHECK_MARKER (marker); |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
565 m = XMARKER (marker); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
566 |
118 | 567 /* If position is nil or a marker that points nowhere, |
568 make this marker point nowhere. */ | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
569 if (NILP (pos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
570 || (MARKERP (pos) && !XMARKER (pos)->buffer)) |
118 | 571 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
572 unchain_marker (m); |
118 | 573 return marker; |
574 } | |
575 | |
484 | 576 if (NILP (buffer)) |
118 | 577 b = current_buffer; |
578 else | |
579 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
580 CHECK_BUFFER (buffer); |
118 | 581 b = XBUFFER (buffer); |
582 /* If buffer is dead, set marker to point nowhere. */ | |
583 if (EQ (b->name, Qnil)) | |
584 { | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
585 unchain_marker (m); |
118 | 586 return marker; |
587 } | |
588 } | |
589 | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
590 /* Optimize the special case where we are copying the position |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
591 of an existing marker, and MARKER is already in the same buffer. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
592 if (MARKERP (pos) && b == XMARKER (pos)->buffer |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
593 && b == m->buffer) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
594 { |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
595 m->bytepos = XMARKER (pos)->bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
596 m->charpos = XMARKER (pos)->charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
597 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
598 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
599 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
600 CHECK_NUMBER_COERCE_MARKER (pos); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
601 |
118 | 602 charno = XINT (pos); |
603 | |
604 if (charno < BUF_BEGV (b)) | |
605 charno = BUF_BEGV (b); | |
606 if (charno > BUF_ZV (b)) | |
607 charno = BUF_ZV (b); | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
608 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
609 bytepos = buf_charpos_to_bytepos (b, charno); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
610 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
611 /* Every character is at least one byte. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
612 if (charno > bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
613 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
614 |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
615 m->bytepos = bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
616 m->charpos = charno; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
617 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
618 if (m->buffer != b) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
619 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
620 unchain_marker (m); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
621 m->buffer = b; |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
622 m->next = BUF_MARKERS (b); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
623 BUF_MARKERS (b) = m; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
624 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
625 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
626 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
627 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
628 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
629 /* Set the position of MARKER, specifying both the |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
630 character position and the corresponding byte position. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
631 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
632 Lisp_Object |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
633 set_marker_both (marker, buffer, charpos, bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
634 Lisp_Object marker, buffer; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
635 int charpos, bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
636 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
637 register struct buffer *b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
638 register struct Lisp_Marker *m; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
639 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
640 CHECK_MARKER (marker); |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
641 m = XMARKER (marker); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
642 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
643 if (NILP (buffer)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
644 b = current_buffer; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
645 else |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
646 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
647 CHECK_BUFFER (buffer); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
648 b = XBUFFER (buffer); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
649 /* If buffer is dead, set marker to point nowhere. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
650 if (EQ (b->name, Qnil)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
651 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
652 unchain_marker (m); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
653 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
654 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
655 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
656 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
657 /* In a single-byte buffer, the two positions must be equal. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
658 if (BUF_Z (b) == BUF_Z_BYTE (b) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
659 && charpos != bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
660 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
661 /* Every character is at least one byte. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
662 if (charpos > bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
663 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
664 |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
665 m->bytepos = bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
666 m->charpos = charpos; |
118 | 667 |
668 if (m->buffer != b) | |
669 { | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
670 unchain_marker (m); |
118 | 671 m->buffer = b; |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
672 m->next = BUF_MARKERS (b); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
673 BUF_MARKERS (b) = m; |
118 | 674 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
675 |
118 | 676 return marker; |
677 } | |
678 | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
679 /* This version of set_marker_both won't let the position |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
680 be outside the visible part. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
681 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
682 Lisp_Object |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
683 set_marker_restricted_both (marker, buffer, charpos, bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
684 Lisp_Object marker, buffer; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
685 int charpos, bytepos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
686 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
687 register struct buffer *b; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
688 register struct Lisp_Marker *m; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
689 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
690 CHECK_MARKER (marker); |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
691 m = XMARKER (marker); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
692 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
693 if (NILP (buffer)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
694 b = current_buffer; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
695 else |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
696 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
697 CHECK_BUFFER (buffer); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
698 b = XBUFFER (buffer); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
699 /* If buffer is dead, set marker to point nowhere. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
700 if (EQ (b->name, Qnil)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
701 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
702 unchain_marker (m); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
703 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
704 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
705 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
706 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
707 if (charpos < BUF_BEGV (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
708 charpos = BUF_BEGV (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
709 if (charpos > BUF_ZV (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
710 charpos = BUF_ZV (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
711 if (bytepos < BUF_BEGV_BYTE (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
712 bytepos = BUF_BEGV_BYTE (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
713 if (bytepos > BUF_ZV_BYTE (b)) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
714 bytepos = BUF_ZV_BYTE (b); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
715 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
716 /* In a single-byte buffer, the two positions must be equal. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
717 if (BUF_Z (b) == BUF_Z_BYTE (b) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
718 && charpos != bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
719 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
720 /* Every character is at least one byte. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
721 if (charpos > bytepos) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
722 abort (); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
723 |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
724 m->bytepos = bytepos; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
725 m->charpos = charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
726 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
727 if (m->buffer != b) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
728 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
729 unchain_marker (m); |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
730 m->buffer = b; |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
731 m->next = BUF_MARKERS (b); |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
732 BUF_MARKERS (b) = m; |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
733 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44651
diff
changeset
|
734 |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
735 return marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
736 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
737 |
41235 | 738 /* Remove MARKER from the chain of whatever buffer it is in. |
739 Leave it "in no buffer". | |
740 | |
741 This is called during garbage collection, | |
118 | 742 so we must be careful to ignore and preserve mark bits, |
743 including those in chain fields of markers. */ | |
744 | |
20301
6e2ea54ad704
(unchain_marker): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents:
16418
diff
changeset
|
745 void |
118 | 746 unchain_marker (marker) |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
747 register struct Lisp_Marker *marker; |
118 | 748 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
749 register struct Lisp_Marker *tail, *prev, *next; |
118 | 750 register struct buffer *b; |
751 | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
752 b = marker->buffer; |
118 | 753 if (b == 0) |
754 return; | |
755 | |
756 if (EQ (b->name, Qnil)) | |
757 abort (); | |
758 | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
759 marker->buffer = 0; |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
760 |
10315
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
761 tail = BUF_MARKERS (b); |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
762 prev = NULL; |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
763 while (tail) |
118 | 764 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
765 next = tail->next; |
118 | 766 |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
767 if (marker == tail) |
118 | 768 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
769 if (!prev) |
118 | 770 { |
10315
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
771 BUF_MARKERS (b) = next; |
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
772 /* Deleting first marker from the buffer's chain. Crash |
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
773 if new first marker in chain does not say it belongs |
10999
84076f6a1f1b
(unchain_marker): Allow differing buffers
Richard M. Stallman <rms@gnu.org>
parents:
10315
diff
changeset
|
774 to the same buffer, or at least that they have the same |
84076f6a1f1b
(unchain_marker): Allow differing buffers
Richard M. Stallman <rms@gnu.org>
parents:
10315
diff
changeset
|
775 base buffer. */ |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
776 if (next && b->text != next->buffer->text) |
118 | 777 abort (); |
778 } | |
779 else | |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
780 prev->next = next; |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
781 /* We have removed the marker from the chain; |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
782 no need to scan the rest of the chain. */ |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
783 return; |
118 | 784 } |
785 else | |
786 prev = tail; | |
787 tail = next; | |
788 } | |
22022
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
789 |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
790 /* Marker was not in its chain. */ |
64ac294567a6
(unchain_marker): Abort if the marker is not in its buffer's chain.
Richard M. Stallman <rms@gnu.org>
parents:
21528
diff
changeset
|
791 abort (); |
118 | 792 } |
793 | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
794 /* Return the char position of marker MARKER, as a C integer. */ |
10315
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
795 |
c78d0bb85d30
Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9315
diff
changeset
|
796 int |
118 | 797 marker_position (marker) |
798 Lisp_Object marker; | |
799 { | |
800 register struct Lisp_Marker *m = XMARKER (marker); | |
801 register struct buffer *buf = m->buffer; | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
802 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
803 if (!buf) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
804 error ("Marker does not point anywhere"); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
805 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
806 return m->charpos; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
807 } |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
808 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
809 /* Return the byte position of marker MARKER, as a C integer. */ |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
810 |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
811 int |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
812 marker_byte_position (marker) |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
813 Lisp_Object marker; |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
814 { |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
815 register struct Lisp_Marker *m = XMARKER (marker); |
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
816 register struct buffer *buf = m->buffer; |
20563
d4de7ffb567d
(buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents:
20537
diff
changeset
|
817 register int i = m->bytepos; |
118 | 818 |
819 if (!buf) | |
820 error ("Marker does not point anywhere"); | |
821 | |
20537
cc87b03bad13
(marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents:
20301
diff
changeset
|
822 if (i < BUF_BEG_BYTE (buf) || i > BUF_Z_BYTE (buf)) |
118 | 823 abort (); |
824 | |
825 return i; | |
826 } | |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
827 |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
828 DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 1, 2, 0, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
829 doc: /* Return a new marker pointing at the same place as MARKER. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
830 If argument is a number, makes a new marker pointing |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
831 at that position in the current buffer. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
832 The optional argument TYPE specifies the insertion type of the new marker; |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
833 see `marker-insertion-type'. */) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
834 (marker, type) |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
835 register Lisp_Object marker, type; |
118 | 836 { |
837 register Lisp_Object new; | |
838 | |
71840
96e9b3cb9809
(Fcopy_marker): Use CHECK_TYPE.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
839 CHECK_TYPE (INTEGERP (marker) || MARKERP (marker), Qinteger_or_marker_p, marker); |
22744
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
840 |
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
841 new = Fmake_marker (); |
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
842 Fset_marker (new, marker, |
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
843 (MARKERP (marker) ? Fmarker_buffer (marker) : Qnil)); |
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
844 XMARKER (new)->insertion_type = !NILP (type); |
79ca732d9740
(Fcopy_marker): Make return from wrong_type_argument
Karl Heuer <kwzh@gnu.org>
parents:
22022
diff
changeset
|
845 return new; |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
846 } |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
847 |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
848 DEFUN ("marker-insertion-type", Fmarker_insertion_type, |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
849 Smarker_insertion_type, 1, 1, 0, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
850 doc: /* Return insertion type of MARKER: t if it stays after inserted text. |
74568
21b2a6ce1aa9
(Fmarker_insertion_type): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
72625
diff
changeset
|
851 The value nil means the marker stays before text inserted there. */) |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
852 (marker) |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
853 register Lisp_Object marker; |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
854 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
855 CHECK_MARKER (marker); |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
856 return XMARKER (marker)->insertion_type ? Qt : Qnil; |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
857 } |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
858 |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
859 DEFUN ("set-marker-insertion-type", Fset_marker_insertion_type, |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
860 Sset_marker_insertion_type, 2, 2, 0, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
861 doc: /* Set the insertion-type of MARKER to TYPE. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
862 If TYPE is t, it means the marker advances when you insert text at it. |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
863 If TYPE is nil, it means the marker stays behind when you insert text at it. */) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
864 (marker, type) |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
865 Lisp_Object marker, type; |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
866 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40553
diff
changeset
|
867 CHECK_MARKER (marker); |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
868 |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
869 XMARKER (marker)->insertion_type = ! NILP (type); |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
870 return type; |
118 | 871 } |
16418
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
872 |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
873 DEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, Sbuffer_has_markers_at, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
874 1, 1, 0, |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
875 doc: /* Return t if there are markers pointing at POSITION in the current buffer. */) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
876 (position) |
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
877 Lisp_Object position; |
16418
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
878 { |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
879 register struct Lisp_Marker *tail; |
16418
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
880 register int charno; |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
881 |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
882 charno = XINT (position); |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
883 |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
884 if (charno < BEG) |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
885 charno = BEG; |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
886 if (charno > Z) |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
887 charno = Z; |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
888 |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
889 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
890 if (tail->charpos == charno) |
16418
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
891 return Qt; |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
892 |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
893 return Qnil; |
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
894 } |
44560
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
895 |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
896 /* For debugging -- count the markers in buffer BUF. */ |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
897 |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
898 int |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
899 count_markers (buf) |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
900 struct buffer *buf; |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
901 { |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
902 int total = 0; |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
903 struct Lisp_Marker *tail; |
44560
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
904 |
51672
018c85ec9a1e
(buf_charpos_to_bytepos, buf_bytepos_to_charpos)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50472
diff
changeset
|
905 for (tail = BUF_MARKERS (buf); tail; tail = tail->next) |
44560
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
906 total++; |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
907 |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
908 return total; |
0fddc27db9ae
(count_markers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44328
diff
changeset
|
909 } |
118 | 910 |
20301
6e2ea54ad704
(unchain_marker): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents:
16418
diff
changeset
|
911 void |
118 | 912 syms_of_marker () |
913 { | |
914 defsubr (&Smarker_position); | |
915 defsubr (&Smarker_buffer); | |
916 defsubr (&Sset_marker); | |
917 defsubr (&Scopy_marker); | |
12999
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
918 defsubr (&Smarker_insertion_type); |
b889a50f71db
(Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
919 defsubr (&Sset_marker_insertion_type); |
16418
cf4260218aec
(Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
920 defsubr (&Sbuffer_has_markers_at); |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
921 |
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
922 DEFVAR_BOOL ("byte-debug-flag", &byte_debug_flag, |
40553
440be654a370
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
34972
diff
changeset
|
923 doc: /* Non-nil enables debugging checks in byte/char position conversions. */); |
20872
431f875501a6
(byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20706
diff
changeset
|
924 byte_debug_flag = 0; |
118 | 925 } |
52401 | 926 |
927 /* arch-tag: 50aa418f-cdd0-4838-b64b-94aa4b2a3b74 | |
928 (do not change this comment) */ |