annotate src/marker.c @ 21003:fd244f615d9d

(info): Always switch to buffer *info* even if current buffer is in Info mode.
author Richard M. Stallman <rms@gnu.org>
date Fri, 27 Feb 1998 23:30:11 +0000
parents 431f875501a6
children 29d2cf14040a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
20706
d43ba5d91281 Update copyright year.
Richard M. Stallman <rms@gnu.org>
parents: 20678
diff changeset
2 Copyright (C) 1985, 1997, 1998 Free Software Foundation, Inc.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 10999
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14082
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14082
diff changeset
19 Boston, MA 02111-1307, USA. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 484
diff changeset
22 #include <config.h>
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include "lisp.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include "buffer.h"
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
25 #include "charset.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
27 /* 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
28 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
29
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
30 static int cached_charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
31 static int cached_bytepos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
32 static struct buffer *cached_buffer;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
33 static int cached_modiff;
20678
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
34
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
35 /* 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
36
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
37 static int byte_debug_flag;
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
38
20678
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
39 clear_charpos_cache (b)
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
40 struct buffer *b;
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
41 {
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
42 if (cached_buffer == b)
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
43 cached_buffer = 0;
4c69e3503cfc (clear_charpos_cache): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20563
diff changeset
44 }
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
45
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
46 /* 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
47
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
48 /* There are several places in the buffer where we know
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
49 the corrspondence: BEG, BEGV, PT, GPT, ZV and Z,
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
50 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
51 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
52
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
53 /* 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
54
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
55 /* 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
56 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
57 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
58
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
59 #define CONSIDER(CHARPOS, BYTEPOS) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
60 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
61 int this_charpos = (CHARPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
62 int changed = 0; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
63 \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
64 if (this_charpos == charpos) \
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
65 { \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
66 int value = (BYTEPOS); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
67 if (byte_debug_flag) \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
68 byte_char_debug_check (b, charpos, value); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
69 return value; \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
70 } \
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
71 else if (this_charpos > charpos) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
72 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
73 if (this_charpos < best_above) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
74 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
75 best_above = this_charpos; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
76 best_above_byte = (BYTEPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
77 changed = 1; \
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 } \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
80 else if (this_charpos > best_below) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
81 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
82 best_below = this_charpos; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
83 best_below_byte = (BYTEPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
84 changed = 1; \
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 \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
87 if (changed) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
88 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
89 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
90 { \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
91 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
92 if (byte_debug_flag) \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
93 byte_char_debug_check (b, charpos, value); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
94 return value; \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
95 } \
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
96 } \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
97 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
98
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
99 int
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
100 byte_char_debug_check (b, charpos, bytepos)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
101 struct buffer *b;
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
102 int charpos, bytepos;
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
103 {
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
104 int nchars = 0;
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
105
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
106 if (bytepos > BUF_GPT_BYTE (b))
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 nchars = chars_in_text (BUF_BEG_ADDR (b),
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
109 BUF_GPT_BYTE (b) - BUF_BEG_BYTE (b));
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
110 nchars += chars_in_text (BUF_GAP_END_ADDR (b),
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
111 bytepos - BUF_GPT_BYTE (b));
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
112 }
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
113 else
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
114 nchars = chars_in_text (BUF_BEG_ADDR (b), bytepos - BUF_BEG_BYTE (b));
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
115
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
116 if (charpos - 1 != nchars)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
117 abort ();
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
118 }
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
119
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
120 int
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
121 charpos_to_bytepos (charpos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
122 int charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
123 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
124 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
125 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
126
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
127 int
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
128 buf_charpos_to_bytepos (b, charpos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
129 struct buffer *b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
130 int charpos;
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 Lisp_Object tail;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
133 int gapend_byte = BUF_GPT_BYTE (b) + BUF_GAP_SIZE (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
134 int best_above, best_above_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
135 int best_below, best_below_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
136
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
137 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
138 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
139
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
140 best_above = BUF_Z (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
141 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
142
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
143 /* 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
144 each character must be one byte.
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
145 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
146 if (best_above == best_above_byte)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
147 return charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
148
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
149 best_below = 1;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
150 best_below_byte = 1;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
151
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
152 /* 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
153 the closest known point above CHARPOS,
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
154 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
155 the closest known point below CHARPOS,
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
156
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
157 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
158 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
159 we interpolate the result immediately. */
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 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
162 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
163 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
164 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
165
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
166 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
167 CONSIDER (cached_charpos, cached_bytepos);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
168
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
169 tail = BUF_MARKERS (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
170 while (XSYMBOL (tail) != XSYMBOL (Qnil))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
171 {
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
172 CONSIDER (XMARKER (tail)->charpos, XMARKER (tail)->bytepos);
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
173
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
174 /* 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
175 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
176 scan the intervening chars directly now. */
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
177 if (best_above - best_below < 50)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
178 break;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
179
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
180 tail = XMARKER (tail)->chain;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
181 }
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 /* 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
184 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
185 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
186
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
187 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
188 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
189 int record = charpos - best_below > 5000;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
190
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
191 while (best_below != charpos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
192 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
193 best_below++;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
194 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
195 }
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 /* 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
198 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
199 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
200 if (record)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
201 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
202 Lisp_Object marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
203 marker = Fmake_marker ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
204 set_marker_both (marker, Qnil, best_below, best_below_byte);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
205 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
206
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
207 if (byte_debug_flag)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
208 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
209
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
210 cached_buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
211 cached_modiff = BUF_MODIFF (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
212 cached_charpos = best_below;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
213 cached_bytepos = best_below_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
214
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
215 return 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 else
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 int record = best_above - charpos > 5000;
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 while (best_above != charpos)
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 best_above--;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
224 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
225 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
226
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
227 /* 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
228 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
229 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
230 if (record)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
231 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
232 Lisp_Object marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
233 marker = Fmake_marker ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
234 set_marker_both (marker, Qnil, best_above, best_above_byte);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
235 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
236
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
237 if (byte_debug_flag)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
238 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
239
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
240 cached_buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
241 cached_modiff = BUF_MODIFF (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
242 cached_charpos = best_above;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
243 cached_bytepos = best_above_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
244
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
245 return best_above_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
246 }
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
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
249 #undef CONSIDER
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 /* 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
252
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
253 /* 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
254 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
255
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
256 #define CONSIDER(BYTEPOS, CHARPOS) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
257 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
258 int this_bytepos = (BYTEPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
259 int changed = 0; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
260 \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
261 if (this_bytepos == bytepos) \
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
262 { \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
263 int value = (CHARPOS); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
264 if (byte_debug_flag) \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
265 byte_char_debug_check (b, value, bytepos); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
266 return value; \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
267 } \
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
268 else if (this_bytepos > bytepos) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
269 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
270 if (this_bytepos < best_above_byte) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
271 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
272 best_above = (CHARPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
273 best_above_byte = this_bytepos; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
274 changed = 1; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
275 } \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
276 } \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
277 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
278 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
279 best_below = (CHARPOS); \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
280 best_below_byte = this_bytepos; \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
281 changed = 1; \
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 \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
284 if (changed) \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
285 { \
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
286 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
287 { \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
288 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
289 if (byte_debug_flag) \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
290 byte_char_debug_check (b, value, bytepos); \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
291 return value; \
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
292 } \
20537
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 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
295
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
296 int
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
297 bytepos_to_charpos (bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
298 int bytepos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
299 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
300 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
301 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
302
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
303 int
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
304 buf_bytepos_to_charpos (b, bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
305 struct buffer *b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
306 int bytepos;
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 Lisp_Object tail;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
309 int best_above, best_above_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
310 int best_below, best_below_byte;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
311
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
312 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
313 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
314
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
315 best_above = BUF_Z (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
316 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
317
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
318 /* 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
319 each character must be one byte.
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
320 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
321 if (best_above == best_above_byte)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
322 return 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 best_below = 1;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
325 best_below_byte = 1;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
326
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
327 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
328 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
329 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
330 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
331
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
332 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
333 CONSIDER (cached_bytepos, cached_charpos);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
334
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
335 tail = BUF_MARKERS (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
336 while (XSYMBOL (tail) != XSYMBOL (Qnil))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
337 {
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
338 CONSIDER (XMARKER (tail)->bytepos, XMARKER (tail)->charpos);
20537
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 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
341 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
342 scan the intervening chars directly now. */
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
343 if (best_above - best_below < 50)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
344 break;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
345
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
346 tail = XMARKER (tail)->chain;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
347 }
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 /* 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
350 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
351 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
352
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
353 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
354 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
355 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
356
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
357 while (best_below_byte < bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
358 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
359 best_below++;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
360 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
361 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
362
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
363 /* 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
364 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
365 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
366 if (record)
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 Lisp_Object marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
369 marker = Fmake_marker ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
370 set_marker_both (marker, Qnil, best_below, best_below_byte);
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
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
373 if (byte_debug_flag)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
374 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
375
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
376 cached_buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
377 cached_modiff = BUF_MODIFF (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
378 cached_charpos = best_below;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
379 cached_bytepos = 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 return best_below;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
382 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
383 else
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
384 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
385 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
386
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
387 while (best_above_byte > bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
388 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
389 best_above--;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
390 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
391 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
392
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
393 /* 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
394 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
395 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
396 if (record)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
397 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
398 Lisp_Object marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
399 marker = Fmake_marker ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
400 set_marker_both (marker, Qnil, best_above, best_above_byte);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
401 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
402
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
403 if (byte_debug_flag)
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
404 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
405
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
406 cached_buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
407 cached_modiff = BUF_MODIFF (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
408 cached_charpos = best_above;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
409 cached_bytepos = best_above_byte;
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 return best_above;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
412 }
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 #undef CONSIDER
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
416
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 /* Operations on markers. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 DEFUN ("marker-buffer", Fmarker_buffer, Smarker_buffer, 1, 1, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 "Return the buffer that MARKER points into, or nil if none.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 Returns nil if MARKER points into a dead buffer.")
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (marker)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 register Lisp_Object marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 register Lisp_Object buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 CHECK_MARKER (marker, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 if (XMARKER (marker)->buffer)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 {
9275
bb50d17f7441 (Fmarker_buffer): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents: 9121
diff changeset
429 XSETBUFFER (buf, XMARKER (marker)->buffer);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 /* Return marker's buffer only if it is not dead. */
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 118
diff changeset
431 if (!NILP (XBUFFER (buf)->name))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 return buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 return Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 DEFUN ("marker-position", Fmarker_position, Smarker_position, 1, 1, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 "Return the position MARKER points at, as a character number.")
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (marker)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 Lisp_Object marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 register Lisp_Object pos;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 register int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 register struct buffer *buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 CHECK_MARKER (marker, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 if (XMARKER (marker)->buffer)
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
448 return make_number (XMARKER (marker)->charpos);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 return Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 }
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
452
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 DEFUN ("set-marker", Fset_marker, Sset_marker, 2, 3, 0,
14082
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
454 "Position MARKER before character number POSITION in BUFFER.\n\
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 BUFFER defaults to the current buffer.\n\
14082
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
456 If POSITION is nil, makes marker point nowhere.\n\
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 Then it no longer slows down editing in any buffer.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 Returns MARKER.")
14082
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
459 (marker, position, buffer)
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
460 Lisp_Object marker, position, buffer;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 {
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
462 register int charno, bytepos;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 register struct buffer *b;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 register struct Lisp_Marker *m;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 CHECK_MARKER (marker, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 /* If position is nil or a marker that points nowhere,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 make this marker point nowhere. */
14082
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
469 if (NILP (position)
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
470 || (MARKERP (position) && !XMARKER (position)->buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 118
diff changeset
476 if (NILP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 b = current_buffer;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 CHECK_BUFFER (buffer, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 b = XBUFFER (buffer);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 /* If buffer is dead, set marker to point nowhere. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 if (EQ (b->name, Qnil))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
490 m = XMARKER (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
491
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
492 /* 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
493 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
494 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
495 && b == m->buffer)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
496 {
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
497 m->bytepos = XMARKER (position)->bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
498 m->charpos = XMARKER (position)->charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
499 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
500 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
501
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
502 CHECK_NUMBER_COERCE_MARKER (position, 1);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
503
14082
c6a1708f37d4 (Fset_marker): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13327
diff changeset
504 charno = XINT (position);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 if (charno < BUF_BEG (b))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 charno = BUF_BEG (b);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 if (charno > BUF_Z (b))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 charno = BUF_Z (b);
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
510
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
511 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
512
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
513 /* 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
514 if (charno > bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
515 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
516
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
517 m->bytepos = bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
518 m->charpos = charno;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 if (m->buffer != b)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 m->buffer = b;
10315
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
524 m->chain = BUF_MARKERS (b);
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
525 BUF_MARKERS (b) = marker;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 /* This version of Fset_marker won't let the position
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 be outside the visible part. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 Lisp_Object
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 set_marker_restricted (marker, pos, buffer)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 Lisp_Object marker, pos, buffer;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 {
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
538 register int charno, bytepos;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 register struct buffer *b;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 register struct Lisp_Marker *m;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 CHECK_MARKER (marker, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 /* If position is nil or a marker that points nowhere,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 make this marker point nowhere. */
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
545 if (NILP (pos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
546 || (MARKERP (pos) && !XMARKER (pos)->buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 118
diff changeset
552 if (NILP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 b = current_buffer;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 CHECK_BUFFER (buffer, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 b = XBUFFER (buffer);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 /* If buffer is dead, set marker to point nowhere. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 if (EQ (b->name, Qnil))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
566 m = XMARKER (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
567
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
568 /* 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
569 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
570 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
571 && b == m->buffer)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
572 {
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
573 m->bytepos = XMARKER (pos)->bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
574 m->charpos = XMARKER (pos)->charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
575 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
576 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
577
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
578 CHECK_NUMBER_COERCE_MARKER (pos, 1);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
579
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 charno = XINT (pos);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 if (charno < BUF_BEGV (b))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 charno = BUF_BEGV (b);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 if (charno > BUF_ZV (b))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 charno = BUF_ZV (b);
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
586
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
587 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
588
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
589 /* 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
590 if (charno > bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
591 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
592
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
593 m->bytepos = bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
594 m->charpos = charno;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
595
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
596 if (m->buffer != b)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
597 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
598 unchain_marker (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
599 m->buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
600 m->chain = BUF_MARKERS (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
601 BUF_MARKERS (b) = marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
602 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
603
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
604 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
605 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
606
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
607 /* 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
608 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
609
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
610 Lisp_Object
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
611 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
612 Lisp_Object marker, buffer;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
613 int charpos, bytepos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
614 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
615 register struct buffer *b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
616 register struct Lisp_Marker *m;
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 CHECK_MARKER (marker, 0);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
619 /* If position is nil or a marker that points nowhere,
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
620 make this marker point nowhere. */
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
621 if (NILP (charpos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
622 || (MARKERP (charpos) && !XMARKER (charpos)->buffer))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
623 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
624 unchain_marker (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
625 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
626 }
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 CHECK_NUMBER_COERCE_MARKER (charpos, 1);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
629 if (NILP (buffer))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
630 b = current_buffer;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
631 else
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
632 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
633 CHECK_BUFFER (buffer, 1);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
634 b = XBUFFER (buffer);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
635 /* 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
636 if (EQ (b->name, Qnil))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
637 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
638 unchain_marker (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
639 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
640 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
641 }
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 m = XMARKER (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
644
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
645 /* 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
646 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
647 && charpos != bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
648 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
649 /* 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
650 if (charpos > bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
651 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
652
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
653 m->bytepos = bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
654 m->charpos = charpos;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 if (m->buffer != b)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 unchain_marker (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 m->buffer = b;
10315
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
660 m->chain = BUF_MARKERS (b);
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
661 BUF_MARKERS (b) = marker;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 return marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
667 /* 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
668 be outside the visible part. */
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
669
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
670 Lisp_Object
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
671 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
672 Lisp_Object marker, buffer;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
673 int charpos, bytepos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
674 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
675 register struct buffer *b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
676 register struct Lisp_Marker *m;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
677
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
678 CHECK_MARKER (marker, 0);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
679
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
680 if (NILP (buffer))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
681 b = current_buffer;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
682 else
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
683 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
684 CHECK_BUFFER (buffer, 1);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
685 b = XBUFFER (buffer);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
686 /* 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
687 if (EQ (b->name, Qnil))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
688 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
689 unchain_marker (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
690 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
691 }
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
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
694 m = XMARKER (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
695
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
696 if (charpos < BUF_BEGV (b))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
697 charpos = BUF_BEGV (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
698 if (charpos > BUF_ZV (b))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
699 charpos = BUF_ZV (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
700 if (bytepos < BUF_BEGV_BYTE (b))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
701 bytepos = BUF_BEGV_BYTE (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
702 if (bytepos > BUF_ZV_BYTE (b))
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
703 bytepos = BUF_ZV_BYTE (b);
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 /* 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
706 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
707 && charpos != bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
708 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
709 /* 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
710 if (charpos > bytepos)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
711 abort ();
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
712
20563
d4de7ffb567d (buf_bytepos_to_charpos): Use marker bytepos, not bufpos.
Richard M. Stallman <rms@gnu.org>
parents: 20537
diff changeset
713 m->bytepos = bytepos;
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
714 m->charpos = charpos;
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 if (m->buffer != b)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
717 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
718 unchain_marker (marker);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
719 m->buffer = b;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
720 m->chain = BUF_MARKERS (b);
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
721 BUF_MARKERS (b) = marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
722 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
723
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
724 return marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
725 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
726
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 /* This is called during garbage collection,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 so we must be careful to ignore and preserve mark bits,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 including those in chain fields of markers. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
20301
6e2ea54ad704 (unchain_marker): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16418
diff changeset
731 void
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 unchain_marker (marker)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 register Lisp_Object marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 register Lisp_Object tail, prev, next;
8829
6f0d48241807 (unchain_marker): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
736 register EMACS_INT omark;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 register struct buffer *b;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 b = XMARKER (marker)->buffer;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 if (b == 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 return;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 if (EQ (b->name, Qnil))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 abort ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745
10315
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
746 tail = BUF_MARKERS (b);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 prev = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 while (XSYMBOL (tail) != XSYMBOL (Qnil))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 next = XMARKER (tail)->chain;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 XUNMARK (next);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 if (XMARKER (marker) == XMARKER (tail))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 {
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 118
diff changeset
755 if (NILP (prev))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 {
10315
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
757 BUF_MARKERS (b) = next;
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
758 /* Deleting first marker from the buffer's chain. Crash
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
759 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
760 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
761 base buffer. */
84076f6a1f1b (unchain_marker): Allow differing buffers
Richard M. Stallman <rms@gnu.org>
parents: 10315
diff changeset
762 if (!NILP (next) && b->text != XMARKER (next)->buffer->text)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 abort ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 omark = XMARKBIT (XMARKER (prev)->chain);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 XMARKER (prev)->chain = next;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 XSETMARKBIT (XMARKER (prev)->chain, omark);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 prev = tail;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 tail = next;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 XMARKER (marker)->buffer = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
780 /* 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
781
c78d0bb85d30 Use BUF_MARKERS throughout.
Richard M. Stallman <rms@gnu.org>
parents: 9315
diff changeset
782 int
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 marker_position (marker)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 Lisp_Object marker;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 register struct Lisp_Marker *m = XMARKER (marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 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
788
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
789 if (!buf)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
790 error ("Marker does not point anywhere");
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
791
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
792 return m->charpos;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
793 }
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
794
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
795 /* 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
796
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
797 int
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
798 marker_byte_position (marker)
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
799 Lisp_Object marker;
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
800 {
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
801 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
802 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
803 register int i = m->bytepos;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 if (!buf)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 error ("Marker does not point anywhere");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
808 if (i < BUF_BEG_BYTE (buf) || i > BUF_Z_BYTE (buf))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 abort ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 return i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 }
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
813
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
814 DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 1, 2, 0,
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 "Return a new marker pointing at the same place as MARKER.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 If argument is a number, makes a new marker pointing\n\
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
817 at that position in the current buffer.\n\
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
818 The optional argument TYPE specifies the insertion type of the new marker;\n\
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
819 see `marker-insertion-type'.")
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
820 (marker, type)
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
821 register Lisp_Object marker, type;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 register Lisp_Object new;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
825 if (INTEGERP (marker) || MARKERP (marker))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 {
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
827 new = Fmake_marker ();
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
828 Fset_marker (new, marker,
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
829 (MARKERP (marker) ? Fmarker_buffer (marker) : Qnil));
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
830 XMARKER (new)->insertion_type = !NILP (type);
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
831 return new;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 }
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
833 else
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
834 marker = wrong_type_argument (Qinteger_or_marker_p, marker);
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
835 }
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
836
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
837 DEFUN ("marker-insertion-type", Fmarker_insertion_type,
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
838 Smarker_insertion_type, 1, 1, 0,
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
839 "Return insertion type of MARKER: t if it stays after inserted text.\n\
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
840 nil means the marker stays before text inserted there.")
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
841 (marker)
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
842 register Lisp_Object marker;
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
843 {
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
844 register Lisp_Object buf;
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
845 CHECK_MARKER (marker, 0);
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
846 return XMARKER (marker)->insertion_type ? Qt : Qnil;
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
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
849 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
850 Sset_marker_insertion_type, 2, 2, 0,
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
851 "Set the insertion-type of MARKER to TYPE.\n\
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
852 If TYPE is t, it means the marker advances when you insert text at it.\n\
13327
e518c2be8d7b (Fset_marker_insertion_type): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12999
diff changeset
853 If TYPE is nil, it means the marker stays behind when you insert text at it.")
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
854 (marker, type)
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
855 Lisp_Object marker, type;
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
856 {
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
857 CHECK_MARKER (marker, 0);
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 XMARKER (marker)->insertion_type = ! NILP (type);
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
860 return type;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 }
16418
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
862
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
863 DEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, Sbuffer_has_markers_at,
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
864 1, 1, 0,
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
865 "Return t if there are markers pointing at POSITION in the current buffer.")
16418
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
866 (position)
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
867 Lisp_Object position;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
868 {
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
869 register Lisp_Object tail;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
870 register int charno;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
871
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
872 charno = XINT (position);
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
873
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
874 if (charno < BEG)
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
875 charno = BEG;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
876 if (charno > Z)
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
877 charno = Z;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
878
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
879 for (tail = BUF_MARKERS (current_buffer);
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
880 XSYMBOL (tail) != XSYMBOL (Qnil);
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
881 tail = XMARKER (tail)->chain)
20537
cc87b03bad13 (marker_byte_position): Renamed from marker_position.
Richard M. Stallman <rms@gnu.org>
parents: 20301
diff changeset
882 if (XMARKER (tail)->charpos == charno)
16418
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
883 return Qt;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
884
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
885 return Qnil;
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
886 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887
20301
6e2ea54ad704 (unchain_marker): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16418
diff changeset
888 void
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 syms_of_marker ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 defsubr (&Smarker_position);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 defsubr (&Smarker_buffer);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 defsubr (&Sset_marker);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 defsubr (&Scopy_marker);
12999
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
895 defsubr (&Smarker_insertion_type);
b889a50f71db (Fcopy_marker): New arg TYPE.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
896 defsubr (&Sset_marker_insertion_type);
16418
cf4260218aec (Fbuffer_has_markers_at): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
897 defsubr (&Sbuffer_has_markers_at);
20872
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
898
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
899 DEFVAR_BOOL ("byte-debug-flag", &byte_debug_flag,
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
900 "Non-nil enables debugging checks in byte/char position conversions.");
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
901 byte_debug_flag = 0;
431f875501a6 (byte_char_debug_check): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20706
diff changeset
902
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 }