/* Buffer manipulation primitives for GNU Emacs.
-Copyright (C) 1985-1989, 1993-1995, 1997-2015 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1995, 1997-2016 Free Software Foundation,
Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "blockinput.h"
#include "keymap.h"
#include "frame.h"
+#include "xwidget.h"
#ifdef WINDOWSNT
#include "w32heap.h" /* for mmap_* */
doc: /* Return a string that is the name of no existing buffer based on NAME.
If there is no live buffer named NAME, then return NAME.
Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
-(starting at 2) until an unused name is found, and then return that name.
+\(starting at 2) until an unused name is found, and then return that name.
Optional second argument IGNORE specifies a name that is okay to use (if
it is in the sequence to be tried) even if a buffer with that name exists.
}
}
-/* Set the global update_mode_lines variable non-zero if the buffer
- was displayed in some window. This is needed to catch the
- attention of redisplay to changes that might require redisplay of
- the frame title (which uses the same variables as mode lines) when
- the buffer object cannot be used for recording that fact, e.g. if
- the buffer is killed. */
-static void
-set_update_modelines_for_buf (bool disp)
-{
- if (disp)
- update_mode_lines = 42;
-}
-
DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
doc: /* Kill the buffer specified by BUFFER-OR-NAME.
The argument may be a buffer or the name of an existing buffer.
struct buffer *b;
Lisp_Object tem;
struct Lisp_Marker *m;
- bool buffer_was_displayed = false;
if (NILP (buffer_or_name))
buffer = Fcurrent_buffer ();
if (!BUFFER_LIVE_P (b))
return Qnil;
- buffer_was_displayed = buffer_window_count (b);
-
/* Run hooks with the buffer to be killed the current buffer. */
{
ptrdiff_t count = SPECPDL_INDEX ();
/* If the hooks have killed the buffer, exit now. */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return unbind_to (count, Qt);
- }
+ return unbind_to (count, Qt);
/* Then run the hooks. */
run_hook (Qkill_buffer_hook);
/* If the hooks have killed the buffer, exit now. */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return Qt;
- }
+ return Qt;
/* We have no more questions to ask. Verify that it is valid
to kill the buffer. This must be done after the questions
/* Exit if we now have killed the base buffer (Bug#11665). */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return Qt;
- }
+ return Qt;
}
/* Run replace_buffer_in_windows before making another buffer current
/* Exit if replacing the buffer in windows has killed our buffer. */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return Qt;
- }
+ return Qt;
/* Make this buffer not be current. Exit if it is the sole visible
buffer. */
unlock_buffer (b);
kill_buffer_processes (buffer);
+ kill_buffer_xwidgets (buffer);
/* Killing buffer processes may run sentinels which may have killed
our buffer. */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return Qt;
- }
+ return Qt;
/* These may run Lisp code and into infinite loops (if someone
insisted on circular lists) so allow quitting here. */
/* Deleting an auto-save file could have killed our buffer. */
if (!BUFFER_LIVE_P (b))
- {
- set_update_modelines_for_buf (buffer_was_displayed);
- return Qt;
- }
+ return Qt;
if (b->base_buffer)
{
if (!NILP (Vrun_hooks))
call1 (Vrun_hooks, Qbuffer_list_update_hook);
- set_update_modelines_for_buf (buffer_was_displayed);
return Qt;
}
\f
doc: /* Signal a `buffer-read-only' error if the current buffer is read-only.
If the text under POSITION (which defaults to point) has the
`inhibit-read-only' text property set, the error will not be raised. */)
- (Lisp_Object pos)
+ (Lisp_Object position)
{
- if (NILP (pos))
- XSETFASTINT (pos, PT);
+ if (NILP (position))
+ XSETFASTINT (position, PT);
else
- CHECK_NUMBER (pos);
+ CHECK_NUMBER (position);
if (!NILP (BVAR (current_buffer, read_only))
&& NILP (Vinhibit_read_only)
- && NILP (Fget_text_property (pos, Qinhibit_read_only, Qnil)))
+ && NILP (Fget_text_property (position, Qinhibit_read_only, Qnil)))
xsignal1 (Qbuffer_read_only, Fcurrent_buffer ());
return Qnil;
}
else
nbytes = SBYTES (str);
- if (INT_ADD_OVERFLOW (ssl->bytes, nbytes))
+ if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes))
memory_full (SIZE_MAX);
- ssl->bytes += nbytes;
+ ssl->bytes = nbytes;
if (STRINGP (str2))
{
else
nbytes = SBYTES (str2);
- if (INT_ADD_OVERFLOW (ssl->bytes, nbytes))
+ if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes))
memory_full (SIZE_MAX);
- ssl->bytes += nbytes;
+ ssl->bytes = nbytes;
}
}
unsigned char *p;
ptrdiff_t total;
- if (INT_ADD_OVERFLOW (overlay_heads.bytes, overlay_tails.bytes))
+ if (INT_ADD_WRAPV (overlay_heads.bytes, overlay_tails.bytes, &total))
memory_full (SIZE_MAX);
- total = overlay_heads.bytes + overlay_tails.bytes;
if (total > overlay_str_len)
overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len,
total - overlay_str_len, -1, 1);
BEG and END may be integers or markers.
The fourth arg FRONT-ADVANCE, if non-nil, makes the marker
for the front of the overlay advance when text is inserted there
-(which means the text *is not* included in the overlay).
+\(which means the text *is not* included in the overlay).
The fifth arg REAR-ADVANCE, if non-nil, makes the marker
for the rear of the overlay advance when text is inserted there
-(which means the text *is* included in the overlay). */)
+\(which means the text *is* included in the overlay). */)
(Lisp_Object beg, Lisp_Object end, Lisp_Object buffer,
Lisp_Object front_advance, Lisp_Object rear_advance)
{
Lisp_Object *copy;
ptrdiff_t i;
+ if (size)
+ {
+ Lisp_Object ovl
+ = XVECTOR (last_overlay_modification_hooks)->contents[1];
+
+ /* If the buffer of the first overlay in the array doesn't
+ match the current buffer, then these modification hooks
+ should not be run in this buffer. This could happen when
+ some code calls some insdel functions, such as del_range_1,
+ with the PREPARE argument false -- in that case this
+ function is never called to record the overlay modification
+ hook functions in the last_overlay_modification_hooks
+ array, so anything we find there is not ours. */
+ if (XMARKER (OVERLAY_START (ovl))->buffer != current_buffer)
+ return;
+ }
+
USE_SAFE_ALLOCA;
SAFE_ALLOCA_LISP (copy, size);
memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
doc: /* Symbol for current buffer's major mode.
The default value (normally `fundamental-mode') affects new buffers.
A value of nil means to use the current buffer's major mode, provided
-it is not marked as "special".
-
-When a mode is used by default, `find-file' switches to it before it
-reads the contents into the buffer and before it finishes setting up
-the buffer. Thus, the mode and its hooks should not expect certain
-variables such as `buffer-read-only' and `buffer-file-coding-system'
-to be set up. */);
+it is not marked as "special". */);
DEFVAR_PER_BUFFER ("mode-name", &BVAR (current_buffer, mode_name),
Qnil,
DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory),
Qstringp,
- doc: /* Name of default directory of current buffer. Should end with slash.
+ doc: /* Name of default directory of current buffer.
To interactively change the default directory, use command `cd'. */);
DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function),
DEFVAR_PER_BUFFER ("selective-display", &BVAR (current_buffer, selective_display),
Qnil,
doc: /* Non-nil enables selective display.
+
An integer N as value means display only lines
that start with less than N columns of space.
+
A value of t means that the character ^M makes itself and
all the rest of the line invisible; also, when saving the buffer
-in a file, save the ^M as a newline. */);
+in a file, save the ^M as a newline. This usage is obsolete; use
+overlays or text properties instead. */);
DEFVAR_PER_BUFFER ("selective-display-ellipses",
&BVAR (current_buffer, selective_display_ellipses),
doc: /* List of functions to call before each text change.
Two arguments are passed to each function: the positions of
the beginning and end of the range of old text to be changed.
-(For an insertion, the beginning and end are at the same place.)
+\(For an insertion, the beginning and end are at the same place.)
No information is given about the length of the text after the change.
Buffer changes made while executing the `before-change-functions'
Three arguments are passed to each function: the positions of
the beginning and end of the range of changed text,
and the length in chars of the pre-change text replaced by that range.
-(For an insertion, the pre-change length is zero;
+\(For an insertion, the pre-change length is zero;
for a deletion, that length is the number of chars deleted,
and the post-change beginning and end are at the same place.)
and VALUE is the old value.
An entry (apply FUN-NAME . ARGS) means undo the change with
-(apply FUN-NAME ARGS).
+\(apply FUN-NAME ARGS).
An entry (apply DELTA BEG END FUN-NAME . ARGS) supports selective undo
in the active region. BEG and END is the range affected by this entry
Lisp programs may give this variable certain special values:
-- A value of `lambda' enables Transient Mark mode temporarily.
- It is disabled again after any subsequent action that would
+- The symbol `lambda' enables Transient Mark mode temporarily.
+ The mode is disabled again after any subsequent action that would
normally deactivate the mark (e.g. buffer modification).
-- A value of (only . OLDVAL) enables Transient Mark mode
+- The pair (only . OLDVAL) 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 (e.g. buffer modification), the value of
(hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT
ANYTHING ELSE display a hollow box cursor
+WIDTH and HEIGHT can't exceed the frame's canonical character size.
+
When the buffer is displayed in a non-selected window, the
cursor's appearance is instead controlled by the variable
`cursor-in-non-selected-windows'. */);
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).
+\(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. */);