[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111121: Avoid code duplication betwe
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111121: Avoid code duplication between prev_frame and next_frame. |
Date: |
Thu, 06 Dec 2012 10:23:51 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111121
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2012-12-06 10:23:51 +0400
message:
Avoid code duplication between prev_frame and next_frame.
* frame.c (candidate_frame): New function. Add comment.
(prev_frame, next_frame): Use it. Adjust comment.
modified:
src/ChangeLog
src/frame.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-12-06 06:17:10 +0000
+++ b/src/ChangeLog 2012-12-06 06:23:51 +0000
@@ -1,3 +1,9 @@
+2012-12-06 Dmitry Antipov <address@hidden>
+
+ Avoid code duplication between prev_frame and next_frame.
+ * frame.c (candidate_frame): New function. Add comment.
+ (prev_frame, next_frame): Use it. Adjust comment.
+
2012-12-06 Eli Zaretskii <address@hidden>
* callproc.c (Fcall_process_region) [!HAVE_MKSTEMP]: If mktemp
=== modified file 'src/frame.c'
--- a/src/frame.c 2012-11-24 17:20:49 +0000
+++ b/src/frame.c 2012-12-06 06:23:51 +0000
@@ -895,13 +895,58 @@
return frames;
}
-/* Return the next frame in the frame list after FRAME.
- If MINIBUF is nil, exclude minibuffer-only frames.
- If MINIBUF is a window, include only its own frame
- and any frame now using that window as the minibuffer.
- If MINIBUF is `visible', include all visible frames.
- If MINIBUF is 0, include all visible and iconified frames.
- Otherwise, include all frames. */
+/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
+ same tty (for tty frames) or among frames which uses FRAME's keyboard.
+ If MINIBUF is nil, do not consider minibuffer-only candidate.
+ If MINIBUF is `visible', do not consider an invisible candidate.
+ If MINIBUF is a window, consider only its own frame and candidate now
+ using that window as the minibuffer.
+ If MINIBUF is 0, consider candidate if it is visible or iconified.
+ Otherwise consider any candidate and return nil if CANDIDATE is not
+ acceptable. */
+
+static Lisp_Object
+candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf)
+{
+ struct frame *c = XFRAME (candidate), *f = XFRAME (frame);
+
+ if ((!FRAME_TERMCAP_P (c) && !FRAME_TERMCAP_P (f)
+ && FRAME_KBOARD (c) == FRAME_KBOARD (f))
+ || (FRAME_TERMCAP_P (c) && FRAME_TERMCAP_P (f)
+ && FRAME_TTY (c) == FRAME_TTY (f)))
+ {
+ if (NILP (minibuf))
+ {
+ if (!FRAME_MINIBUF_ONLY_P (c))
+ return candidate;
+ }
+ else if (EQ (minibuf, Qvisible))
+ {
+ FRAME_SAMPLE_VISIBILITY (c);
+ if (FRAME_VISIBLE_P (c))
+ return candidate;
+ }
+ else if (WINDOWP (minibuf))
+ {
+ if (EQ (FRAME_MINIBUF_WINDOW (c), minibuf)
+ || EQ (WINDOW_FRAME (XWINDOW (minibuf)), candidate)
+ || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
+ FRAME_FOCUS_FRAME (c)))
+ return candidate;
+ }
+ else if (XFASTINT (minibuf) == 0)
+ {
+ FRAME_SAMPLE_VISIBILITY (c);
+ if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c))
+ return candidate;
+ }
+ else
+ return candidate;
+ }
+ return Qnil;
+}
+
+/* Return the next frame in the frame list after FRAME. */
static Lisp_Object
next_frame (Lisp_Object frame, Lisp_Object minibuf)
@@ -910,72 +955,24 @@
int passed = 0;
/* There must always be at least one frame in Vframe_list. */
- if (! CONSP (Vframe_list))
- emacs_abort ();
-
- /* If this frame is dead, it won't be in Vframe_list, and we'll loop
- forever. Forestall that. */
- CHECK_LIVE_FRAME (frame);
-
- while (1)
+ eassert (CONSP (Vframe_list));
+
+ while (passed < 2)
FOR_EACH_FRAME (tail, f)
{
- if (passed
- && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME
(frame))
- && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
- || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME
(frame))
- && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))))
+ if (passed)
{
- /* Decide whether this frame is eligible to be returned. */
-
- /* If we've looped all the way around without finding any
- eligible frames, return the original frame. */
- if (EQ (f, frame))
- return f;
-
- /* Let minibuf decide if this frame is acceptable. */
- if (NILP (minibuf))
- {
- if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
- return f;
- }
- else if (EQ (minibuf, Qvisible))
- {
- FRAME_SAMPLE_VISIBILITY (XFRAME (f));
- if (FRAME_VISIBLE_P (XFRAME (f)))
- return f;
- }
- else if (INTEGERP (minibuf) && XINT (minibuf) == 0)
- {
- FRAME_SAMPLE_VISIBILITY (XFRAME (f));
- if (FRAME_VISIBLE_P (XFRAME (f))
- || FRAME_ICONIFIED_P (XFRAME (f)))
- return f;
- }
- else if (WINDOWP (minibuf))
- {
- if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
- || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
- || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
- FRAME_FOCUS_FRAME (XFRAME (f))))
- return f;
- }
- else
+ f = candidate_frame (f, frame, minibuf);
+ if (!NILP (f))
return f;
}
-
if (EQ (frame, f))
passed++;
}
+ return frame;
}
-/* Return the previous frame in the frame list before FRAME.
- If MINIBUF is nil, exclude minibuffer-only frames.
- If MINIBUF is a window, include only its own frame
- and any frame now using that window as the minibuffer.
- If MINIBUF is `visible', include all visible frames.
- If MINIBUF is 0, include all visible and iconified frames.
- Otherwise, include all frames. */
+/* Return the previous frame in the frame list before FRAME. */
static Lisp_Object
prev_frame (Lisp_Object frame, Lisp_Object minibuf)
@@ -989,43 +986,9 @@
{
if (EQ (frame, f) && !NILP (prev))
return prev;
-
- if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
- && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
- || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
- && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))
- {
- /* Decide whether this frame is eligible to be returned,
- according to minibuf. */
- if (NILP (minibuf))
- {
- if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
- prev = f;
- }
- else if (WINDOWP (minibuf))
- {
- if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
- || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
- || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
- FRAME_FOCUS_FRAME (XFRAME (f))))
- prev = f;
- }
- else if (EQ (minibuf, Qvisible))
- {
- FRAME_SAMPLE_VISIBILITY (XFRAME (f));
- if (FRAME_VISIBLE_P (XFRAME (f)))
- prev = f;
- }
- else if (XFASTINT (minibuf) == 0)
- {
- FRAME_SAMPLE_VISIBILITY (XFRAME (f));
- if (FRAME_VISIBLE_P (XFRAME (f))
- || FRAME_ICONIFIED_P (XFRAME (f)))
- prev = f;
- }
- else
- prev = f;
- }
+ f = candidate_frame (f, frame, minibuf);
+ if (!NILP (f))
+ prev = f;
}
/* We've scanned the entire list. */
@@ -1056,7 +1019,6 @@
{
if (NILP (frame))
frame = selected_frame;
-
CHECK_LIVE_FRAME (frame);
return next_frame (frame, miniframe);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111121: Avoid code duplication between prev_frame and next_frame.,
Dmitry Antipov <=