- std::vector<string>::const_iterator cit = files.begin();
- std::vector<string>::const_iterator end = files.end();
- for (; cit != end; ++cit) {
- Buffer * b = bufferlist.newBuffer(*cit);
- if (loadLyXFile(b, *cit))
- last = b;
- }
-
- // switch to the last buffer successfully loaded
- if (last) {
- view.view()->buffer(last);
- }
+ for_each(files.begin(), files.end(),
+ bind(&BufferView::loadLyXFile, view.view(), _1, true));