diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | runtime/doc/windows.txt | 59 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 123 | ||||
-rw-r--r-- | src/nvim/ex_cmds.lua | 34 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 27 | ||||
-rw-r--r-- | src/nvim/getchar.c | 6 | ||||
-rw-r--r-- | src/nvim/globals.h | 3 | ||||
-rw-r--r-- | src/nvim/misc1.c | 15 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
9 files changed, 171 insertions, 101 deletions
diff --git a/.gitignore b/.gitignore index 5332ef5c76..3ad1a352eb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ /src/nvim/po/vim.pot /src/nvim/po/*.ck +# Files generated by scripts/vim-patch.sh +/.vim-src/ + # Files generated by the tests /src/nvim/testdir/mbyte.vim /src/nvim/testdir/mzscheme.vim diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 4ba28a3c08..00fe956dd4 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -1042,36 +1042,41 @@ list of buffers. |unlisted-buffer| a number). Insert a backslash before a space in a buffer name. -:[N]b[uffer][!] [N] *:b* *:bu* *:buf* *:buffer* *E86* +:[N]b[uffer][!] [+cmd] [N] *:b* *:bu* *:buf* *:buffer* *E86* Edit buffer [N] from the buffer list. If [N] is not given, the current buffer remains being edited. See |:buffer-!| for [!]. This will also edit a buffer that is not in the buffer list, without setting the 'buflisted' flag. + Also see ||+cmd|. -:[N]b[uffer][!] {bufname} +:[N]b[uffer][!] [+cmd] {bufname} Edit buffer for {bufname} from the buffer list. See |:buffer-!| for [!]. This will also edit a buffer that is not in the buffer list, without setting the 'buflisted' flag. + Also see ||+cmd|. -:[N]sb[uffer] [N] *:sb* *:sbuffer* +:[N]sb[uffer] [+cmd] [N] *:sb* *:sbuffer* Split window and edit buffer [N] from the buffer list. If [N] is not given, the current buffer is edited. Respects the "useopen" setting of 'switchbuf' when splitting. This will also edit a buffer that is not in the buffer list, without setting the 'buflisted' flag. + Also see ||+cmd|. -:[N]sb[uffer] {bufname} +:[N]sb[uffer] [+cmd] {bufname} Split window and edit buffer for {bufname} from the buffer list. This will also edit a buffer that is not in the buffer list, without setting the 'buflisted' flag. Note: If what you want to do is split the buffer, make a copy under another name, you can do it this way: > :w foobar | sp # +< Also see ||+cmd|. -:[N]bn[ext][!] [N] *:bn* *:bnext* *E87* +:[N]bn[ext][!] [+cmd] [N] *:bn* *:bnext* *E87* Go to [N]th next buffer in buffer list. [N] defaults to one. Wraps around the end of the buffer list. See |:buffer-!| for [!]. + Also see ||+cmd|. If you are in a help buffer, this takes you to the next help buffer (if there is one). Similarly, if you are in a normal (non-help) buffer, this takes you to the next normal buffer. @@ -1079,55 +1084,61 @@ list of buffers. |unlisted-buffer| the way when you're browsing code/text buffers. The next three commands also work like this. + *:sbn* *:sbnext* -:[N]sbn[ext] [N] +:[N]sbn[ext] [+cmd] [N] Split window and go to [N]th next buffer in buffer list. Wraps around the end of the buffer list. Uses 'switchbuf' + Also see ||+cmd|. -:[N]bN[ext][!] [N] *:bN* *:bNext* *:bp* *:bprevious* *E88* -:[N]bp[revious][!] [N] +:[N]bN[ext][!] [+cmd] [N] *:bN* *:bNext* *:bp* *:bprevious* *E88* +:[N]bp[revious][!] [+cmd] [N] Go to [N]th previous buffer in buffer list. [N] defaults to one. Wraps around the start of the buffer list. See |:buffer-!| for [!] and 'switchbuf'. + Also see ||+cmd|. -:[N]sbN[ext] [N] *:sbN* *:sbNext* *:sbp* *:sbprevious* -:[N]sbp[revious] [N] +:[N]sbN[ext] [+cmd] [N] *:sbN* *:sbNext* *:sbp* *:sbprevious* +:[N]sbp[revious] [+cmd] [N] Split window and go to [N]th previous buffer in buffer list. Wraps around the start of the buffer list. Uses 'switchbuf'. + Also see ||+cmd|. - *:br* *:brewind* -:br[ewind][!] Go to first buffer in buffer list. If the buffer list is +:br[ewind][!] [+cmd] *:br* *:brewind* + Go to first buffer in buffer list. If the buffer list is empty, go to the first unlisted buffer. See |:buffer-!| for [!]. - *:bf* *:bfirst* -:bf[irst] Same as ":brewind". +:bf[irst] [+cmd] *:bf* *:bfirst* + Same as |:brewind|. + Also see |+cmd|. - *:sbr* *:sbrewind* -:sbr[ewind] Split window and go to first buffer in buffer list. If the +:sbr[ewind] [+cmd] *:sbr* *:sbrewind* + Split window and go to first buffer in buffer list. If the buffer list is empty, go to the first unlisted buffer. Respects the 'switchbuf' option. + Also see |+cmd|. - *:sbf* *:sbfirst* -:sbf[irst] Same as ":sbrewind". +:sbf[irst] [+cmd] *:sbf* *:sbfirst* + Same as ":sbrewind". - *:bl* *:blast* -:bl[ast][!] Go to last buffer in buffer list. If the buffer list is +:bl[ast][!] [+cmd] *:bl* *:blast* + Go to last buffer in buffer list. If the buffer list is empty, go to the last unlisted buffer. See |:buffer-!| for [!]. - *:sbl* *:sblast* -:sbl[ast] Split window and go to last buffer in buffer list. If the +:sbl[ast] [+cmd] *:sbl* *:sblast* + Split window and go to last buffer in buffer list. If the buffer list is empty, go to the last unlisted buffer. Respects 'switchbuf' option. -:[N]bm[odified][!] [N] *:bm* *:bmodified* *E84* +:[N]bm[odified][!] [+cmd] [N] *:bm* *:bmodified* *E84* Go to [N]th next modified buffer. Note: this command also finds unlisted buffers. If there is no modified buffer the command fails. -:[N]sbm[odified] [N] *:sbm* *:sbmodified* +:[N]sbm[odified] [+cmd] [N] *:sbm* *:sbmodified* Split window and go to [N]th next modified buffer. Respects 'switchbuf' option. Note: this command also finds buffers not in the buffer list. diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 6e098dd5eb..f6b4793184 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -1,27 +1,26 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e +set -o pipefail NEOVIM_SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -VIM_SOURCE_DIR_DEFAULT=${NEOVIM_SOURCE_DIR}/build/vim +VIM_SOURCE_DIR_DEFAULT=${NEOVIM_SOURCE_DIR}/.vim-src VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}" if [[ ${#} != 1 ]]; then >&2 echo "Helper script for porting Vim patches. For more information," >&2 echo "see https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim." >&2 echo - >&2 echo "Usage: ${0} vim-version" - >&2 echo "vim-version must be in format '7.4.xxx'." + >&2 echo "Usage: ${0} vim-revision" + >&2 echo "vim-revision can be a version number in format '7.4.xxx'" + >&2 echo "or a Mercurial commit hash." >&2 echo >&2 echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored." >&2 echo "The default is '${VIM_SOURCE_DIR_DEFAULT}'." exit 1 fi -vim_version="${1}" -if [[ ! ${vim_version} =~ [0-9]\.[0-9]\.[0-9][0-9][0-9] ]]; then - >&2 echo "vim-version must be in format '7.4.xxx'." - exit 2 -fi - +echo "Retrieving Vim sources." if [[ ! -d ${VIM_SOURCE_DIR} ]]; then echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'." hg clone https://code.google.com/p/vim ${VIM_SOURCE_DIR} @@ -29,53 +28,93 @@ if [[ ! -d ${VIM_SOURCE_DIR} ]]; then else echo "Updating Vim sources in '${VIM_SOURCE_DIR}'." cd ${VIM_SOURCE_DIR} - hg pull --update || echo 'Could not update Vim sources.' + hg pull --update || echo "✘ Could not update Vim sources." fi -vim_tag="v${vim_version//./-}" -echo "Using Vim tag '${vim_tag}'." +if [[ "${1}" =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then + # Interpret parameter as version number. + vim_version="${1}" + vim_commit="v${1//./-}" + strip_commit_line=true +else + # Interpret parameter as commit hash. + vim_version="${1:0:7}" + vim_commit="${1}" + strip_commit_line=false +fi -hg log --rev ${vim_tag} >/dev/null 2>&1 || { - >&2 echo "Couldn't find Vim tag '${vim_tag}'." +hg log --rev ${vim_commit} >/dev/null 2>&1 || { + >&2 echo "✘ Couldn't find Vim revision '${vim_commit}'." exit 3 } - -vim_full="$(hg log --patch --git --verbose --rev ${vim_tag})" -vim_message="$(hg log --template "{desc}" --rev ${vim_tag} \ - | sed -e '1d')" # Remove first line of commit message. -vim_diff="$(hg diff --show-function --git --change ${vim_tag} \ +echo "✔ Found Vim revision '${vim_commit}'." + +# Collect patch details and store into variables. +vim_full="$(hg log --patch --git --verbose --rev ${vim_commit})" +vim_message="$(hg log --template "{desc}" --rev ${vim_commit})" +if [[ "${strip_commit_line}" == "true" ]]; then + # Remove first line of commit message. + vim_message="$(echo "${vim_message}" | sed -e '1d')" +fi +vim_diff="$(hg diff --show-function --git --change ${vim_commit} \ | sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim. +neovim_message=" +vim-patch:${vim_version} + +${vim_message} + +https://code.google.com/p/vim/source/detail?r=${vim_commit}" +neovim_pr=" +\`\`\` +${vim_message} +\`\`\` +https://code.google.com/p/vim/source/detail?r=${vim_commit} +Original patch: + +\`\`\`diff +${vim_diff} +\`\`\`" neovim_branch="vim-${vim_version}" + echo -echo "Creating Neovim branch '${neovim_branch}'." +echo "Creating Git branch." cd ${NEOVIM_SOURCE_DIR} -git checkout -b "${neovim_branch}" +echo -n "✘ " +# 'git checkout -b' writes to stderr in case of success :-( +# Re-add newline (stripped by echo -n) in error case. +git checkout -b "${neovim_branch}" 2>&1 | xargs echo -n || (echo; false) +echo -n "." # Add trailing dot. +echo -e "\r✔ " # Replace ✘ with ✔ echo -echo "Saving patch to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch'." -echo "${vim_diff}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch - -echo "Saving full commit details to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.commit'." -echo "${vim_full}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.commit +echo "Creating empty commit with correct commit message." +echo -n "✘ " +git commit --allow-empty --file - <<< "${neovim_message}" | xargs echo -n +echo -e "\r✔ " # Replace ✘ with ✔ echo -echo "Creating empty Neovim commit with correct commit message." -neovim_message=" -vim-patch:${vim_version} - -${vim_message} - -https://code.google.com/p/vim/source/detail?r=${vim_tag}" - -git commit --allow-empty --file - <<< "${neovim_message}" +echo "Creating files." +echo "${vim_diff}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff +echo "✔ Saved patch to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff'." +echo "${vim_full}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch +echo "✔ Saved full commit details to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch'." +echo "${neovim_pr}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr +echo "✔ Saved suggested PR description to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr'." +echo "You can use 'git clean' to remove these files when you're done." echo -echo "Proceed to port the patch and stage your changes ('git add ...')." -echo "Then use 'git commit --amend' to commit." -echo "Push your changes with 'git push origin ${neovim_branch}' and create a" -echo "pull request called '[RFC] vim-patch:${vim_version}'." +echo "Instructions:" +echo +echo " Proceed to port the patch." +echo " You might want to try 'patch -p1 < ${neovim_branch}.diff' first." +echo +echo " Stage your changes ('git add ...') and use 'git commit --amend' to commit." +echo +echo " Push your changes with 'git push origin ${neovim_branch}' and create a" +echo " pull request called '[RFC] vim-patch:${vim_version}'. You might want " +echo " to use the text in '${neovim_branch}.pr' as the description of this pull request." echo -echo "See https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim" -echo "for more information." +echo " See https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim" +echo " for more information." diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index d5d6d39616..c9dd974d11 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -127,12 +127,12 @@ return { }, { command='buffer', - flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, EDITCMD, TRLBAR), func='ex_buffer', }, { command='bNext', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { @@ -162,22 +162,22 @@ return { }, { command='bfirst', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_brewind', }, { command='blast', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_blast', }, { command='bmodified', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bmodified', }, { command='bnext', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bnext', }, { @@ -187,12 +187,12 @@ return { }, { command='bprevious', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='brewind', - flags=bit.bor(BANG, RANGE, NOTADR, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, EDITCMD, TRLBAR), func='ex_brewind', }, { @@ -1762,47 +1762,47 @@ return { }, { command='sbuffer', - flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR), + flags=bit.bor(BANG, RANGE, NOTADR, BUFNAME, BUFUNL, COUNT, EXTRA, EDITCMD, TRLBAR), func='ex_buffer', }, { command='sbNext', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='sball', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_buffer_all', }, { command='sbfirst', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_brewind', }, { command='sblast', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_blast', }, { command='sbmodified', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bmodified', }, { command='sbnext', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bnext', }, { command='sbprevious', - flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR), + flags=bit.bor(RANGE, NOTADR, COUNT, EDITCMD, TRLBAR), func='ex_bprevious', }, { command='sbrewind', - flags=bit.bor(TRLBAR), + flags=bit.bor(EDITCMD, TRLBAR), func='ex_brewind', }, { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 65d4b980b7..359c4b31d1 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3959,13 +3959,17 @@ static void ex_bunload(exarg_T *eap) */ static void ex_buffer(exarg_T *eap) { - if (*eap->arg) + if (*eap->arg) { eap->errmsg = e_trailing; - else { - if (eap->addr_count == 0) /* default is current buffer */ + } else { + if (eap->addr_count == 0) { // default is current buffer goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); - else + } else { goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); + } + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } } @@ -3976,6 +3980,9 @@ static void ex_buffer(exarg_T *eap) static void ex_bmodified(exarg_T *eap) { goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -3985,6 +3992,9 @@ static void ex_bmodified(exarg_T *eap) static void ex_bnext(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -3996,6 +4006,9 @@ static void ex_bnext(exarg_T *eap) static void ex_bprevious(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -4007,6 +4020,9 @@ static void ex_bprevious(exarg_T *eap) static void ex_brewind(exarg_T *eap) { goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } /* @@ -4016,6 +4032,9 @@ static void ex_brewind(exarg_T *eap) static void ex_blast(exarg_T *eap) { goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); + if (eap->do_ecmd_cmd != NULL) { + do_cmdline_cmd(eap->do_ecmd_cmd); + } } int ends_excmd(int c) FUNC_ATTR_CONST diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 39227cc199..d0eebf8fea 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3645,10 +3645,8 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL) { /* might have CSI escaped mp->m_keys */ q = vim_strsave(mp->m_keys); - if (q != NULL) { - vim_unescape_csi(q); - qlen = (int)STRLEN(q); - } + vim_unescape_csi(q); + qlen = (int)STRLEN(q); } /* find entries with right mode and keys */ match = (mp->m_mode & State) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 5f542eec0c..f53a780efe 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -606,9 +606,6 @@ EXTERN int exiting INIT(= FALSE); /* TRUE when planning to exit Vim. Might * still keep on running if there is a changed * buffer. */ -EXTERN int really_exiting INIT(= FALSE); -/* TRUE when we are sure to exit, e.g., after - * a deadly signal */ /* volatile because it is used in signal handler deathtrap(). */ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index fc848466c6..4f17f84e11 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -3329,32 +3329,35 @@ void prepare_to_exit(void) */ void preserve_exit(void) { + // 'true' when we are sure to exit, e.g., after a deadly signal + static bool really_exiting = false; + // Prevent repeated calls into this method. if (really_exiting) { exit(2); } - really_exiting = TRUE; + really_exiting = true; prepare_to_exit(); out_str(IObuff); - screen_start(); /* don't know where cursor is now */ + screen_start(); // don't know where cursor is now out_flush(); - ml_close_notmod(); /* close all not-modified buffers */ + ml_close_notmod(); // close all not-modified buffers FOR_ALL_BUFFERS(buf) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { OUT_STR("Vim: preserving files...\n"); - screen_start(); /* don't know where cursor is now */ + screen_start(); // don't know where cursor is now out_flush(); - ml_sync_all(FALSE, FALSE); /* preserve all swap files */ + ml_sync_all(false, false); // preserve all swap files break; } } - ml_close_all(FALSE); /* close all memfiles, without deleting */ + ml_close_all(false); // close all memfiles, without deleting OUT_STR("Vim: Finished.\n"); diff --git a/src/nvim/version.c b/src/nvim/version.c index 2c648eded6..7eb528f91c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -287,7 +287,7 @@ static int included_patches[] = { //453 NA 452, //451, - //450, + 450, 449, //448 NA 447, |