comparison src/fileio.c @ 934:e44efb3af0d5 v7.0.060

updated for version 7.0-060
author vimboss
date Wed, 16 Aug 2006 17:35:00 +0000
parents 8cd729851562
children 4fb859cd9ba9
comparison
equal deleted inserted replaced
933:56609cdae088 934:e44efb3af0d5
6448 pos_T old_cursor; 6448 pos_T old_cursor;
6449 linenr_T old_topline; 6449 linenr_T old_topline;
6450 int old_ro = buf->b_p_ro; 6450 int old_ro = buf->b_p_ro;
6451 buf_T *savebuf; 6451 buf_T *savebuf;
6452 int saved = OK; 6452 int saved = OK;
6453 #ifdef FEAT_AUTOCMD
6454 aco_save_T aco; 6453 aco_save_T aco;
6455 6454
6456 /* set curwin/curbuf for "buf" and save some things */ 6455 /* set curwin/curbuf for "buf" and save some things */
6457 aucmd_prepbuf(&aco, buf); 6456 aucmd_prepbuf(&aco, buf);
6458 #else
6459 buf_T *save_curbuf = curbuf;
6460
6461 curbuf = buf;
6462 curwin->w_buffer = buf;
6463 #endif
6464 6457
6465 /* We only want to read the text from the file, not reset the syntax 6458 /* We only want to read the text from the file, not reset the syntax
6466 * highlighting, clear marks, diff status, etc. Force the fileformat 6459 * highlighting, clear marks, diff status, etc. Force the fileformat
6467 * and encoding to be the same. */ 6460 * and encoding to be the same. */
6468 if (prep_exarg(&ea, buf) == OK) 6461 if (prep_exarg(&ea, buf) == OK)
6571 * reset it, might have had a read error. */ 6564 * reset it, might have had a read error. */
6572 if (orig_mode == curbuf->b_orig_mode) 6565 if (orig_mode == curbuf->b_orig_mode)
6573 curbuf->b_p_ro |= old_ro; 6566 curbuf->b_p_ro |= old_ro;
6574 } 6567 }
6575 6568
6576 #ifdef FEAT_AUTOCMD
6577 /* restore curwin/curbuf and a few other things */ 6569 /* restore curwin/curbuf and a few other things */
6578 aucmd_restbuf(&aco); 6570 aucmd_restbuf(&aco);
6579 /* Careful: autocommands may have made "buf" invalid! */ 6571 /* Careful: autocommands may have made "buf" invalid! */
6580 #else
6581 curwin->w_buffer = save_curbuf;
6582 curbuf = save_curbuf;
6583 #endif
6584 } 6572 }
6585 6573
6586 /*ARGSUSED*/ 6574 /*ARGSUSED*/
6587 void 6575 void
6588 buf_store_time(buf, st, fname) 6576 buf_store_time(buf, st, fname)
8086 /* 8074 /*
8087 * Prepare for executing autocommands for (hidden) buffer "buf". 8075 * Prepare for executing autocommands for (hidden) buffer "buf".
8088 * Search a window for the current buffer. Save the cursor position and 8076 * Search a window for the current buffer. Save the cursor position and
8089 * screen offset. 8077 * screen offset.
8090 * Set "curbuf" and "curwin" to match "buf". 8078 * Set "curbuf" and "curwin" to match "buf".
8079 * When FEAT_AUTOCMD is not defined another version is used, see below.
8091 */ 8080 */
8092 void 8081 void
8093 aucmd_prepbuf(aco, buf) 8082 aucmd_prepbuf(aco, buf)
8094 aco_save_T *aco; /* structure to save values in */ 8083 aco_save_T *aco; /* structure to save values in */
8095 buf_T *buf; /* new curbuf */ 8084 buf_T *buf; /* new curbuf */
8149 } 8138 }
8150 8139
8151 /* 8140 /*
8152 * Cleanup after executing autocommands for a (hidden) buffer. 8141 * Cleanup after executing autocommands for a (hidden) buffer.
8153 * Restore the window as it was (if possible). 8142 * Restore the window as it was (if possible).
8143 * When FEAT_AUTOCMD is not defined another version is used, see below.
8154 */ 8144 */
8155 void 8145 void
8156 aucmd_restbuf(aco) 8146 aucmd_restbuf(aco)
8157 aco_save_T *aco; /* structure holding saved values */ 8147 aco_save_T *aco; /* structure holding saved values */
8158 { 8148 {
9061 theend: 9051 theend:
9062 vim_free(arg_save); 9052 vim_free(arg_save);
9063 return retval; 9053 return retval;
9064 } 9054 }
9065 9055
9056 #else /* FEAT_AUTOCMD */
9057
9058 /*
9059 * Prepare for executing commands for (hidden) buffer "buf".
9060 * This is the non-autocommand version, it simply saves "curbuf" and sets
9061 * "curbuf" and "curwin" to match "buf".
9062 */
9063 void
9064 aucmd_prepbuf(aco, buf)
9065 aco_save_T *aco; /* structure to save values in */
9066 buf_T *buf; /* new curbuf */
9067 {
9068 aco->save_buf = buf;
9069 curbuf = buf;
9070 curwin->w_buffer = buf;
9071 }
9072
9073 /*
9074 * Restore after executing commands for a (hidden) buffer.
9075 * This is the non-autocommand version.
9076 */
9077 void
9078 aucmd_restbuf(aco)
9079 aco_save_T *aco; /* structure holding saved values */
9080 {
9081 curbuf = aco->save_buf;
9082 curwin->w_buffer = curbuf;
9083 }
9084
9066 #endif /* FEAT_AUTOCMD */ 9085 #endif /* FEAT_AUTOCMD */
9086
9067 9087
9068 #if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) || defined(PROTO) 9088 #if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) || defined(PROTO)
9069 /* 9089 /*
9070 * Try matching a filename with a "pattern" ("prog" is NULL), or use the 9090 * Try matching a filename with a "pattern" ("prog" is NULL), or use the
9071 * precompiled regprog "prog" ("pattern" is NULL). That avoids calling 9091 * precompiled regprog "prog" ("pattern" is NULL). That avoids calling