emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109976: Convenient macro to check wh


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109976: Convenient macro to check whether the buffer is live.
Date: Tue, 11 Sep 2012 08:22:03 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109976
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-09-11 08:22:03 +0400
message:
  Convenient macro to check whether the buffer is live.
  * buffer.h (BUFFER_LIVE_P): New macro.
  * alloc.c, buffer.c, editfns.c, insdel.c, lread.c, marker.c:
  * minibuf.c, print.c, process.c, window.c, xdisp.c: Use it.
modified:
  src/ChangeLog
  src/alloc.c
  src/buffer.c
  src/buffer.h
  src/editfns.c
  src/insdel.c
  src/lread.c
  src/marker.c
  src/minibuf.c
  src/print.c
  src/process.c
  src/window.c
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-09-11 03:32:41 +0000
+++ b/src/ChangeLog     2012-09-11 04:22:03 +0000
@@ -1,3 +1,10 @@
+2012-09-11  Dmitry Antipov  <address@hidden>
+
+       Convenient macro to check whether the buffer is live.
+       * buffer.h (BUFFER_LIVE_P): New macro.
+       * alloc.c, buffer.c, editfns.c, insdel.c, lread.c, marker.c:
+       * minibuf.c, print.c, process.c, window.c, xdisp.c: Use it.
+
 2012-09-11  YAMAMOTO Mitsuharu  <address@hidden>
 
        * xdisp.c (right_overwritten, right_overwriting): Also handle gstring

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-09-07 07:24:08 +0000
+++ b/src/alloc.c       2012-09-11 04:22:03 +0000
@@ -3682,7 +3682,7 @@
   struct Lisp_Marker *m;
 
   /* No dead buffers here.  */
-  eassert (!NILP (BVAR (buf, name)));
+  eassert (BUFFER_LIVE_P (buf));
 
   /* Every character is at least one byte.  */
   eassert (charpos <= bytepos);

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2012-09-09 21:11:14 +0000
+++ b/src/buffer.c      2012-09-11 04:22:03 +0000
@@ -388,7 +388,7 @@
 Value is nil if OBJECT is not a buffer or if it has been killed.  */)
   (Lisp_Object object)
 {
-  return ((BUFFERP (object) && ! NILP (BVAR (XBUFFER (object), name)))
+  return ((BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)))
          ? Qt : Qnil);
 }
 
@@ -776,7 +776,7 @@
   base_buffer = Fget_buffer (base_buffer);
   if (NILP (base_buffer))
     error ("No such buffer: `%s'", SDATA (tem));
-  if (NILP (BVAR (XBUFFER (base_buffer), name)))
+  if (!BUFFER_LIVE_P (XBUFFER (base_buffer)))
     error ("Base buffer has been killed");
 
   if (SCHARS (name) == 0)
