#endif /* not MAXPATHLEN */
#include <config.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include "lisp.h"
#include "intervals.h"
#include "window.h"
b->file_format = Qnil;
b->last_selected_window = Qnil;
XSETINT (b->display_count, 0);
+ b->display_time = Qnil;
b->extra2 = Qnil;
b->extra3 = Qnil;
b->enable_multibyte_characters = buffer_defaults.enable_multibyte_characters;
valcontents = XSYMBOL (XCONS (XCONS (tail)->car)->car)->value;
if ((BUFFER_LOCAL_VALUEP (valcontents)
|| SOME_BUFFER_LOCAL_VALUEP (valcontents))
- && (tem = XBUFFER_LOCAL_VALUE (valcontents)->car,
+ && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
(BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
/* Just reference the variable
to cause it to become set for this buffer. */
valcontents = XSYMBOL (XCONS (XCONS (tail)->car)->car)->value;
if ((BUFFER_LOCAL_VALUEP (valcontents)
|| SOME_BUFFER_LOCAL_VALUEP (valcontents))
- && (tem = XBUFFER_LOCAL_VALUE (valcontents)->car,
+ && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
(BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
/* Just reference the variable
to cause it to become set for this buffer. */
{
Lisp_Object tail, markers;
+ /* Do nothing if nothing actually changes. */
+ if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters))
+ return flag;
+
/* It would be better to update the list,
but this is good enough for now. */
if (! EQ (current_buffer->undo_list, Qt))
}
tail = markers = BUF_MARKERS (current_buffer);
+
+ /* This prevents BYTE_TO_CHAR (that is, buf_bytepos_to_charpos) from
+ getting confused by the markers that have not yet been updated.
+ It is also a signal that it should never create a marker. */
BUF_MARKERS (current_buffer) = Qnil;
while (XSYMBOL (tail) != XSYMBOL (Qnil))
tail = XMARKER (tail)->chain;
}
+
+ /* Make sure no markers were put on the chain
+ while the chain value was incorrect. */
+ if (! EQ (BUF_MARKERS (current_buffer), Qnil))
+ abort ();
+
BUF_MARKERS (current_buffer) = markers;
/* Do this last, so it can calculate the new correspondences
sym = XCONS (XCONS (alist)->car)->car;
/* Need not do anything if some other buffer's binding is now encached. */
- tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car;
+ tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer;
if (XBUFFER (tem) == current_buffer)
{
/* Symbol is set up for this buffer's old local value.
Set it up for the current buffer with the default value. */
- tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->cdr;
+ tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr;
/* Store the symbol's current value into the alist entry
it is currently set up for. This is so that, if the
local is marked permanent, and we make it local again
later in Fkill_all_local_variables, we don't lose the value. */
XCONS (XCONS (tem)->car)->cdr
- = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car);
+ = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue);
/* Switch to the symbol's default-value alist entry. */
XCONS (tem)->car = tem;
/* Mark it as current for buffer B. */
- XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car
- = buffer;
+ XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer = buffer;
/* Store the current value into any forwarding in the symbol. */
- store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car,
+ store_symval_forwarding (sym,
+ XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue,
XCONS (tem)->cdr);
}
}
};
static int
-compare_overlays (s1, s2)
- struct sortvec *s1, *s2;
+compare_overlays (v1, v2)
+ const void *v1, *v2;
{
+ const struct sortvec *s1 = (const struct sortvec *) v1;
+ const struct sortvec *s2 = (const struct sortvec *) v2;
if (s1->priority != s2->priority)
return s1->priority - s2->priority;
if (s1->beg != s2->beg)
nbytes = XSTRING (str)->size;
else if (! STRING_MULTIBYTE (str))
nbytes = count_size_as_multibyte (XSTRING (str)->data,
- XSTRING (str)->size_byte);
+ STRING_BYTES (XSTRING (str)));
else
- nbytes = XSTRING (str)->size_byte;
+ nbytes = STRING_BYTES (XSTRING (str));
ssl->bytes += nbytes;
nbytes = XSTRING (str2)->size;
else if (! STRING_MULTIBYTE (str2))
nbytes = count_size_as_multibyte (XSTRING (str2)->data,
- XSTRING (str2)->size_byte);
+ STRING_BYTES (XSTRING (str2)));
else
- nbytes = XSTRING (str2)->size_byte;
+ nbytes = STRING_BYTES (XSTRING (str2));
ssl->bytes += nbytes;
}
{
int nbytes;
tem = overlay_tails.buf[i].string;
- nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte,
+ nbytes = copy_text (XSTRING (tem)->data, p,
+ STRING_BYTES (XSTRING (tem)),
STRING_MULTIBYTE (tem), multibyte);
p += nbytes;
}
{
int nbytes;
tem = overlay_heads.buf[i].string;
- nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte,
+ nbytes = copy_text (XSTRING (tem)->data, p,
+ STRING_BYTES (XSTRING (tem)),
STRING_MULTIBYTE (tem), multibyte);
p += nbytes;
tem = overlay_heads.buf[i].string2;
if (STRINGP (tem))
{
nbytes = copy_text (XSTRING (tem)->data, p,
- XSTRING (tem)->size_byte,
+ STRING_BYTES (XSTRING (tem)),
STRING_MULTIBYTE (tem), multibyte);
p += nbytes;
}
b->overlays_after = Fdelq (overlay, b->overlays_after);
modify_overlay (b,
- marker_position (OVERLAY_START (overlay)),
- marker_position (OVERLAY_END (overlay)));
+ marker_position (OVERLAY_START (overlay)),
+ marker_position (OVERLAY_END (overlay)));
Fset_marker (OVERLAY_START (overlay), Qnil, Qnil);
Fset_marker (OVERLAY_END (overlay), Qnil, Qnil);
type_name, XSYMBOL (sym)->name->data);
}
\f
+void
init_buffer_once ()
{
register Lisp_Object tem;
buffer_defaults.cache_long_line_scans = Qnil;
buffer_defaults.file_truename = Qnil;
XSETFASTINT (buffer_defaults.display_count, 0);
+ buffer_defaults.display_time = Qnil;
/* Assign the local-flags to the slots that have default values.
The local flag is a bit that is used in the buffer
XSETINT (buffer_local_flags.invisibility_spec, -1);
XSETINT (buffer_local_flags.file_format, -1);
XSETINT (buffer_local_flags.display_count, -1);
+ XSETINT (buffer_local_flags.display_time, -1);
XSETINT (buffer_local_flags.enable_multibyte_characters, -1);
XSETFASTINT (buffer_local_flags.mode_line_format, 1);
Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
}
+void
init_buffer ()
{
char buf[MAXPATHLEN+1];
int rc;
Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
+ if (NILP (buffer_defaults.enable_multibyte_characters))
+ Fset_buffer_multibyte (Qnil);
/* If PWD is accurate, use it instead of calling getwd. This is faster
when PWD is right, and may avoid a fatal error. */
}
/* initialize the buffer routines */
+void
syms_of_buffer ()
{
extern Lisp_Object Qdisabled;
¤t_buffer->buffer_file_coding_system, Qnil,
"Coding system to be used for encoding the buffer contents on saving.\n\
If it is nil, the buffer is saved without any code conversion unless\n\
-some coding system is specified in file-coding-system-alist\n\
+some coding system is specified in `file-coding-system-alist'\n\
for the buffer file.\n\
\n\
This variable is never applied to a way of decoding\n\
but make-docfile can find it in this comment. */
DEFVAR_PER_BUFFER ("buffer-undo-list", ¤t_buffer->undo_list, Qnil,
"List of undo entries in current buffer.\n\
+This variable is always local in all buffers.\n\
Recent changes come first; older changes follow newer.\n\
\n\
An entry (BEG . END) represents an insertion which begins at\n\
functions; it should only affect their performance.");
DEFVAR_PER_BUFFER ("point-before-scroll", ¤t_buffer->point_before_scroll, Qnil,
- "Value of point before the last series of scroll operations, or nil.");
+ "Value of point before the last series of scroll operations, or nil.\n\
+This variable is always local in all buffers.");
DEFVAR_PER_BUFFER ("buffer-file-format", ¤t_buffer->file_format, Qnil,
"List of formats to use when saving this buffer.\n\
+This variable is always local in all buffers.\n\
Formats are defined by `format-alist'. This variable is\n\
set when a file is visited. Automatically local in all buffers.");
DEFVAR_PER_BUFFER ("buffer-invisibility-spec",
¤t_buffer->invisibility_spec, Qnil,
"Invisibility spec of this buffer.\n\
+This variable is always local in all buffers.\n\
The default is t, which means that text is invisible\n\
if it has a non-nil `invisible' property.\n\
If the value is a list, a text character is invisible if its `invisible'\n\
DEFVAR_PER_BUFFER ("buffer-display-count",
¤t_buffer->display_count, Qnil,
- "A number incremented each time the buffer is displayed in a window.");
+ "A number incremented each time this buffer is displayed in a window.\n\
+This variable is always local in all buffers.\n\
+The function `set-window-buffer increments it.");
+
+ DEFVAR_PER_BUFFER ("buffer-display-time",
+ ¤t_buffer->display_time, Qnil,
+ "Time stamp updated each time this buffer is displayed in a window.\n\
+This variable is always local in all buffers.\n\
+The function `set-window-buffer' updates this variable\n\
+to the value obtained by calling `current-time'.\n\
+If the buffer has never been shown in a window, the value is nil.");
DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode,
"*Non-nil means deactivate the mark when the buffer contents change.\n\
defsubr (&Soverlay_put);
}
+void
keys_of_buffer ()
{
initial_define_key (control_x_map, 'b', "switch-to-buffer");