diff options
| author | Dmitry Antipov | 2012-12-07 11:16:32 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-12-07 11:16:32 +0400 |
| commit | ed08365b9e2756208b0cd2724715b47df6bf5320 (patch) | |
| tree | 234b22e6b305f5ac90b4563a4026fa5a528da626 /src/buffer.c | |
| parent | 8e0762cade0431a3586c9f60234a63df4117a16a (diff) | |
| download | emacs-ed08365b9e2756208b0cd2724715b47df6bf5320.tar.gz emacs-ed08365b9e2756208b0cd2724715b47df6bf5320.zip | |
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.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c index 619a729a859..6e2191dc22f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1529,6 +1529,16 @@ This does not change the name of the visited file (if any). */) | |||
| 1529 | return BVAR (current_buffer, name); | 1529 | return BVAR (current_buffer, name); |
| 1530 | } | 1530 | } |
| 1531 | 1531 | ||
| 1532 | /* True if B can be used as 'other-than-BUFFER' buffer. */ | ||
| 1533 | |||
| 1534 | static bool | ||
| 1535 | candidate_buffer (Lisp_Object b, Lisp_Object buffer) | ||
| 1536 | { | ||
| 1537 | return (BUFFERP (b) && !EQ (b, buffer) | ||
| 1538 | && BUFFER_LIVE_P (XBUFFER (b)) | ||
| 1539 | && !BUFFER_HIDDEN_P (XBUFFER (b))); | ||
| 1540 | } | ||
| 1541 | |||
| 1532 | DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, | 1542 | DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, |
| 1533 | doc: /* Return most recently selected buffer other than BUFFER. | 1543 | doc: /* Return most recently selected buffer other than BUFFER. |
| 1534 | Buffers not visible in windows are preferred to visible buffers, unless | 1544 | Buffers not visible in windows are preferred to visible buffers, unless |
| @@ -1550,9 +1560,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */) | |||
| 1550 | for (; CONSP (tail); tail = XCDR (tail)) | 1560 | for (; CONSP (tail); tail = XCDR (tail)) |
| 1551 | { | 1561 | { |
| 1552 | buf = XCAR (tail); | 1562 | buf = XCAR (tail); |
| 1553 | if (BUFFERP (buf) && !EQ (buf, buffer) | 1563 | if (candidate_buffer (buf, buffer) |
| 1554 | && BUFFER_LIVE_P (XBUFFER (buf)) | ||
| 1555 | && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') | ||
| 1556 | /* If the frame has a buffer_predicate, disregard buffers that | 1564 | /* If the frame has a buffer_predicate, disregard buffers that |
| 1557 | don't fit the predicate. */ | 1565 | don't fit the predicate. */ |
| 1558 | && (NILP (pred) || !NILP (call1 (pred, buf)))) | 1566 | && (NILP (pred) || !NILP (call1 (pred, buf)))) |
| @@ -1570,9 +1578,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */) | |||
| 1570 | for (; CONSP (tail); tail = XCDR (tail)) | 1578 | for (; CONSP (tail); tail = XCDR (tail)) |
| 1571 | { | 1579 | { |
| 1572 | buf = Fcdr (XCAR (tail)); | 1580 | buf = Fcdr (XCAR (tail)); |
| 1573 | if (BUFFERP (buf) && !EQ (buf, buffer) | 1581 | if (candidate_buffer (buf, buffer) |
| 1574 | && BUFFER_LIVE_P (XBUFFER (buf)) | ||
| 1575 | && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ') | ||
| 1576 | /* If the frame has a buffer_predicate, disregard buffers that | 1582 | /* If the frame has a buffer_predicate, disregard buffers that |
| 1577 | don't fit the predicate. */ | 1583 | don't fit the predicate. */ |
| 1578 | && (NILP (pred) || !NILP (call1 (pred, buf)))) | 1584 | && (NILP (pred) || !NILP (call1 (pred, buf)))) |
| @@ -1608,13 +1614,10 @@ other_buffer_safely (Lisp_Object buffer) | |||
| 1608 | { | 1614 | { |
| 1609 | Lisp_Object tail, buf; | 1615 | Lisp_Object tail, buf; |
| 1610 | 1616 | ||
| 1611 | tail = Vbuffer_alist; | 1617 | for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
| 1612 | for (; CONSP (tail); tail = XCDR (tail)) | ||
| 1613 | { | 1618 | { |
| 1614 | buf = Fcdr (XCAR (tail)); | 1619 | buf = Fcdr (XCAR (tail)); |
| 1615 | if (BUFFERP (buf) && !EQ (buf, buffer) | 1620 | if (candidate_buffer (buf, buffer)) |
| 1616 | && BUFFER_LIVE_P (XBUFFER (buf)) | ||
| 1617 | && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')) | ||
| 1618 | return buf; | 1621 | return buf; |
| 1619 | } | 1622 | } |
| 1620 | 1623 | ||