@@ -1553,7 +1553,7 @@
     {
       buf = XCAR (tail);
       if (BUFFERP (buf) && !EQ (buf, buffer)
-         && !NILP (BVAR (XBUFFER (buf), name))
+         && BUFFER_LIVE_P (XBUFFER (buf))
          && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
          /* If the frame has a buffer_predicate, disregard buffers that
             don't fit the predicate.  */
@@ -1573,7 +1573,7 @@
     {
       buf = Fcdr (XCAR (tail));
       if (BUFFERP (buf) && !EQ (buf, buffer)
-         && !NILP (BVAR (XBUFFER (buf), name))
+         && BUFFER_LIVE_P (XBUFFER (buf))
          && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
          /* If the frame has a buffer_predicate, disregard buffers that
             don't fit the predicate.  */
@@ -1615,7 +1615,7 @@
     {
       buf = Fcdr (XCAR (tail));
       if (BUFFERP (buf) && !EQ (buf, buffer)
-         && !NILP (BVAR (XBUFFER (buf), name))
+         && BUFFER_LIVE_P (XBUFFER (buf))
          && (SREF (BVAR (XBUFFER (buf), name), 0) != ' '))
        return buf;
     }
@@ -1734,7 +1734,7 @@
   b = XBUFFER (buffer);
 
   /* Avoid trouble for buffer already dead.  */
-  if (NILP (BVAR (b, name)))
+  if (!BUFFER_LIVE_P (b))
     return Qnil;
 
   /* Query if the buffer is still modified.  */
@@ -1770,7 +1770,7 @@
   }
 
   /* If the hooks have killed the buffer, exit now.  */
-  if (NILP (BVAR (b, name)))
+  if (!BUFFER_LIVE_P (b))
     return Qt;
 
   /* We have no more questions to ask.  Verify that it is valid
@@ -1802,7 +1802,7 @@
       UNGCPRO;
 
       /* Exit if we now have killed the base buffer (Bug#11665).  */
-      if (NILP (BVAR (b, name)))
+      if (!BUFFER_LIVE_P (b))
        return Qt;
     }
 
@@ -1813,7 +1813,7 @@
   replace_buffer_in_windows (buffer);
 
   /* Exit if replacing the buffer in windows has killed our buffer.  */
-  if (NILP (BVAR (b, name)))
+  if (!BUFFER_LIVE_P (b))
     return Qt;
 
   /* Make this buffer not be current.  Exit if it is the sole visible
@@ -1846,7 +1846,7 @@
 
   /* Killing buffer processes may run sentinels which may have killed
      our buffer.  */
-  if (NILP (BVAR (b, name)))
+  if (!BUFFER_LIVE_P (b))
     return Qt;
 
   /* These may run Lisp code and into infinite loops (if someone
@@ -1878,7 +1878,7 @@
     }
 
   /* Deleting an auto-save file could have killed our buffer.  */
-  if (NILP (BVAR (b, name)))
+  if (!BUFFER_LIVE_P (b))
     return Qt;
 
   if (b->base_buffer)
@@ -2047,7 +2047,7 @@
 
   CHECK_BUFFER (buffer);
 
-  if (NILP (BVAR (XBUFFER (buffer), name)))
+  if (!BUFFER_LIVE_P (XBUFFER (buffer)))
     error ("Attempt to set major mode for a dead buffer");
 
   if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
@@ -2183,7 +2183,7 @@
   buffer = Fget_buffer (buffer_or_name);
   if (NILP (buffer))
     nsberror (buffer_or_name);
-  if (NILP (BVAR (XBUFFER (buffer), name)))
+  if (!BUFFER_LIVE_P (XBUFFER (buffer)))
     error ("Selecting deleted buffer");
   set_buffer_internal (XBUFFER (buffer));
   return buffer;
@@ -2194,7 +2194,7 @@
 Lisp_Object
 set_buffer_if_live (Lisp_Object buffer)
 {
-  if (! NILP (BVAR (XBUFFER (buffer), name)))
+  if (BUFFER_LIVE_P (XBUFFER (buffer)))
     set_buffer_internal (XBUFFER (buffer));
   return Qnil;
 }
@@ -2289,7 +2289,7 @@
   CHECK_BUFFER (buffer);
   other_buffer = XBUFFER (buffer);
 
-  if (NILP (BVAR (other_buffer, name)))
+  if (!BUFFER_LIVE_P (other_buffer))
     error ("Cannot swap a dead buffer's text");
 
   /* Actually, it probably works just fine.
@@ -2685,7 +2685,7 @@
   /* Copy this buffer's new multibyte status
      into all of its indirect buffers.  */
   FOR_EACH_BUFFER (other)
-    if (other->base_buffer == current_buffer && !NILP (BVAR (other, name)))
+    if (other->base_buffer == current_buffer && BUFFER_LIVE_P (other))
       {
        BVAR (other, enable_multibyte_characters)
          = BVAR (current_buffer, enable_multibyte_characters);

=== modified file 'src/buffer.h'
--- a/src/buffer.h      2012-09-04 17:34:54 +0000
+++ b/src/buffer.h      2012-09-11 04:22:03 +0000
@@ -959,7 +959,10 @@
   b->INTERNAL_FIELD (width_table) = val;
 }
 
-
+/* Convenient check whether buffer B is live.  */
+
+#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
+
 /* Chain of all buffers, including killed ones.  */
 
 extern struct buffer *all_buffers;

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2012-09-05 17:05:32 +0000
+++ b/src/editfns.c     2012-09-11 04:22:03 +0000
@@ -2613,7 +2613,7 @@
   if (NILP (buf))
     nsberror (buffer);
   bp = XBUFFER (buf);
-  if (NILP (BVAR (bp, name)))
+  if (!BUFFER_LIVE_P (bp))
     error ("Selecting deleted buffer");
 
   if (NILP (start))
@@ -2677,7 +2677,7 @@
       if (NILP (buf1))
        nsberror (buffer1);
       bp1 = XBUFFER (buf1);
-      if (NILP (BVAR (bp1, name)))
+      if (!BUFFER_LIVE_P (bp1))
        error ("Selecting deleted buffer");
     }
 
@@ -2715,7 +2715,7 @@
       if (NILP (buf2))
        nsberror (buffer2);
       bp2 = XBUFFER (buf2);
-      if (NILP (BVAR (bp2, name)))
+      if (!BUFFER_LIVE_P (bp2))
        error ("Selecting deleted buffer");
     }
 

