emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits fu


From: Vitalie Spinu
Subject: Re: [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality
Date: Tue, 22 Mar 2016 20:44:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)

Sure. Fixed. This convention is not mentioned in CONTRIBUTE btw.

  Vitalie

>> On Tue, Mar 22 2016 08:08, Stefan Monnier wrote:

> Hi Vitalie,

> For tentative branches where you don't want to have to follow all the
> coding conventions (especially the convention about formatting and
> content of commit messages), please use branch names of the form "scratch/*".

>         Stefan

>>>>>> "Vitalie" == Vitalie Spinu <address@hidden> writes:

>> branch: widen-limits
>> commit c331b6626a427fb89303fea75faebd8c39d343a8
>> Author: Vitalie Spinu <address@hidden>
>> Commit: Vitalie Spinu <address@hidden>

>>     Implement buffer-widen-limits functionality

>>      `widen` now respects restrictions imposed by new variable
>>      `hard-widen-limits`
>> ---
>>  src/buffer.c  |   19 +++++++++++++++++--
>>  src/buffer.h  |   17 +++++++++++++++++
>>  src/editfns.c |   15 ++++++++++++++-
>>  3 files changed, 48 insertions(+), 3 deletions(-)

>> diff --git a/src/buffer.c b/src/buffer.c
>> index f06d7e0..1b62d3a 100644
>> --- a/src/buffer.c
>> +++ b/src/buffer.c
>> @@ -329,6 +329,11 @@ bset_scroll_up_aggressively (struct buffer *b, 
>> Lisp_Object val)
> b-> scroll_up_aggressively_ = val;
>>  }
>>  static void
>> +bset_widen_limits (struct buffer *b, Lisp_Object val)
>> +{
>> +  b->widen_limits_ = val;
>> +}
>> +static void
>>  bset_selective_display (struct buffer *b, Lisp_Object val)
>>  {
> b-> selective_display_ = val;
>> @@ -847,6 +852,7 @@ CLONE nil means the indirect buffer's state is reset to 
>> default values.  */)
>>        bset_display_count (b, make_number (0));
>>        bset_backed_up (b, Qnil);
>>        bset_auto_save_file_name (b, Qnil);
>> +      bset_widen_limits (b, b->base_buffer->widen_limits_);
>>        set_buffer_internal_1 (b);
>>        Fset (intern ("buffer-save-without-query"), Qnil);
>>        Fset (intern ("buffer-file-number"), Qnil);
>> @@ -961,6 +967,7 @@ reset_buffer_local_variables (struct buffer *b, bool 
>> permanent_too)
>>       things that depend on the major mode.
>>       default-major-mode is handled at a higher level.
>>       We ignore it here.  */
>> +  bset_widen_limits(b, Qnil);
>>    bset_major_mode (b, Qfundamental_mode);
>>    bset_keymap (b, Qnil);
>>    bset_mode_name (b, QSFundamental);
>> @@ -2167,7 +2174,7 @@ so the buffer is truly empty after this.  */)
>>  {
>>    Fwiden ();

>> -  del_range (BEG, Z);
>> +  del_range (BEGWL, ZWL);

> current_buffer-> last_window_start = 1;
>>    /* Prevent warnings, or suspension of auto saving, that would happen
>> @@ -5037,6 +5044,7 @@ init_buffer_once (void)
>>    bset_display_count (&buffer_local_flags, make_number (-1));
>>    bset_display_time (&buffer_local_flags, make_number (-1));
>>    bset_enable_multibyte_characters (&buffer_local_flags, make_number (-1));
>> +  bset_widen_limits (&buffer_local_flags, make_number (-1));

>>    /* These used to be stuck at 0 by default, but now that the all-zero value
>>       means Qnil, we have to initialize them explicitly.  */
>> @@ -5160,6 +5168,7 @@ init_buffer_once (void)
>>    bset_cursor_type (&buffer_defaults, Qt);
>>    bset_extra_line_spacing (&buffer_defaults, Qnil);
>>    bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
>> +  bset_widen_limits (&buffer_defaults, Qnil);

>>    bset_enable_multibyte_characters (&buffer_defaults, Qt);
>>    bset_buffer_file_coding_system (&buffer_defaults, Qnil);
>> @@ -5367,7 +5376,6 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, 
>> const char *namestring,
>>      emacs_abort ();
>>  }

