all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality
Date: Tue, 22 Mar 2016 08:08:22 -0400	[thread overview]
Message-ID: <jwvoaa6u36j.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <E1aiC0q-0004DL-40@vcs.savannah.gnu.org> (Vitalie Spinu's message of "Tue, 22 Mar 2016 02:25:40 +0000")

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 <spinuvit@gmail.com> writes:

> branch: widen-limits
> commit c331b6626a427fb89303fea75faebd8c39d343a8
> Author: Vitalie Spinu <spinuvit@gmail.com>
> Commit: Vitalie Spinu <spinuvit@gmail.com>

>     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);
>  }
> +
>  \f
>  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
> Emacs-diffs@gnu.org
> https://lists.gnu.org/mailman/listinfo/emacs-diffs



       reply	other threads:[~2016-03-22 12:08 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160322022539.16038.77264@vcs.savannah.gnu.org>
     [not found] ` <E1aiC0q-0004DL-40@vcs.savannah.gnu.org>
2016-03-22 12:08   ` Stefan Monnier [this message]
2016-03-22 19:44     ` [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality Vitalie Spinu
2016-03-22 19:56       ` Drew Adams
2016-03-22 22:42         ` Vitalie Spinu
2016-03-23  0:44           ` Drew Adams
2016-03-23  7:16             ` Andreas Röhler
2016-03-23 11:58               ` Vitalie Spinu
2016-03-23 13:02                 ` Andreas Röhler
2016-03-23 14:17                   ` Vitalie Spinu
2016-03-23 15:34                     ` Eli Zaretskii
2016-03-23 17:24                       ` Andreas Röhler
2016-03-23 17:55                         ` Eli Zaretskii
2016-03-23 18:53                           ` Andreas Röhler
2016-03-23 21:57                             ` Drew Adams
2016-03-23 22:13                               ` Vitalie Spinu
2016-03-23 23:03                                 ` Drew Adams
2016-03-24  3:38                                 ` Eli Zaretskii
2016-03-24 12:24                                   ` Dmitry Gutov
2016-03-24 15:56                                     ` Eli Zaretskii
2016-03-24 18:55                                       ` Removing prog-indentation-context (was: [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality) Stefan Monnier
2016-03-25  0:53                                         ` Removing prog-indentation-context Dmitry Gutov
2016-03-25  1:29                                           ` Dmitry Gutov
2016-03-25  2:09                                           ` Stefan Monnier
2016-03-25 11:38                                             ` Dmitry Gutov
2016-03-26 22:29                                               ` John Wiegley
2016-03-28  1:03                                                 ` Dmitry Gutov
2016-03-25 15:45                                           ` Vitalie Spinu
2016-03-28 21:37                                             ` Dmitry Gutov
2016-03-28 22:08                                               ` Stefan Monnier
2016-03-28 22:55                                                 ` Dmitry Gutov
2016-03-28 23:24                                                   ` Stefan Monnier
2016-03-28  1:03                                       ` [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality Dmitry Gutov
2016-03-24  3:37                               ` Eli Zaretskii
2016-03-23 17:14                     ` Andreas Röhler
2016-03-24  0:03                       ` Vitalie Spinu
2016-03-24  0:37                         ` Drew Adams
2016-03-24  2:36                           ` Vitalie Spinu
2016-03-24 13:53                             ` Drew Adams
2016-03-24 13:57                               ` Dmitry Gutov
2016-03-24 14:31                                 ` Drew Adams
2016-03-24 14:56                                   ` Stefan Monnier
2016-03-24 15:13                                     ` Drew Adams
2016-03-24 15:20                                       ` Stefan Monnier
2016-03-24  7:00                         ` Andreas Röhler
2016-03-23 14:29                 ` Drew Adams
2016-03-23 21:16                 ` A vision for multiple major modes [was: Re: [Emacs-diffs] widen-limits c331b66:] Alan Mackenzie
2016-03-23 21:58                   ` Vitalie Spinu
2016-03-24 17:44                     ` Alan Mackenzie
2016-03-24 20:43                       ` Vitalie Spinu
2016-03-23 22:34                   ` Dmitry Gutov
2016-03-24 18:38                     ` Alan Mackenzie
2016-03-24 20:22                       ` Vitalie Spinu
2016-03-25  0:11                       ` Dmitry Gutov
2016-03-27 12:09                         ` Alan Mackenzie
2016-03-27 22:59                           ` Dmitry Gutov
2016-03-29  0:07                             ` Alan Mackenzie
2016-04-01  1:15                               ` Dmitry Gutov
2016-04-05 16:29                                 ` Alan Mackenzie
2016-04-05 22:52                                   ` Dmitry Gutov
2016-04-18 21:32                                     ` Alan Mackenzie
2016-03-28 13:00                       ` Filipp Gunbin
2016-03-25 18:20                   ` Phillip Lord
     [not found] <<20160322022539.16038.77264@vcs.savannah.gnu.org>
     [not found] ` <<E1aiC0q-0004DL-40@vcs.savannah.gnu.org>
     [not found]   ` <<jwvoaa6u36j.fsf-monnier+emacsdiffs@gnu.org>
     [not found]     ` <<8737riqouj.fsf@gmail.com>
     [not found]       ` <<221845e0-b194-433e-bfbc-105272ae5752@default>
     [not found]         ` <<87twjyp21k.fsf@gmail.com>
     [not found]           ` <<a15ff45f-aef0-4e89-b428-dd1d58a85960@default>
     [not found]             ` <<56F242E0.7060004@online.de>
     [not found]               ` <<877fgtpfrw.fsf@gmail.com>
     [not found]                 ` <<56F293E7.2000703@online.de>
     [not found]                   ` <<87a8lpnusg.fsf@gmail.com>
     [not found]                     ` <<83r3f12oo5.fsf@gnu.org>
     [not found]                       ` <<56F2D156.9040401@online.de>
     [not found]                         ` <<83k2kt2i51.fsf@gnu.org>
     [not found]                           ` <<56F2E643.4060903@online.de>
     [not found]                             ` <<592bbafa-76ae-49d9-b5cd-644b3619a0d8@default>
     [not found]                               ` <<838u1835si.fsf@gnu.org>
2016-03-24 14:41                                 ` [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality Drew Adams
2016-03-24 16:12                                   ` Eli Zaretskii
     [not found]                                   ` <<83zitn26t0.fsf@gnu.org>
2016-03-24 16:24                                     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvoaa6u36j.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=spinuvit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.