=== modified file 'src/insdel.c'
--- a/src/insdel.c      2012-09-04 17:34:54 +0000
+++ b/src/insdel.c      2012-09-11 04:22:03 +0000
@@ -2107,7 +2107,7 @@
      non-nil, and insertion calls a file handler (e.g. through
      lock_file) which scribbles into a temp file -- cyd  */
   if (!BUFFERP (combine_after_change_buffer)
-      || NILP (BVAR (XBUFFER (combine_after_change_buffer), name)))
+      || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer)))
     {
       combine_after_change_list = Qnil;
       return Qnil;

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-09-09 16:06:33 +0000
+++ b/src/lread.c       2012-09-11 04:22:03 +0000
@@ -1734,7 +1734,7 @@
     {
       ptrdiff_t count1 = SPECPDL_INDEX ();
 
-      if (b != 0 && NILP (BVAR (b, name)))
+      if (b != 0 && !BUFFER_LIVE_P (b))
        error ("Reading from killed buffer");
 
       if (!NILP (start))

=== modified file 'src/marker.c'
--- a/src/marker.c      2012-09-04 17:34:54 +0000
+++ b/src/marker.c      2012-09-11 04:22:03 +0000
@@ -407,7 +407,7 @@
         does not preserve the buffer from being GC'd (it's weak), so
         markers have to be unlinked from their buffer as soon as the buffer
         is killed.  */
-      eassert (!NILP (BVAR (XBUFFER (buf), name)));
+      eassert (BUFFER_LIVE_P (XBUFFER (buf)));
       return buf;
     }
   return Qnil;
@@ -462,13 +462,13 @@
   if (NILP (buffer))
     {
       b = current_buffer;
-      eassert (!NILP (BVAR (b, name)));
+      eassert (BUFFER_LIVE_P (b));
     }
   else
     {
       CHECK_BUFFER (buffer);
       b = XBUFFER (buffer);
-      if (NILP (BVAR (b, name)))
+      if (!BUFFER_LIVE_P (b))
        b = NULL;
     }
   return b;
@@ -595,7 +595,7 @@
       register struct Lisp_Marker *tail, **prev;
 
       /* No dead buffers here.  */
-      eassert (!NILP (BVAR (b, name)));
+      eassert (BUFFER_LIVE_P (b));
 
       marker->buffer = NULL;
       prev = &BUF_MARKERS (b);

=== modified file 'src/minibuf.c'
--- a/src/minibuf.c     2012-09-04 17:34:54 +0000
+++ b/src/minibuf.c     2012-09-11 04:22:03 +0000
@@ -798,7 +798,7 @@
       Vminibuffer_list = nconc2 (Vminibuffer_list, tail);
     }
   buf = Fcar (tail);
