/* Buffer manipulation primitives for GNU Emacs.
- Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001, 2002
+ Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001, 02, 2003
Free Software Foundation, Inc.
This file is part of GNU Emacs.
/* List of functions to call that can query about killing a buffer.
If any of these functions returns nil, we don't kill it. */
Lisp_Object Vkill_buffer_query_functions;
+Lisp_Object Qkill_buffer_query_functions;
/* List of functions to call before changing an unmodified buffer. */
Lisp_Object Vfirst_change_hook;
XSETBUFFER (buf, b);
Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
- /* Fixme: Protect against errors, which would trigger infinite
- regress? */
+ /* An error in calling the function here (should someone redfine it)
+ can lead to infinite regress until you run out of stack. rms
+ says that's not worth protecting against. */
if (!NILP (Ffboundp (Qucs_set_table_for_input)))
- /* buff is on buffer-alist, so no gcpro */
+ /* buf is on buffer-alist, so no gcpro. */
call1 (Qucs_set_table_for_input, buf);
return buf;
We ignore it here. */
b->major_mode = Qfundamental_mode;
b->keymap = Qnil;
- b->abbrev_table = Vfundamental_mode_abbrev_table;
b->mode_name = QSFundamental;
b->minor_modes = Qnil;
/* Run hooks with the buffer to be killed the current buffer. */
{
int count = SPECPDL_INDEX ();
- Lisp_Object list;
+ Lisp_Object arglist[1];
record_unwind_protect (save_excursion_restore, save_excursion_save ());
set_buffer_internal (b);
/* First run the query functions; if any query is answered no,
don't kill the buffer. */
- for (list = Vkill_buffer_query_functions; CONSP (list); list = XCDR (list))
- {
- tem = call0 (XCAR (list));
- if (NILP (tem))
- return unbind_to (count, Qnil);
- }
+ arglist[0] = Qkill_buffer_query_functions;
+ if (NILP (Frun_hook_with_args_until_failure (1, arglist)))
+ return unbind_to (count, Qnil);
/* Then run the hooks. */
Frun_hooks (1, &Qkill_buffer_hook);
Fset_window_buffer (EQ (selected_window, minibuf_window)
? Fnext_window (minibuf_window, Qnil, Qnil)
: selected_window,
- buf);
+ buf, Qnil);
return buf;
}
}
Fset_buffer (buf);
if (NILP (norecord))
- /* This seems bogus since Fselect_window will call record_buffer anyway. */
+ /* Why bother ? Fselect_window will do it for us anyway. -stef */
record_buffer (buf);
- Fselect_window (Fdisplay_buffer (buf, other_window, Qnil));
+ Fselect_window (Fdisplay_buffer (buf, other_window, Qnil), norecord);
return buf;
}
Lisp_Object tail, markers;
struct buffer *other;
int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
- int begv = BEGV, zv = ZV;
- int narrowed = (BEG != begv || Z != zv);
+ int begv, zv;
+ int narrowed = (BEG != BEGV || Z != ZV);
int modified_p = !NILP (Fbuffer_modified_p (Qnil));
if (current_buffer->base_buffer)
/* If the cached position is for this buffer, clear it out. */
clear_charpos_cache (current_buffer);
+ if (NILP (flag))
+ begv = BEGV_BYTE, zv = ZV_BYTE;
+ else
+ begv = BEGV, zv = ZV;
+
if (narrowed)
Fwiden ();
if (!modified_p && !NILP (Fbuffer_modified_p (Qnil)))
Fset_buffer_modified_p (Qnil);
+#ifdef subprocesses
+ /* Update coding systems of this buffer's process (if any). */
+ {
+ Lisp_Object process;
+
+ process = Fget_buffer_process (Fcurrent_buffer ());
+ if (PROCESSP (process))
+ setup_process_coding_systems (process);
+ }
+#endif /* subprocesses */
+
return flag;
}
\f
and we store only as many overlays as will fit.
But we still return the total number of overlays. */
-int
+static int
overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr)
int beg, end;
int extend;
}
DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0,
- doc: /* Recenter the overlays of the current buffer around position POS. */)
+ doc: /* Recenter the overlays of the current buffer around position POS.
+That makes overlay lookup faster for positions near POS (but perhaps slower
+for positions far away from POS). */)
(pos)
Lisp_Object pos;
{
buffer_defaults.cache_long_line_scans = Qnil;
buffer_defaults.file_truename = Qnil;
XSETFASTINT (buffer_defaults.display_count, 0);
+ XSETFASTINT (buffer_defaults.left_margin_cols, 0);
+ XSETFASTINT (buffer_defaults.right_margin_cols, 0);
+ buffer_defaults.left_fringe_width = Qnil;
+ buffer_defaults.right_fringe_width = Qnil;
+ buffer_defaults.fringes_outside_margins = Qnil;
+ buffer_defaults.scroll_bar_width = Qnil;
+ buffer_defaults.vertical_scroll_bar_type = Qt;
buffer_defaults.indicate_empty_lines = Qnil;
buffer_defaults.scroll_up_aggressively = Qnil;
buffer_defaults.scroll_down_aggressively = Qnil;
XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);
/* Make this one a permanent local. */
buffer_permanent_local_flags[idx++] = 1;
- XSETFASTINT (buffer_local_flags.left_margin_width, idx); ++idx;
- XSETFASTINT (buffer_local_flags.right_margin_width, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.left_margin_cols, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.right_margin_cols, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.left_fringe_width, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.right_fringe_width, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.fringes_outside_margins, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.scroll_bar_width, idx); ++idx;
+ XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx;
XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
Qpermanent_local = intern ("permanent-local");
Qkill_buffer_hook = intern ("kill-buffer-hook");
+ Fput (Qkill_buffer_hook, Qpermanent_local, Qt);
Qucs_set_table_for_input = intern ("ucs-set-table-for-input");
staticpro (&Qafter_change_functions);
staticpro (&Qucs_set_table_for_input);
+ Qkill_buffer_query_functions = intern ("kill-buffer-query-functions");
+ staticpro (&Qkill_buffer_query_functions);
+
Fput (Qprotected_field, Qerror_conditions,
Fcons (Qprotected_field, Fcons (Qerror, Qnil)));
Fput (Qprotected_field, Qerror_message,
DEFVAR_LISP_NOPRO ("default-direction-reversed",
&buffer_defaults.direction_reversed,
- doc: /* Default value of `direction_reversed' for buffers that do not override it.
+ doc: /* Default value of `direction-reversed' for buffers that do not override it.
This is the same as (default-value 'direction-reversed). */);
DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters",
#endif
DEFVAR_LISP_NOPRO ("default-left-margin-width",
- &buffer_defaults.left_margin_width,
+ &buffer_defaults.left_margin_cols,
doc: /* Default value of `left-margin-width' for buffers that don't override it.
This is the same as (default-value 'left-margin-width). */);
DEFVAR_LISP_NOPRO ("default-right-margin-width",
- &buffer_defaults.right_margin_width,
- doc: /* Default value of `right_margin_width' for buffers that don't override it.
+ &buffer_defaults.right_margin_cols,
+ doc: /* Default value of `right-margin-width' for buffers that don't override it.
This is the same as (default-value 'right-margin-width). */);
+ DEFVAR_LISP_NOPRO ("default-left-fringe-width",
+ &buffer_defaults.left_fringe_width,
+ doc: /* Default value of `left-fringe-width' for buffers that don't override it.
+This is the same as (default-value 'left-fringe-width). */);
+
+ DEFVAR_LISP_NOPRO ("default-right-fringe-width",
+ &buffer_defaults.right_fringe_width,
+ doc: /* Default value of `right-fringe-width' for buffers that don't override it.
+This is the same as (default-value 'right-fringe-width). */);
+
+ DEFVAR_LISP_NOPRO ("default-fringes-outside-margins",
+ &buffer_defaults.fringes_outside_margins,
+ doc: /* Default value of `fringes-outside-margins' for buffers that don't override it.
+This is the same as (default-value 'fringes-outside-margins). */);
+
+ DEFVAR_LISP_NOPRO ("default-scroll-bar-width",
+ &buffer_defaults.scroll_bar_width,
+ doc: /* Default value of `scroll-bar-width' for buffers that don't override it.
+This is the same as (default-value 'scroll-bar-width). */);
+
+ DEFVAR_LISP_NOPRO ("default-vertical-scroll-bar",
+ &buffer_defaults.vertical_scroll_bar_type,
+ doc: /* Default value of `vertical-scroll-bar' for buffers that don't override it.
+This is the same as (default-value 'vertical-scroll-bar). */);
+
DEFVAR_LISP_NOPRO ("default-indicate-empty-lines",
&buffer_defaults.indicate_empty_lines,
doc: /* Default value of `indicate-empty-lines' for buffers that don't override it.
DEFVAR_PER_BUFFER ("enable-multibyte-characters",
¤t_buffer->enable_multibyte_characters,
- make_number (-1),
+ Qnil,
doc: /* Non-nil means the buffer contents are regarded as multi-byte characters.
Otherwise they are regarded as unibyte. This affects the display,
file I/O and the behavior of various editing commands.
Changing its default value with `setq-default' is supported.
See also variable `default-enable-multibyte-characters' and Info node
`(elisp)Text Representations'. */);
+ XSYMBOL (intern ("enable-multibyte-characters"))->constant = 1;
DEFVAR_PER_BUFFER ("buffer-file-coding-system",
¤t_buffer->buffer_file_coding_system, Qnil,
See also the functions `display-table-slot' and `set-display-table-slot'. */);
- DEFVAR_PER_BUFFER ("left-margin-width", ¤t_buffer->left_margin_width,
+ DEFVAR_PER_BUFFER ("left-margin-width", ¤t_buffer->left_margin_cols,
Qnil,
doc: /* *Width of left marginal area for display of a buffer.
A value of nil means no marginal area. */);
- DEFVAR_PER_BUFFER ("right-margin-width", ¤t_buffer->right_margin_width,
+ DEFVAR_PER_BUFFER ("right-margin-width", ¤t_buffer->right_margin_cols,
Qnil,
doc: /* *Width of right marginal area for display of a buffer.
A value of nil means no marginal area. */);
+ DEFVAR_PER_BUFFER ("left-fringe-width", ¤t_buffer->left_fringe_width,
+ Qnil,
+ doc: /* *Width of this buffer's left fringe (in pixels).
+A value of 0 means no left fringe is shown in this buffer's window.
+A value of nil means to use the left fringe width from the window's frame. */);
+
+ DEFVAR_PER_BUFFER ("right-fringe-width", ¤t_buffer->right_fringe_width,
+ Qnil,
+ doc: /* *Width of this buffer's right fringe (in pixels).
+A value of 0 means no right fringe is shown in this buffer's window.
+A value of nil means to use the right fringe width from the window's frame. */);
+
+ DEFVAR_PER_BUFFER ("fringes-outside-margins", ¤t_buffer->fringes_outside_margins,
+ Qnil,
+ doc: /* *Non-nil means to display fringes outside display margins.
+A value of nil means to display fringes between margins and buffer text. */);
+
+ DEFVAR_PER_BUFFER ("scroll-bar-width", ¤t_buffer->scroll_bar_width,
+ Qnil,
+ doc: /* *Width of this buffer's scroll bars in pixels.
+A value of nil means to use the scroll bar width from the window's frame. */);
+
+ DEFVAR_PER_BUFFER ("vertical-scroll-bar", ¤t_buffer->vertical_scroll_bar_type,
+ Qnil,
+ doc: /* *Position of this buffer's vertical scroll bar.
+A value of left or right means to place the vertical scroll bar at that side
+of the window; a value of nil means that this window has no vertical scroll bar.
+A value of t means to use the vertical scroll bar type from the window's frame. */);
+
DEFVAR_PER_BUFFER ("indicate-empty-lines",
¤t_buffer->indicate_empty_lines, Qnil,
doc: /* *Visually indicate empty lines after the buffer end.
DEFVAR_PER_BUFFER ("buffer-file-format", ¤t_buffer->file_format, Qnil,
doc: /* List of formats to use when saving this buffer.
Formats are defined by `format-alist'. This variable is
-set when a file is visited. Automatically local in all buffers. */);
+set when a file is visited. */);
DEFVAR_PER_BUFFER ("buffer-invisibility-spec",
¤t_buffer->invisibility_spec, Qnil,