diff options
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/src/buffer.c b/src/buffer.c index 80c799e719b..7e4c84911bb 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -292,6 +292,11 @@ bset_major_mode (struct buffer *b, Lisp_Object val) b->major_mode_ = val; } static void +bset_local_minor_modes (struct buffer *b, Lisp_Object val) +{ + b->local_minor_modes_ = val; +} +static void bset_mark (struct buffer *b, Lisp_Object val) { b->mark_ = val; @@ -776,15 +781,22 @@ fetch_buffer_markers (struct buffer *b) DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, - 2, 3, + 2, 4, "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, named NAME. BASE-BUFFER should be a live buffer, or the name of an existing buffer. + NAME should be a string which is not the name of an existing buffer. Optional argument CLONE non-nil means preserve BASE-BUFFER's state, such as major and minor modes, in the indirect buffer. -CLONE nil means the indirect buffer's state is reset to default values. */) - (Lisp_Object base_buffer, Lisp_Object name, Lisp_Object clone) + +CLONE nil means the indirect buffer's state is reset to default values. + +If optional argument INHIBIT-BUFFER-HOOKS is non-nil, the new buffer +does not run the hooks `kill-buffer-hook', +`kill-buffer-query-functions', and `buffer-list-update-hook'. */) + (Lisp_Object base_buffer, Lisp_Object name, Lisp_Object clone, + Lisp_Object inhibit_buffer_hooks) { Lisp_Object buf, tem; struct buffer *b; @@ -829,6 +841,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) b->pt_byte = b->base_buffer->pt_byte; b->begv_byte = b->base_buffer->begv_byte; b->zv_byte = b->base_buffer->zv_byte; + b->inhibit_buffer_hooks = !NILP (inhibit_buffer_hooks); b->newline_cache = 0; b->width_run_cache = 0; @@ -893,6 +906,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) bset_file_truename (b, Qnil); bset_display_count (b, make_fixnum (0)); bset_backed_up (b, Qnil); + bset_local_minor_modes (b, Qnil); bset_auto_save_file_name (b, Qnil); set_buffer_internal_1 (b); Fset (intern ("buffer-save-without-query"), Qnil); @@ -967,6 +981,7 @@ reset_buffer (register struct buffer *b) b->clip_changed = 0; b->prevent_redisplay_optimizations_p = 1; bset_backed_up (b, Qnil); + bset_local_minor_modes (b, Qnil); BUF_AUTOSAVE_MODIFF (b) = 0; b->auto_save_failure_time = 0; bset_auto_save_file_name (b, Qnil); @@ -1069,12 +1084,12 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) for (newlist = Qnil; CONSP (list); list = XCDR (list)) { Lisp_Object elt = XCAR (list); - /* Preserve element ELT if it's t, - if it is a function with a `permanent-local-hook' property, - or if it's not a symbol. */ - if (! SYMBOLP (elt) - || EQ (elt, Qt) - || !NILP (Fget (elt, Qpermanent_local_hook))) + /* Preserve element ELT if it's t, or if it is a + function with a `permanent-local-hook' + property. */ + if (EQ (elt, Qt) + || (SYMBOLP (elt) + && !NILP (Fget (elt, Qpermanent_local_hook)))) newlist = Fcons (elt, newlist); } newlist = Fnreverse (newlist); @@ -1442,9 +1457,9 @@ state of the current buffer. Use with care. */) { bool already = SAVE_MODIFF < MODIFF; if (!already && !NILP (flag)) - lock_file (fn); + Flock_file (fn); else if (already && NILP (flag)) - unlock_file (fn); + Funlock_file (fn); } } @@ -1750,7 +1765,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) if (thread_check_current_buffer (b)) return Qnil; - /* Run hooks with the buffer to be killed the current buffer. */ + /* Run hooks with the buffer to be killed as the current buffer. */ { ptrdiff_t count = SPECPDL_INDEX (); @@ -1935,8 +1950,8 @@ cleaning up all windows currently displaying the buffer to be killed. */) } /* Since we've unlinked the markers, the overlays can't be here any more either. */ - b->overlays_before = NULL; - b->overlays_after = NULL; + set_buffer_overlays_before (b, NULL); + set_buffer_overlays_after (b, NULL); /* Reset the local variables, so that this buffer's local values won't be protected from GC. They would be protected @@ -2412,6 +2427,7 @@ results, see Info node `(elisp)Swapping Text'. */) swapfield (overlay_center, ptrdiff_t); swapfield_ (undo_list, Lisp_Object); swapfield_ (mark, Lisp_Object); + swapfield_ (mark_active, Lisp_Object); /* Belongs with the `mark'. */ swapfield_ (enable_multibyte_characters, Lisp_Object); swapfield_ (bidi_display_reordering, Lisp_Object); swapfield_ (bidi_paragraph_direction, Lisp_Object); @@ -2979,7 +2995,7 @@ overlays_in (EMACS_INT beg, EMACS_INT end, bool extend, ptrdiff_t next = ZV; ptrdiff_t prev = BEGV; bool inhibit_storing = 0; - bool end_is_Z = end == Z; + bool end_is_Z = end == ZV; for (struct Lisp_Overlay *tail = current_buffer->overlays_before; tail; tail = tail->next) @@ -4206,7 +4222,11 @@ OVERLAY. */) DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0, doc: /* Return a list of the overlays that contain the character at POS. -If SORTED is non-nil, then sort them by decreasing priority. */) +If SORTED is non-nil, then sort them by decreasing priority. + +Zero-length overlays that start and stop at POS are not included in +the return value. Instead use `overlays-in' if those overlays are of +interest. */) (Lisp_Object pos, Lisp_Object sorted) { ptrdiff_t len, noverlays; @@ -4248,9 +4268,10 @@ DEFUN ("overlays-in", Foverlays_in, Soverlays_in, 2, 2, 0, doc: /* Return a list of the overlays that overlap the region BEG ... END. Overlap means that at least one character is contained within the overlay and also contained within the specified region. + Empty overlays are included in the result if they are located at BEG, between BEG and END, or at END provided END denotes the position at the -end of the buffer. */) +end of the accessible part of the buffer. */) (Lisp_Object beg, Lisp_Object end) { ptrdiff_t len, noverlays; @@ -5151,6 +5172,7 @@ init_buffer_once (void) bset_auto_save_file_name (&buffer_local_flags, make_fixnum (-1)); bset_read_only (&buffer_local_flags, make_fixnum (-1)); bset_major_mode (&buffer_local_flags, make_fixnum (-1)); + bset_local_minor_modes (&buffer_local_flags, make_fixnum (-1)); bset_mode_name (&buffer_local_flags, make_fixnum (-1)); bset_undo_list (&buffer_local_flags, make_fixnum (-1)); bset_mark_active (&buffer_local_flags, make_fixnum (-1)); @@ -5381,17 +5403,24 @@ init_buffer (void) recorded by temacs, that cannot be used by the dumped Emacs. We map new memory for their text here. - Implementation note: the buffers we carry from temacs are: + Implementation notes: the buffers we carry from temacs are: " prin1", "*scratch*", " *Minibuf-0*", "*Messages*", and " *code-conversion-work*". They are created by init_buffer_once and init_window_once (which are not called - in the dumped Emacs), and by the first call to coding.c routines. */ + in the dumped Emacs), and by the first call to coding.c + routines. Since FOR_EACH_LIVE_BUFFER only walks the buffers + in Vbuffer_alist, any buffer we carry from temacs that is + not in the alist (a.k.a. "magic invisible buffers") should + be handled here explicitly. */ FOR_EACH_LIVE_BUFFER (tail, buffer) { struct buffer *b = XBUFFER (buffer); b->text->beg = NULL; enlarge_buffer_text (b, 0); } + /* The " prin1" buffer is not in Vbuffer_alist. */ + XBUFFER (Vprin1_to_string_buffer)->text->beg = NULL; + enlarge_buffer_text (XBUFFER (Vprin1_to_string_buffer), 0); } #endif /* USE_MMAP_FOR_BUFFERS */ @@ -5617,6 +5646,12 @@ 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". */); + DEFVAR_PER_BUFFER ("local-minor-modes", + &BVAR (current_buffer, local_minor_modes), + Qnil, + doc: /* Minor modes currently active in the current buffer. +This is a list of symbols, or nil if there are no minor modes active. */); + DEFVAR_PER_BUFFER ("mode-name", &BVAR (current_buffer, mode_name), Qnil, doc: /* Pretty name of current buffer's major mode. @@ -5651,15 +5686,18 @@ Linefeed indents to this column in Fundamental mode. */); DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), Qintegerp, doc: /* Distance between tab stops (for display of tab characters), in columns. -NOTE: This controls the display width of a TAB character, and not -the size of an indentation step. -This should be an integer greater than zero. */); +This controls the width of a TAB character on display. +The value should be a positive integer. +Note that this variable doesn't necessarily affect the size of the +indentation step. However, if the major mode's indentation facility +inserts one or more TAB characters, this variable will affect the +indentation step as well, even if `indent-tabs-mode' is non-nil. */); DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR (current_buffer, ctl_arrow), Qnil, - doc: /* Non-nil means display control chars with uparrow. -A value of nil means use backslash and octal digits. -This variable does not apply to characters whose display is specified -in the current display table (if there is one). */); + doc: /* Non-nil means display control chars with uparrow `^'. +A value of nil means use backslash `\\' and octal digits. +This variable does not apply to characters whose display is specified in +the current display table (if there is one; see `standard-display-table'). */); DEFVAR_PER_BUFFER ("enable-multibyte-characters", &BVAR (current_buffer, enable_multibyte_characters), |