emacs-diffs
[Top][All Lists]
Advanced

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

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


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111142: Convenient macro to check whether the buffer is hidden.
Date: Fri, 07 Dec 2012 11:16:32 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111142
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-12-07 11:16:32 +0400
message:
  Convenient macro to check whether the buffer is hidden.
  * buffer.h (BUFFER_HIDDEN_P): New macro.
  * frame.c (make_frame): Use it.  Adjust comment.
  * buffer.c (candidate_buffer): New function.
  (Fother_buffer, other_buffer_safely): Use it.
modified:
  src/ChangeLog
  src/buffer.c
  src/buffer.h
  src/frame.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-12-06 18:36:22 +0000
+++ b/src/ChangeLog     2012-12-07 07:16:32 +0000
@@ -1,3 +1,11 @@
+2012-12-07  Dmitry Antipov  <address@hidden>
+
+       Convenient macro to check whether the buffer is hidden.
+       * buffer.h (BUFFER_HIDDEN_P): New macro.
+       * frame.c (make_frame): Use it.  Adjust comment.
+       * buffer.c (candidate_buffer): New function.
+       (Fother_buffer, other_buffer_safely): Use it.
+
 2012-12-06  Eli Zaretskii  <address@hidden>
 
        * w32proc.c (waitpid): Avoid busy-waiting when called with WNOHANG

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2012-11-08 21:58:55 +0000
+++ b/src/buffer.c      2012-12-07 07:16:32 +0000
@@ -1529,6 +1529,16 @@
   return BVAR (current_buffer, name);
 }
 
+/* True if B can be used as 'other-than-BUFFER' buffer.  */
+
+static bool
+candidate_buffer (Lisp_Object b, Lisp_Object buffer)
+{
+  return (BUFFERP (b) && !EQ (b, buffer)
+         && BUFFER_LIVE_P (XBUFFER (b))
+         && !BUFFER_HIDDEN_P (XBUFFER (b)));
+}
+         
 DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0,
        doc: /* Return most recently selected buffer other than BUFFER.
 Buffers not visible in windows are preferred to visible buffers, unless
@@ -1550,9 +1560,7 @@
   for (; CONSP (tail); tail = XCDR (tail))
     {
       buf = XCAR (tail);
-      if (BUFFERP (buf) && !EQ (buf, buffer)
-         && BUFFER_LIVE_P (XBUFFER (buf))
-         && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
+      if (candidate_buffer (buf, buffer)
          /* If the frame has a buffer_predicate, disregard buffers that
             don't fit the predicate.  */
          && (NILP (pred) || !NILP (call1 (pred, buf))))
@@ -1570,9 +1578,7 @@
   for (; CONSP (tail); tail = XCDR (tail))
     {
       buf = Fcdr (XCAR (tail));
-      if (BUFFERP (buf) && !EQ (buf, buffer)
-         && BUFFER_LIVE_P (XBUFFER (buf))
-         && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
+      if (candidate_buffer (buf, buffer)
          /* If the frame has a buffer_predicate, disregard buffers that
             don't fit the predicate.  */
          && (NILP (pred) || !NILP (call1 (pred, buf))))
@@ -1608,13 +1614,10 @@
 {
   Lisp_Object tail, buf;
 
-  tail = Vbuffer_alist;
-  for (; CONSP (tail); tail = XCDR (tail))
+  for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
     {
       buf = Fcdr (XCAR (tail));
-      if (BUFFERP (buf) && !EQ (buf, buffer)
-         && BUFFER_LIVE_P (XBUFFER (buf))
-         && (SREF (BVAR (XBUFFER (buf), name), 0) != ' '))
+      if (candidate_buffer (buf, buffer))
        return buf;
     }
 

=== modified file 'src/buffer.h'
--- a/src/buffer.h      2012-11-08 14:10:28 +0000
+++ b/src/buffer.h      2012-12-07 07:16:32 +0000
@@ -982,6 +982,11 @@
 
 #define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
 
+/* Convenient check whether buffer B is hidden (i.e. its name
+   starts with a space).  Caller must ensure that B is live.  */
+
+#define BUFFER_HIDDEN_P(b) (SREF (BVAR (b, name), 0) == ' ')
+
 /* Verify indirection counters.  */
 
 #define BUFFER_CHECK_INDIRECTION(b)                    \

=== modified file 'src/frame.c'
--- a/src/frame.c       2012-12-06 13:48:11 +0000
+++ b/src/frame.c       2012-12-07 07:16:32 +0000
@@ -346,13 +346,11 @@
 
   /* Choose a buffer for the frame's root window.  */
   {
-    Lisp_Object buf;
+    Lisp_Object buf = Fcurrent_buffer ();
 
     wset_buffer (XWINDOW (root_window), Qt);
-    buf = Fcurrent_buffer ();
-    /* If buf is a 'hidden' buffer (i.e. one whose name starts with
-       a space), try to find another one.  */
-    if (SREF (Fbuffer_name (buf), 0) == ' ')
+    /* If current buffer is hidden, try to find another one.  */
+    if (BUFFER_HIDDEN_P (XBUFFER (buf)))
       buf = other_buffer_safely (buf);
 
     /* Use set_window_buffer, not Fset_window_buffer, and don't let


reply via email to

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