comparison src/mark.c @ 4043:80b041b994d1 v7.3.776

updated for version 7.3.776 Problem: ml_get error when searching, caused by curwin not matching curbuf. Solution: Avoid changing curbuf. (Lech Lorens)
author Bram Moolenaar <bram@vim.org>
date Wed, 23 Jan 2013 15:53:15 +0100
parents bdf7f3e4c763
children c0cc0e0620dd
comparison
equal deleted inserted replaced
4042:874910cb3cf5 4043:80b041b994d1
302 return curbuf->b_changelist + n; 302 return curbuf->b_changelist + n;
303 } 303 }
304 #endif 304 #endif
305 305
306 /* 306 /*
307 * Find mark "c". 307 * Find mark "c" in buffer pointed to by "buf".
308 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc. 308 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc.
309 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit 309 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit
310 * another file. 310 * another file.
311 * Returns: 311 * Returns:
312 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is 312 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is
313 * in another file which can't be gotten. (caller needs to check lnum!) 313 * in another file which can't be gotten. (caller needs to check lnum!)
314 * - NULL if there is no mark called 'c'. 314 * - NULL if there is no mark called 'c'.
315 * - -1 if mark is in other file and jumped there (only if changefile is TRUE) 315 * - -1 if mark is in other file and jumped there (only if changefile is TRUE)
316 */ 316 */
317 pos_T * 317 pos_T *
318 getmark_buf(buf, c, changefile)
319 buf_T *buf;
320 int c;
321 int changefile;
322 {
323 return getmark_buf_fnum(buf, c, changefile, NULL);
324 }
325
326 pos_T *
318 getmark(c, changefile) 327 getmark(c, changefile)
319 int c; 328 int c;
320 int changefile; 329 int changefile;
321 { 330 {
322 return getmark_fnum(c, changefile, NULL); 331 return getmark_buf_fnum(curbuf, c, changefile, NULL);
323 } 332 }
324 333
325 pos_T * 334 pos_T *
326 getmark_fnum(c, changefile, fnum) 335 getmark_buf_fnum(buf, c, changefile, fnum)
336 buf_T *buf;
327 int c; 337 int c;
328 int changefile; 338 int changefile;
329 int *fnum; 339 int *fnum;
330 { 340 {
331 pos_T *posp; 341 pos_T *posp;
349 { 359 {
350 pos_copy = curwin->w_pcmark; /* need to make a copy because */ 360 pos_copy = curwin->w_pcmark; /* need to make a copy because */
351 posp = &pos_copy; /* w_pcmark may be changed soon */ 361 posp = &pos_copy; /* w_pcmark may be changed soon */
352 } 362 }
353 else if (c == '"') /* to pos when leaving buffer */ 363 else if (c == '"') /* to pos when leaving buffer */
354 posp = &(curbuf->b_last_cursor); 364 posp = &(buf->b_last_cursor);
355 else if (c == '^') /* to where Insert mode stopped */ 365 else if (c == '^') /* to where Insert mode stopped */
356 posp = &(curbuf->b_last_insert); 366 posp = &(buf->b_last_insert);
357 else if (c == '.') /* to where last change was made */ 367 else if (c == '.') /* to where last change was made */
358 posp = &(curbuf->b_last_change); 368 posp = &(buf->b_last_change);
359 else if (c == '[') /* to start of previous operator */ 369 else if (c == '[') /* to start of previous operator */
360 posp = &(curbuf->b_op_start); 370 posp = &(buf->b_op_start);
361 else if (c == ']') /* to end of previous operator */ 371 else if (c == ']') /* to end of previous operator */
362 posp = &(curbuf->b_op_end); 372 posp = &(buf->b_op_end);
363 else if (c == '{' || c == '}') /* to previous/next paragraph */ 373 else if (c == '{' || c == '}') /* to previous/next paragraph */
364 { 374 {
365 pos_T pos; 375 pos_T pos;
366 oparg_T oa; 376 oparg_T oa;
367 int slcb = listcmd_busy; 377 int slcb = listcmd_busy;
393 listcmd_busy = slcb; 403 listcmd_busy = slcb;
394 } 404 }
395 #ifdef FEAT_VISUAL 405 #ifdef FEAT_VISUAL
396 else if (c == '<' || c == '>') /* start/end of visual area */ 406 else if (c == '<' || c == '>') /* start/end of visual area */
397 { 407 {
398 startp = &curbuf->b_visual.vi_start; 408 startp = &buf->b_visual.vi_start;
399 endp = &curbuf->b_visual.vi_end; 409 endp = &buf->b_visual.vi_end;
400 if ((c == '<') == lt(*startp, *endp)) 410 if ((c == '<') == lt(*startp, *endp))
401 posp = startp; 411 posp = startp;
402 else 412 else
403 posp = endp; 413 posp = endp;
404 /* 414 /*
405 * For Visual line mode, set mark at begin or end of line 415 * For Visual line mode, set mark at begin or end of line
406 */ 416 */
407 if (curbuf->b_visual.vi_mode == 'V') 417 if (buf->b_visual.vi_mode == 'V')
408 { 418 {
409 pos_copy = *posp; 419 pos_copy = *posp;
410 posp = &pos_copy; 420 posp = &pos_copy;
411 if (c == '<') 421 if (c == '<')
412 pos_copy.col = 0; 422 pos_copy.col = 0;
418 } 428 }
419 } 429 }
420 #endif 430 #endif
421 else if (ASCII_ISLOWER(c)) /* normal named mark */ 431 else if (ASCII_ISLOWER(c)) /* normal named mark */
422 { 432 {
423 posp = &(curbuf->b_namedm[c - 'a']); 433 posp = &(buf->b_namedm[c - 'a']);
424 } 434 }
425 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */ 435 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */
426 { 436 {
427 if (VIM_ISDIGIT(c)) 437 if (VIM_ISDIGIT(c))
428 c = c - '0' + NMARKS; 438 c = c - '0' + NMARKS;
433 if (namedfm[c].fmark.fnum == 0) 443 if (namedfm[c].fmark.fnum == 0)
434 fname2fnum(&namedfm[c]); 444 fname2fnum(&namedfm[c]);
435 445
436 if (fnum != NULL) 446 if (fnum != NULL)
437 *fnum = namedfm[c].fmark.fnum; 447 *fnum = namedfm[c].fmark.fnum;
438 else if (namedfm[c].fmark.fnum != curbuf->b_fnum) 448 else if (namedfm[c].fmark.fnum != buf->b_fnum)
439 { 449 {
440 /* mark is in another file */ 450 /* mark is in another file */
441 posp = &pos_copy; 451 posp = &pos_copy;
442 452
443 if (namedfm[c].fmark.mark.lnum != 0 453 if (namedfm[c].fmark.mark.lnum != 0