-  if (NILP (buf) || NILP (BVAR (XBUFFER (buf), name)))
+  if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf)))
     {
       buf = Fget_buffer_create
        (make_formatted_string (name, " *Minibuf-%"pI"d*", depth));

=== modified file 'src/print.c'
--- a/src/print.c       2012-09-09 16:06:33 +0000
+++ b/src/print.c       2012-09-11 04:22:03 +0000
@@ -1873,7 +1873,7 @@
        }
       else if (BUFFERP (obj))
        {
-         if (NILP (BVAR (XBUFFER (obj), name)))
+         if (!BUFFER_LIVE_P (XBUFFER (obj)))
            strout ("#<killed buffer>", -1, -1, printcharfun);
          else if (escapeflag)
            {

=== modified file 'src/process.c'
--- a/src/process.c     2012-09-07 01:27:44 +0000
+++ b/src/process.c     2012-09-11 04:22:03 +0000
@@ -5298,7 +5298,7 @@
     }
 
   /* If no filter, write into buffer if it isn't dead.  */
-  else if (!NILP (p->buffer) && !NILP (BVAR (XBUFFER (p->buffer), name)))
+  else if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
     {
       Lisp_Object old_read_only;
       ptrdiff_t old_begv, old_zv;
@@ -6722,7 +6722,7 @@
 
              /* Avoid error if buffer is deleted
                 (probably that's why the process is dead, too) */
-             if (NILP (BVAR (XBUFFER (buffer), name)))
+             if (!BUFFER_LIVE_P (XBUFFER (buffer)))
                continue;
              Fset_buffer (buffer);
 

=== modified file 'src/window.c'
--- a/src/window.c      2012-09-05 07:18:46 +0000
+++ b/src/window.c      2012-09-11 04:22:03 +0000
@@ -2668,7 +2668,7 @@
            /* Check for a window that has a killed buffer.  */
          case CHECK_ALL_WINDOWS:
            if (! NILP (w->buffer)
-               && NILP (BVAR (XBUFFER (w->buffer), name)))
+               && !BUFFER_LIVE_P (XBUFFER (w->buffer)))
              emacs_abort ();
            break;
 
@@ -3273,7 +3273,7 @@
   XSETWINDOW (window, w);
   buffer = Fget_buffer (buffer_or_name);
   CHECK_BUFFER (buffer);
-  if (NILP (BVAR (XBUFFER (buffer), name)))
+  if (!BUFFER_LIVE_P (XBUFFER (buffer)))
     error ("Attempt to display deleted buffer");
 
   tem = w->buffer;
@@ -3338,7 +3338,7 @@
 
   if (STRINGP (object))
     object = Fget_buffer (object);
-  if (BUFFERP (object) && !NILP (BVAR (XBUFFER (object), name)))
+  if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)))
     {
       /* Walk all windows looking for buffer, and force update
         of each of those windows.  */
@@ -5549,7 +5549,7 @@
   saved_windows = XVECTOR (data->saved_windows);
 
   new_current_buffer = data->current_buffer;
-  if (NILP (BVAR (XBUFFER (new_current_buffer), name)))
+  if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer)))
     new_current_buffer = Qnil;
   else
     {
@@ -5624,7 +5624,7 @@
          w = XWINDOW (window);
          if (!NILP (w->buffer)
              && !EQ (w->buffer, p->buffer)
-             && !NILP (BVAR (XBUFFER (p->buffer), name)))
+             && BUFFER_LIVE_P (XBUFFER (p->buffer)))
            /* If a window we restore gets another buffer, record the
               window's old buffer.  */
            call1 (Qrecord_window_buffer, window);
@@ -5774,7 +5774,7 @@
          if (NILP (p->buffer))
            /* An internal window.  */
            wset_buffer (w, p->buffer);
-         else if (!NILP (BVAR (XBUFFER (p->buffer), name)))
+         else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
            /* If saved buffer is alive, install it.  */
            {
              wset_buffer (w, p->buffer);
@@ -5793,7 +5793,7 @@
                Fgoto_char (w->pointm);
             }
           else if (!NILP (w->buffer)
-                   && !NILP (BVAR (XBUFFER (w->buffer), name)))
+                   && BUFFER_LIVE_P (XBUFFER (w->buffer)))
             /* Keep window's old buffer; make sure the markers are
                real.  */
             {

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-09-11 03:32:41 +0000
+++ b/src/xdisp.c       2012-09-11 04:22:03 +0000
@@ -3667,7 +3667,7 @@
        }
       /* There isn't much we can reasonably do to protect against
         misbehaving fontification, but here's a fig leaf.  */
-      else if (!NILP (BVAR (obuf, name)))
+      else if (BUFFER_LIVE_P (obuf))
        set_buffer_internal_1 (obuf);
 
       /* The fontification code may have added/removed text.
@@ -9910,7 +9910,7 @@
 
   for (i = 0; i < 2; ++i)
     if (!BUFFERP (echo_buffer[i])
-       || NILP (BVAR (XBUFFER (echo_buffer[i]), name)))
+       || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i])))
       {
        char name[30];
        Lisp_Object old_buffer;


reply via email to

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