>> -
>>  /* Initialize the buffer routines.  */
>>  void
>>  syms_of_buffer (void)
>> @@ -5796,6 +5804,13 @@ If you set this to -2, that means don't turn off 
>> auto-saving in this buffer
>>  if its text size shrinks.   If you use `buffer-swap-text' on a buffer,
>>  you probably should set this to -2 in that buffer.  */);

>> +  DEFVAR_PER_BUFFER ("buffer-widen-limits", &BVAR (current_buffer, 
>> widen_limits),
>> +                     Qnil,
>> +                     doc: /* When non-nil `widen` will widen to these 
>> limits.
>> +Must be a cons of the form (MIN . MAX) where MIN and MAX are integers
>> +of hard widen limits in this buffer. This is an experimental variable
>> +intended primarily for multi-mode engines.  */);
>> +
>>    DEFVAR_PER_BUFFER ("selective-display", &BVAR (current_buffer, 
>> selective_display),
>>                   Qnil,
>>                   doc: /* Non-nil enables selective display.
>> diff --git a/src/buffer.h b/src/buffer.h
>> index 87b7cee..4075bbf 100644
>> --- a/src/buffer.h
>> +++ b/src/buffer.h
>> @@ -59,6 +59,10 @@ INLINE_HEADER_BEGIN
>>  #define Z (current_buffer->text->z)
>>  #define Z_BYTE (current_buffer->text->z_byte)

>> +/* Positions that take into account widen limits.  */
>> +#define BEGWL (BUF_BEGWL (current_buffer))
>> +#define ZWL (BUF_ZWL(current_buffer))
>> +
>>  /* Macros for the addresses of places in the buffer.  */

>>  /* Address of beginning of buffer.  */
>> @@ -128,6 +132,15 @@ INLINE_HEADER_BEGIN
>>      : NILP (BVAR (buf, begv_marker)) ? buf->begv_byte       \
>>      : marker_byte_position (BVAR (buf, begv_marker)))

>> +/* Hard positions in buffer. */
>> +#define BUF_BEGWL(buf)                                      \
>> +  ((NILP (BVAR (buf, widen_limits))) ?  BUF_BEG (buf)    \
>> +   : XINT( XCAR (BVAR (buf, widen_limits))))
>> +
>> +#define BUF_ZWL(buf)                                        \
>> +  ((NILP (BVAR (buf, widen_limits))) ?  BUF_Z (buf)      \
>> +   : XINT( XCDR (BVAR (buf, widen_limits))))
>> +
>>  /* Position of point in buffer.  */
>>  #define BUF_PT(buf)                                 \
>>     (buf == current_buffer ? PT                              \
>> @@ -150,6 +163,7 @@ INLINE_HEADER_BEGIN
>>      : NILP (BVAR (buf, zv_marker)) ? buf->zv_byte   \
>>      : marker_byte_position (BVAR (buf, zv_marker)))

>> +
>>  /* Position of gap in buffer.  */
>>  #define BUF_GPT(buf) ((buf)->text->gpt)
>>  #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte)
>> @@ -748,6 +762,9 @@ struct buffer
>>       See `cursor-type' for other values.  */
>>    Lisp_Object cursor_in_non_selected_windows_;

>> +  /* Cons of hard widen limits */
>> +  Lisp_Object widen_limits_;
>> +
>>    /* No more Lisp_Object beyond this point.  Except undo_list,
>>       which is handled specially in Fgarbage_collect.  */

>> diff --git a/src/editfns.c b/src/editfns.c
>> index 2ac0537..e5ab637 100644
>> --- a/src/editfns.c
>> +++ b/src/editfns.c
>> @@ -3480,12 +3480,25 @@ DEFUN ("delete-and-extract-region", 
>> Fdelete_and_extract_region,
>>      return empty_unibyte_string;
>>    return del_range_1 (XINT (start), XINT (end), 1, 1);
>>  }
>> +
>>  
>>  DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
>>         doc: /* Remove restrictions (narrowing) from current buffer.
>> -This allows the buffer's full text to be seen and edited.  */)
>> +This allows the buffer's full text to be seen and edited.
>> +If `buffer-widen-limits` is non-nil, widen only to those limits.  */)
>>    (void)
>>  {
>> +
>> +  if (!NILP (BVAR(current_buffer, widen_limits)))
>> +    {
>> +      Lisp_Object hl = BVAR(current_buffer,  widen_limits);
>> +      CHECK_CONS(hl);
>> +      CHECK_NUMBER(XCAR(hl));
>> +      CHECK_NUMBER(XCDR(hl));
>> +      Fnarrow_to_region(XCAR(hl), XCDR(hl));
>> +      return Qnil;
>> +    }
>> +
>>    if (BEG != BEGV || Z != ZV)
> current_buffer-> clip_changed = 1;
>>    BEGV = BEG;

>> _______________________________________________
>> Emacs-diffs mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/emacs-diffs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]