/* Buffer manipulation primitives for GNU Emacs.
- Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994,
- 1995, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
- Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997,
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
int last_per_buffer_idx;
EXFUN (Fset_buffer, 1);
-void set_buffer_internal (struct buffer *b);
-void set_buffer_internal_1 (struct buffer *b);
static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
int after, Lisp_Object arg1,
Lisp_Object arg2, Lisp_Object arg3);
Lisp_Object Qoverlayp;
-Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string;
+Lisp_Object Qpriority, Qevaporate, Qbefore_string, Qafter_string;
Lisp_Object Qmodification_hooks;
Lisp_Object Qinsert_in_front_hooks;
and return the adjusted position. */
static int
-advance_to_char_boundary (int byte_pos)
+advance_to_char_boundary (EMACS_INT byte_pos)
{
int c;
{
/* We should advance BYTE_POS only when C is a constituent of a
multibyte sequence. */
- int orig_byte_pos = byte_pos;
+ EMACS_INT orig_byte_pos = byte_pos;
do
{
{
struct Lisp_Marker *tail, *markers;
struct buffer *other;
- int begv, zv;
+ EMACS_INT begv, zv;
int narrowed = (BEG != BEGV || Z != ZV);
int modified_p = !NILP (Fbuffer_modified_p (Qnil));
Lisp_Object old_undo = current_buffer->undo_list;
if (NILP (flag))
{
- int pos, stop;
+ EMACS_INT pos, stop;
unsigned char *p;
/* Do this first, so it can use CHAR_TO_BYTE
{
c = STRING_CHAR_AND_LENGTH (p, bytes);
/* Delete all bytes for this 8-bit character but the
- last one, and change the last one to the charcter
+ last one, and change the last one to the character
code. */
bytes--;
del_range_2 (pos, pos, pos + bytes, pos + bytes, 0);
}
else
{
- int pt = PT;
- int pos, stop;
+ EMACS_INT pt = PT;
+ EMACS_INT pos, stop;
unsigned char *p, *pend;
/* Be sure not to have a multibyte sequence striding over the GAP.
while (! CHAR_HEAD_P (*p) && p > BEG_ADDR) p--;
if (LEADING_CODE_P (*p))
{
- int new_gpt = GPT_BYTE - (GPT_ADDR - p);
+ EMACS_INT new_gpt = GPT_BYTE - (GPT_ADDR - p);
move_gap_both (new_gpt, new_gpt);
}
ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG;
{
- int pt_byte = advance_to_char_boundary (PT_BYTE);
- int pt;
+ EMACS_INT pt_byte = advance_to_char_boundary (PT_BYTE);
+ EMACS_INT pt;
if (pt_byte > GPT_BYTE)
pt = chars_in_text (GAP_END_ADDR, pt_byte - GPT_BYTE) + GPT;
int idx = 0;
int len = *len_ptr;
Lisp_Object *vec = *vec_ptr;
- int next = ZV;
- int prev = BEGV;
+ EMACS_INT next = ZV;
+ EMACS_INT prev = BEGV;
int inhibit_storing = 0;
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
XSETMISC (overlay, tail);
for (tail = current_buffer->overlays_after; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
XSETMISC (overlay, tail);
But we still return the total number of overlays. */
static int
-overlays_in (int beg, int end, int extend, Lisp_Object **vec_ptr, int *len_ptr,
- int *next_ptr, int *prev_ptr)
+overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
+ Lisp_Object **vec_ptr, int *len_ptr,
+ EMACS_INT *next_ptr, EMACS_INT *prev_ptr)
{
Lisp_Object overlay, ostart, oend;
struct Lisp_Overlay *tail;
int idx = 0;
int len = *len_ptr;
Lisp_Object *vec = *vec_ptr;
- int next = ZV;
- int prev = BEGV;
+ EMACS_INT next = ZV;
+ EMACS_INT prev = BEGV;
int inhibit_storing = 0;
int end_is_Z = end == Z;
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
XSETMISC (overlay, tail);
for (tail = current_buffer->overlays_after; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
XSETMISC (overlay, tail);
int
mouse_face_overlay_overlaps (Lisp_Object overlay)
{
- int start = OVERLAY_POSITION (OVERLAY_START (overlay));
- int end = OVERLAY_POSITION (OVERLAY_END (overlay));
+ EMACS_INT start = OVERLAY_POSITION (OVERLAY_START (overlay));
+ EMACS_INT end = OVERLAY_POSITION (OVERLAY_END (overlay));
int n, i, size;
Lisp_Object *v, tem;
\f
/* Fast function to just test if we're at an overlay boundary. */
int
-overlay_touches_p (int pos)
+overlay_touches_p (EMACS_INT pos)
{
Lisp_Object overlay;
struct Lisp_Overlay *tail;
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
- int endpos;
+ EMACS_INT endpos;
XSETMISC (overlay ,tail);
if (!OVERLAYP (overlay))
for (tail = current_buffer->overlays_after; tail; tail = tail->next)
{
- int startpos;
+ EMACS_INT startpos;
XSETMISC (overlay, tail);
if (!OVERLAYP (overlay))
struct sortvec
{
Lisp_Object overlay;
- int beg, end;
+ EMACS_INT beg, end;
int priority;
};
struct sortstr *buf; /* An array that expands as needed; never freed. */
int size; /* Allocated length of that array. */
int used; /* How much of the array is currently in use. */
- int bytes; /* Total length of the strings in buf. */
+ EMACS_INT bytes; /* Total length of the strings in buf. */
};
/* Buffers for storing information about the overlays touching a given
static unsigned char *overlay_str_buf;
/* Allocated length of overlay_str_buf. */
-static int overlay_str_len;
+static EMACS_INT overlay_str_len;
/* A comparison function suitable for passing to qsort. */
static int
static void
record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str2, Lisp_Object pri, int size)
{
- int nbytes;
+ EMACS_INT nbytes;
if (ssl->used == ssl->size)
{
PSTR, if that variable is non-null. The string may be overwritten by
subsequent calls. */
-int
+EMACS_INT
overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr)
{
Lisp_Object overlay, window, str;
struct Lisp_Overlay *ov;
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
overlay_heads.used = overlay_heads.bytes = 0;
if (overlay_heads.bytes || overlay_tails.bytes)
{
Lisp_Object tem;
- int i;
+ EMACS_INT i;
unsigned char *p;
- int total = overlay_heads.bytes + overlay_tails.bytes;
+ EMACS_INT total = overlay_heads.bytes + overlay_tails.bytes;
if (total > overlay_str_len)
{
p = overlay_str_buf;
for (i = overlay_tails.used; --i >= 0;)
{
- int nbytes;
+ EMACS_INT nbytes;
tem = overlay_tails.buf[i].string;
nbytes = copy_text (SDATA (tem), p,
SBYTES (tem),
}
for (i = 0; i < overlay_heads.used; ++i)
{
- int nbytes;
+ EMACS_INT nbytes;
tem = overlay_heads.buf[i].string;
nbytes = copy_text (SDATA (tem), p,
SBYTES (tem),
if (OVERLAY_POSITION (end) > pos)
{
/* OVERLAY needs to be moved. */
- int where = OVERLAY_POSITION (beg);
+ EMACS_INT where = OVERLAY_POSITION (beg);
struct Lisp_Overlay *other, *other_prev;
/* Splice the cons cell TAIL out of overlays_before. */
if (OVERLAY_POSITION (end) <= pos)
{
/* OVERLAY needs to be moved. */
- int where = OVERLAY_POSITION (end);
+ EMACS_INT where = OVERLAY_POSITION (end);
struct Lisp_Overlay *other, *other_prev;
/* Splice the cons cell TAIL out of overlays_after. */
Such an overlay might even have negative size at this point.
If so, we'll make the overlay empty. */
void
-fix_start_end_in_overlays (register int start, register int end)
+fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end)
{
Lisp_Object overlay;
struct Lisp_Overlay *before_list, *after_list;
current_buffer->overlays_before or overlays_after, depending
which loop we're in. */
struct Lisp_Overlay *tail, *parent;
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
/* This algorithm shifts links around instead of consing and GCing.
The loop invariant is that before_list (resp. after_list) is a
{
if (start > end)
{
- int temp = start;
+ EMACS_INT temp = start;
start = end;
end = temp;
}
/* Redisplay where the overlay was. */
if (!NILP (obuffer))
{
- int o_beg;
- int o_end;
+ EMACS_INT o_beg;
+ EMACS_INT o_end;
o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
else
/* Redisplay the area the overlay has just left, or just enclosed. */
{
- int o_beg, o_end;
+ EMACS_INT o_beg, o_end;
o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
/* Put all the overlays we want in a vector in overlay_vec.
Store the length in len. */
noverlays = overlays_in (XINT (beg), XINT (end), 1, &overlay_vec, &len,
- (int *) 0, (int *) 0);
+ NULL, NULL);
/* Make a list of them all. */
result = Flist (noverlays, overlay_vec);
last_overlay_modification_hooks_used = 0;
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
Lisp_Object ostart, oend;
XSETMISC (overlay, tail);
for (tail = current_buffer->overlays_after; tail; tail = tail->next)
{
- int startpos, endpos;
+ EMACS_INT startpos, endpos;
Lisp_Object ostart, oend;
XSETMISC (overlay, tail);
if (pos <= current_buffer->overlay_center)
for (tail = current_buffer->overlays_before; tail; tail = tail->next)
{
- int endpos;
+ EMACS_INT endpos;
XSETMISC (overlay, tail);
endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
if (endpos < pos)
else
for (tail = current_buffer->overlays_after; tail; tail = tail->next)
{
- int startpos;
+ EMACS_INT startpos;
XSETMISC (overlay, tail);
startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
if (startpos > pos)
} while (0)
static void
-defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, char *namestring,
+defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
Lisp_Object *address, Lisp_Object type, char *doc)
{
struct Lisp_Symbol *sym;
bo_fwd->type = Lisp_Fwd_Buffer_Obj;
bo_fwd->offset = offset;
bo_fwd->slottype = type;
+ sym->declared_special = 1;
sym->redirect = SYMBOL_FORWARDED;
{
/* I tried to do the job without a cast, but it seems impossible.
staticpro (&Qget_file_buffer);
Qpriority = intern_c_string ("priority");
staticpro (&Qpriority);
- Qwindow = intern_c_string ("window");
- staticpro (&Qwindow);
Qbefore_string = intern_c_string ("before-string");
staticpro (&Qbefore_string);
Qafter_string = intern_c_string ("after-string");
doc: /* Local (mode-specific) abbrev table of current buffer. */);
DEFVAR_PER_BUFFER ("abbrev-mode", ¤t_buffer->abbrev_mode, Qnil,
- doc: /* Non-nil turns on automatic expansion of abbrevs as they are inserted. */);
+ doc: /* Non-nil if Abbrev mode is enabled.
+Use the command `abbrev-mode' to change this variable. */);
DEFVAR_PER_BUFFER ("case-fold-search", ¤t_buffer->case_fold_search,
Qnil,
Buffer changes made while executing the `before-change-functions'
don't call any before-change or after-change functions.
-That's because these variables are temporarily set to nil.
-As a result, a hook function cannot straightforwardly alter the
-value of these variables. See the Emacs Lisp manual for a way of
-accomplishing an equivalent result by using other variables.
+That's because `inhibit-modification-hooks' is temporarily set non-nil.
If an unhandled error happens in running these functions,
the variable's value remains nil. That prevents the error
Buffer changes made while executing the `after-change-functions'
don't call any before-change or after-change functions.
-That's because these variables are temporarily set to nil.
-As a result, a hook function cannot straightforwardly alter the
-value of these variables. See the Emacs Lisp manual for a way of
-accomplishing an equivalent result by using other variables.
+That's because `inhibit-modification-hooks' is temporarily set non-nil.
If an unhandled error happens in running these functions,
the variable's value remains nil. That prevents the error
If the buffer has never been shown in a window, the value is nil. */);
DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode,
- doc: /* */);
+ doc: /* Non-nil if Transient Mark mode is enabled.
+See the command `transient-mark-mode' for a description of this minor mode.
+
+Non-nil also enables highlighting of the region whenever the mark is active.
+The variable `highlight-nonselected-windows' controls whether to highlight
+all windows or just the selected window.
+
+If the value is `lambda', that enables Transient Mark mode temporarily.
+After any subsequent action that would normally deactivate the mark
+\(such as buffer modification), Transient Mark mode is turned off.
+
+If the value is (only . OLDVAL), that enables Transient Mark mode
+temporarily. After any subsequent point motion command that is not
+shift-translated, or any other action that would normally deactivate
+the mark (such as buffer modification), the value of
+`transient-mark-mode' is set to OLDVAL. */);
Vtransient_mark_mode = Qnil;
- /* The docstring is in simple.el. If we put it here, it would be
- overwritten when transient-mark-mode is defined using
- define-minor-mode. */
DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only,
doc: /* *Non-nil means disregard read-only status of buffers or characters.
DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
¤t_buffer->cursor_in_non_selected_windows, Qnil,
- doc: /* *Cursor type to display in non-selected windows.
-The value t means to use hollow box cursor. See `cursor-type' for other values. */);
+ doc: /* *Non-nil means show a cursor in non-selected windows.
+If nil, only shows a cursor in the selected window.
+If t, displays a cursor related to the usual cursor type
+\(a solid box becomes hollow, a bar becomes a narrower bar).
+You can also specify the cursor type as in the `cursor-type' variable.
+Use Custom to set this variable and update the display." */);
DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions,
doc: /* List of functions called with no args to query before killing a buffer.
Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt);
}
-/* arch-tag: e48569bf-69a9-4b65-a23b-8e68769436e1
- (do not change this comment) */