emacs-diffs
[Top][All Lists]
Advanced

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

feature/improved-locked-narrowing e41e9740fb: Fix user narrowing handlin


From: Gregory Heytings
Subject: feature/improved-locked-narrowing e41e9740fb: Fix user narrowing handling.
Date: Sat, 20 Aug 2022 18:56:26 -0400 (EDT)

branch: feature/improved-locked-narrowing
commit e41e9740fb7cfb775f8f1ddff6b6a66ceafc9ab0
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    Fix user narrowing handling.
    
    * src/editfns.c (syms_of_editfns): New 'outermost-narrowing' internal
    variable.
    (Fwiden, Fnarrow_to_region): Set and reset the variable.
    (Fnarrowing_lock): Use it.
---
 src/editfns.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 6987c44f98..f52db223e4 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2692,6 +2692,8 @@ in which case the the restrictions that were current when
 `narrowing-lock' was called are restored.  */)
   (void)
 {
+  Fset (Qoutermost_narrowing, Qnil);
+
   if (NILP (Vnarrowing_locks))
     {
       if (BEG != BEGV || Z != ZV)
@@ -2708,6 +2710,8 @@ in which case the the restrictions that were current when
        current_buffer->clip_changed = 1;
       SET_BUF_BEGV (current_buffer, begv);
       SET_BUF_ZV (current_buffer, zv);
+      if (EQ (Fcar (Fcar (Vnarrowing_locks)), Qoutermost_narrowing))
+       Fset (Qnarrowing_locks, Qnil);
     }
   /* Changing the buffer bounds invalidates any recorded current column.  */
   invalidate_current_column ();
@@ -2750,6 +2754,11 @@ restrictions that were current when `narrowing-lock' was 
called.  */)
        args_out_of_range (start, end);
     }
 
+  Fset (Qoutermost_narrowing,
+       Fcons (Fcons (Qoutermost_narrowing,
+                     Fcons (make_fixnum (BEGV), make_fixnum (ZV))),
+              Qnil));
+
   if (BEGV != s || ZV != e)
     current_buffer->clip_changed = 1;
 
@@ -2773,6 +2782,8 @@ used only within the limits of the restrictions that were 
current when
 `narrowing-lock' was called.  */)
   (Lisp_Object tag)
 {
+  if (NILP (Vnarrowing_locks))
+    Fset (Qnarrowing_locks, Voutermost_narrowing);
   Fset (Qnarrowing_locks,
        Fcons (Fcons (tag, Fcons (make_fixnum (BEGV), make_fixnum (ZV))),
               Vnarrowing_locks));
@@ -4624,12 +4635,18 @@ it to be non-nil.  */);
 
   DEFSYM (Qnarrowing_locks, "narrowing-locks");
   DEFVAR_LISP ("narrowing-locks", Vnarrowing_locks,
-              doc: /* Internal use only.
-List of narrowing locks in the current buffer.  */);
+              doc: /* List of narrowing locks in the current buffer.  Internal 
use only.  */);
   Vnarrowing_locks = Qnil;
   Fmake_variable_buffer_local (Qnarrowing_locks);
   Funintern (Qnarrowing_locks, Qnil);
 
+  DEFSYM (Qoutermost_narrowing, "outermost-narrowing");
+  DEFVAR_LISP ("outermost-narrowing", Voutermost_narrowing,
+              doc: /* Outermost narrowing bounds, if any.  Internal use only.  
*/);
+  Voutermost_narrowing = Qnil;
+  Fmake_variable_buffer_local (Qoutermost_narrowing);
+  Funintern (Qoutermost_narrowing, Qnil);
+
   defsubr (&Spropertize);
   defsubr (&Schar_equal);
   defsubr (&Sgoto_char);



reply via email to

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