To: vim-dev@vim.org Subject: patch 5.4.15 Fcc: outbox From: Bram Moolenaar ------------ Another patch which has had enough time for testing: Patch 5.4.15 Problem: Since 'backspace' set to 0 has been made Vi compatible, it is no longer possible to only allow deleting autoindent. Solution: Make 'backspace' a list of parts, to allow each kind of backspacing separately. Files: src/edit.c, src/option.c, src/option.h, src/proto/option.pro, runtime/doc/option.txt, runtime/doc/insert.txt *** ../vim-5.4/src/edit.c Sun Jul 25 22:02:03 1999 --- src/edit.c Wed Aug 4 17:53:08 1999 *************** *** 323,329 **** #ifdef USE_MOUSE /* * After a paste we consider text typed to be part of the insert for ! * the pasted text. You can backspace over the paste text too. */ if (where_paste_started.lnum) arrow_used = FALSE; --- 323,329 ---- #ifdef USE_MOUSE /* * After a paste we consider text typed to be part of the insert for ! * the pasted text. You can backspace over the pasted text too. */ if (where_paste_started.lnum) arrow_used = FALSE; *************** *** 4697,4703 **** if (gchar_cursor() == NUL) /* delete newline */ { temp = curwin->w_cursor.col; ! if (!p_bs /* only if 'bs' set */ || u_save((linenr_t)(curwin->w_cursor.lnum - 1), (linenr_t)(curwin->w_cursor.lnum + 2)) == FAIL || do_join(FALSE, TRUE) == FAIL) --- 4697,4703 ---- if (gchar_cursor() == NUL) /* delete newline */ { temp = curwin->w_cursor.col; ! if (!can_bs(BS_EOL) /* only if "eol" included */ || u_save((linenr_t)(curwin->w_cursor.lnum - 1), (linenr_t)(curwin->w_cursor.lnum + 2)) == FAIL || do_join(FALSE, TRUE) == FAIL) *************** *** 4751,4762 **** !revins_on && #endif ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col <= 0) ! || (p_bs < 2 && (arrow_used || (curwin->w_cursor.lnum == Insstart.lnum ! && curwin->w_cursor.col <= Insstart.col) ! || (curwin->w_cursor.col <= ai_col ! && p_bs == 0)))))) { vim_beep(); return FALSE; --- 4751,4763 ---- !revins_on && #endif ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col <= 0) ! || (!can_bs(BS_START) && (arrow_used || (curwin->w_cursor.lnum == Insstart.lnum ! && curwin->w_cursor.col <= Insstart.col))) ! || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 ! && curwin->w_cursor.col <= ai_col) ! || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { vim_beep(); return FALSE; *** ../vim-5.4/src/option.c Sun Jul 25 22:02:04 1999 --- src/option.c Wed Aug 4 17:34:01 1999 *************** *** 172,180 **** (char_u *)"light", #endif (char_u *)0L}}, ! {"backspace", "bs", P_NUM|P_VI_DEF|P_VIM, (char_u *)&p_bs, ! {(char_u *)0L, (char_u *)0L}}, {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_bk, {(char_u *)FALSE, (char_u *)0L}}, --- 172,180 ---- (char_u *)"light", #endif (char_u *)0L}}, ! {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA, (char_u *)&p_bs, ! {(char_u *)"", (char_u *)0L}}, {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_bk, {(char_u *)FALSE, (char_u *)0L}}, *************** *** 1475,1480 **** --- 1475,1481 ---- #ifdef USE_CLIPBOARD static char *(p_cb_values[]) = {"unnamed", "autoselect", NULL}; #endif + static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; static void set_option_default __ARGS((int, int)); static void set_options_default __ARGS((int dofree)); *************** *** 3629,3634 **** --- 3630,3647 ---- } } + /* 'backspace' */ + else if (varp == &p_bs) + { + if (isdigit(*p_bs)) + { + if (*p_bs >'2' || p_bs[1] != NUL) + errmsg = e_invarg; + } + else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) + errmsg = e_invarg; + } + /* Options that are a list of flags. */ else { *************** *** 5926,5929 **** --- 5944,5963 ---- for (i = 0; i < 4; ++i) wim_flags[i] = new_wim_flags[i]; return OK; + } + + /* + * Check if backspacing over something is allowed. + */ + int + can_bs(what) + int what; /* BS_INDENT, BS_EOL or BS_START */ + { + switch (*p_bs) + { + case '2': return TRUE; + case '1': return (what != BS_START); + case '0': return FALSE; + default: return vim_strchr(p_bs, what) != NULL; + } } *** ../vim-5.4/src/option.h Sun Jul 25 22:02:04 1999 --- src/option.h Wed Aug 4 16:30:55 1999 *************** *** 238,243 **** --- 238,248 ---- #define WIM_LONGEST 2 #define WIM_LIST 4 + /* arguments for can_bs() */ + #define BS_INDENT 'i' /* "Indent" */ + #define BS_EOL 'o' /* "eOl" */ + #define BS_START 's' /* "Start" */ + /* * The following are actual variabables for the options */ *************** *** 246,252 **** EXTERN long p_aleph; /* 'aleph' */ #endif EXTERN int p_aw; /* 'autowrite' */ ! EXTERN long p_bs; /* 'backspace' */ EXTERN char_u *p_bg; /* 'background' */ EXTERN int p_bk; /* 'backup' */ EXTERN char_u *p_bdir; /* 'backupdir' */ --- 251,257 ---- EXTERN long p_aleph; /* 'aleph' */ #endif EXTERN int p_aw; /* 'autowrite' */ ! EXTERN char_u *p_bs; /* 'backspace' */ EXTERN char_u *p_bg; /* 'background' */ EXTERN int p_bk; /* 'backup' */ EXTERN char_u *p_bdir; /* 'backupdir' */ *** ../vim-5.4/src/proto/option.pro Sun Jul 25 22:01:57 1999 --- src/proto/option.pro Wed Aug 4 16:33:41 1999 *************** *** 33,35 **** --- 33,36 ---- void vimrc_found __ARGS((void)); void change_compatible __ARGS((int on)); int option_was_set __ARGS((char_u *name)); + int can_bs __ARGS((int what)); *** ../vim-5.4/runtime/doc/options.txt Sun Jul 25 22:02:36 1999 --- runtime/doc/options.txt Wed Aug 4 15:43:07 1999 *************** *** 1,4 **** ! *options.txt* For Vim version 5.4. Last change: 1999 Jul 23 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *options.txt* For Vim version 5.4. Last change: 1999 Aug 04 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 28,34 **** :se[t] all Show all but terminal options. :se[t] termcap Show all terminal options. Note that in the GUI the ! key codes are not show, because they are generated interally and can't be changed. Changing the terminal codes in the GUI is not useful either... --- 28,34 ---- :se[t] all Show all but terminal options. :se[t] termcap Show all terminal options. Note that in the GUI the ! key codes are not shown, because they are generated interally and can't be changed. Changing the terminal codes in the GUI is not useful either... *************** *** 567,582 **** done with ":syntax on". *'backspace'* *'bs'* ! 'backspace' 'bs' number (default 0) global {not in Vi} Influences the working of , , CTRL-W and CTRL-U in Insert ! mode: value effect ~ ! 0 Vi compatible backspacing is used. ! 1 allow backspacing over s and autoindent. ! 2 allow backspacing over the start of insert. CTRL-W and CTRL-U stop once at the start of insert. See |:fixdel| if your or key does not do what you want. *'backup'* *'bk'* *'nobackup'* *'nobk'* --- 567,592 ---- done with ":syntax on". *'backspace'* *'bs'* ! 'backspace' 'bs' string (default "") global {not in Vi} Influences the working of , , CTRL-W and CTRL-U in Insert ! mode. This is a list of items, separated by commas. Each item allows ! a way to backspace over something: value effect ~ ! indent allow backspacing over autoindent ! eol allow backspacing over line breaks (join lines) ! start allow backspacing over the start of insert; CTRL-W and CTRL-U stop once at the start of insert. + + When the value is empty, Vi compatible backspacing is used. + + For backwards compatibility with version 5.4 and earlier: + value effect ~ + 0 same as "" (Vi compatible) + 1 same as "indent,eol" + 2 same as "indent,eol,start" + See |:fixdel| if your or key does not do what you want. *'backup'* *'bk'* *'nobackup'* *'nobk'* *** ../vim-5.4/runtime/doc/insert.txt Sun Jul 25 22:02:36 1999 --- runtime/doc/insert.txt Wed Aug 4 16:53:57 1999 *************** *** 1,4 **** ! *insert.txt* For Vim version 5.4. Last change: 1999 Jun 29 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *insert.txt* For Vim version 5.4. Last change: 1999 Aug 04 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 54,67 **** *i_CTRL-H* *i_* or CTRL-H Delete the character before the cursor (see |i_backspacing| ! about joining lines). See |:fixdel| if your does not do ! what you want. {Vi: does not delete autoindents} *i_* Delete the character under the cursor. If the cursor is at ! the end of the line, and the 'backspace' option is non-zero, ! delete the ; the next line is appended after the current ! one. See |:fixdel| if your key does not do what you ! want. {not in Vi} *i_CTRL-W* CTRL-W Delete the word before the cursor (see |i_backspacing| about joining lines). See the section "word motions", --- 54,69 ---- *i_CTRL-H* *i_* or CTRL-H Delete the character before the cursor (see |i_backspacing| ! about joining lines). ! See |:fixdel| if your key does not do what you want. ! {Vi: does not delete autoindents} *i_* Delete the character under the cursor. If the cursor is at ! the end of the line, and the 'backspace' option includes ! "eol", delete the ; the next line is appended after the ! current one. ! See |:fixdel| if your key does not do what you want. ! {not in Vi} *i_CTRL-W* CTRL-W Delete the word before the cursor (see |i_backspacing| about joining lines). See the section "word motions", *************** *** 194,212 **** *i_backspacing* The effect of the , CTRL-W, and CTRL-U depend on the 'backspace' option ! (unless 'revins' is set): ! backspace action ! option ! 0 delete stops in column 1 and start position of insert ! 1 delete stops at start position of insert ! 2 delete always; CTRL-W and CTRL-U stop once at start position of ! insert ! ! If the 'backspace' option is non-zero and the cursor is in column 1 when one ! of the three keys is used, the current line is joined with the previous ! line. This effectively deletes the in front of the cursor. {Vi: does ! not cross lines, does not delete past start position of insert} *i_CTRL-V_digit* With CTRL-V followed by one, two, or three digits, you can enter the decimal --- 196,219 ---- *i_backspacing* The effect of the , CTRL-W, and CTRL-U depend on the 'backspace' option ! (unless 'revins' is set). This is a comma separated list of items: ! item action ~ ! indent allow backspacing over autoindent ! eol allow backspacing over end-of-line (join lines) ! start allow backspacing over the start position of insert; CTRL-W and ! CTRL-U stop once at the start position ! ! When 'backspace' is empty, Vi compatible backspacing is used. You cannot ! backspace over autoindent, before column 1 or before where insert started. ! ! For backwards compatibility the values "0", "1" and "2" are also allowed, see ! |'backspace'|. ! ! If the 'backspace' option does contain "eol" and the cursor is in column 1 ! when one of the three keys is used, the current line is joined with the ! previous line. This effectively deletes the in front of the cursor. ! {Vi: does not cross lines, does not delete past start position of insert} *i_CTRL-V_digit* With CTRL-V followed by one, two, or three digits, you can enter the decimal *************** *** 248,255 **** and then restart insertion. This means you can do something without getting out of Insert mode. This is very handy if you prefer to use the Insert mode all the time, just like editors that don't have a separate Normal mode. You ! may also want to set the 'backspace' option to 2 and set the 'insertmode' ! option. You can use CTRL-O if you want to map a function key to a command. The changes (inserted or deleted characters) before and after these keys can be undone separately. Only the last change can be redone and always behaves --- 255,263 ---- and then restart insertion. This means you can do something without getting out of Insert mode. This is very handy if you prefer to use the Insert mode all the time, just like editors that don't have a separate Normal mode. You ! may also want to set the 'backspace' option to "indent,eol,start" and set the ! 'insertmode' option. You can use CTRL-O if you want to map a function key to ! a command. The changes (inserted or deleted characters) before and after these keys can be undone separately. Only the last change can be redone and always behaves *** ../vim-5.4/src/version.h Sat Aug 7 22:03:47 1999 --- src/version.h Sat Aug 7 22:10:31 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 14 ! #define VIM_VERSION_PATCHLEVEL_STR "14" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 15 ! #define VIM_VERSION_PATCHLEVEL_STR "15" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.14" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.14 (1999 Aug 7)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.14 (1999 Aug 7, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.15" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.15 (1999 Aug 7)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.15 (1999 Aug 7, compiled " -- Biting someone with your natural teeth is "simple assault," while biting someone with your false teeth is "aggravated assault." [real standing law in Louisana, United States of America] --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /