summaryrefslogtreecommitdiffstats
path: root/src/globals.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-24 22:04:11 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-24 22:04:11 +0200
commit2932359000b2f918d5fade79ea4d124d5943cd07 (patch)
tree1ca4fa98569a4d20ce066c7d6254404bcf431b47 /src/globals.h
parent6835dc61aebca2b602d85a9d63c449ace58683b4 (diff)
patch 7.4.2101v7.4.2101
Problem: Looping over windows, buffers and tab pages is inconsistant. Solution: Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan)
Diffstat (limited to 'src/globals.h')
-rw-r--r--src/globals.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/globals.h b/src/globals.h
index b569680a41..a3d6b4ee24 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -548,6 +548,10 @@ EXTERN win_T *lastwin; /* last window */
EXTERN win_T *prevwin INIT(= NULL); /* previous window */
# define W_NEXT(wp) ((wp)->w_next)
# define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next)
+# define FOR_ALL_TABPAGES(tp) for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
+# define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
+ for ((wp) = ((tp) == NULL || (tp) == curtab) \
+ ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
/*
* When using this macro "break" only breaks out of the inner loop. Use "goto"
* to break out of the tabpage loop.
@@ -561,6 +565,8 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */
# define lastwin curwin
# define W_NEXT(wp) NULL
# define FOR_ALL_WINDOWS(wp) wp = curwin;
+# define FOR_ALL_TABPAGES(tp) for (;FALSE;)
+# define FOR_ALL_WINDOWS_IN_TAB(tp, wp) wp = curwin;
# define FOR_ALL_TAB_WINDOWS(tp, wp) wp = curwin;
#endif
@@ -595,6 +601,8 @@ EXTERN buf_T *firstbuf INIT(= NULL); /* first buffer */
EXTERN buf_T *lastbuf INIT(= NULL); /* last buffer */
EXTERN buf_T *curbuf INIT(= NULL); /* currently active buffer */
+#define FOR_ALL_BUFFERS(buf) for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+
/* Flag that is set when switching off 'swapfile'. It means that all blocks
* are to be loaded into memory. Shouldn't be global... */
EXTERN int mf_dont_release INIT(= FALSE); /* don't release blocks */