From a90beeadbb5dfbe443eae3c057c79a9cefa47ad6 Mon Sep 17 00:00:00 2001
From: "Justin M. Keyes" <justinkz@gmail.com>
Date: Fri, 10 Feb 2017 03:39:00 +0100
Subject: [PATCH 1/2] defaults: 'showcmd', 'belloff', 'ruler'

- Vim "unix default" of 'noshowcmd' is serving few users. And it's
  inconsistent.
- 'ruler' and 'belloff=all' improve the out-of-the-box experience.
- Continue to use 'noshowcmd' and 'noruler' by default in the functional
  tests to keep them fast.

TODO: Add a "disable slow stuff" command or mapping to address the
use-case of a very slow terminal connection.
---
 runtime/doc/options.txt                   | 25 ++++++-----------------
 runtime/doc/vim_diff.txt                  |  3 +++
 src/nvim/options.lua                      | 10 +++------
 src/nvim/testdir/setup.vim                |  4 ++++
 test/functional/ex_cmds/oldfiles_spec.lua | 12 ++++-------
 test/functional/helpers.lua               |  8 ++++++--
 test/functional/options/defaults_spec.lua |  4 +---
 test/functional/plugin/helpers.lua        |  6 +++---
 test/functional/terminal/api_spec.lua     |  8 ++++----
 test/functional/terminal/tui_spec.lua     | 11 ++++++----
 test/functional/ui/output_spec.lua        |  6 +++---
 test/functional/ui/screen_basic_spec.lua  |  2 +-
 12 files changed, 45 insertions(+), 54 deletions(-)

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index e28e4e59a8..23d8287a2c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -979,7 +979,7 @@ A jump table for the options with a short description can be found at |Q_op|.
 'balloonexpr' 'bexpr'	Removed. {Nvim}
 
 						*'belloff'* *'bo'*
-'belloff' 'bo'		string	(default "")
+'belloff' 'bo'		string	(default "all")
 			global
 	Specifies for which events the bell will not be rung. It is a comma
 	separated list of items. For each item that is present, the bell
@@ -2186,9 +2186,8 @@ A jump table for the options with a short description can be found at |Q_op|.
 	Ring the bell (beep or screen flash) for error messages.  This only
 	makes a difference for error messages, the bell will be used always
 	for a lot of errors without a message (e.g., hitting <Esc> in Normal
-	mode).  See 'visualbell' on how to make the bell behave like a beep,
-	screen flash or do nothing. See 'belloff' to finetune when to ring the
-	bell.
+	mode).  See 'visualbell' to make the bell behave like a screen flash
+	or do nothing. See 'belloff' to finetune when to ring the bell.
 
 						*'errorfile'* *'ef'*
 'errorfile' 'ef'	string	(default: "errors.err")
@@ -4822,10 +4821,8 @@ A jump table for the options with a short description can be found at |Q_op|.
 	The 'rightleft' option must be set for 'rightleftcmd' to take effect.
 
 					 *'ruler'* *'ru'* *'noruler'* *'noru'*
-'ruler' 'ru'		boolean	(default off)
+'ruler' 'ru'		boolean	(default on)
 			global
-			{not available when compiled without the
-			|+cmdline_info| feature}
 	Show the line and column number of the cursor position, separated by a
 	comma.  When there is room, the relative position of the displayed
 	text in the file is shown on the far right:
@@ -5530,11 +5527,8 @@ A jump table for the options with a short description can be found at |Q_op|.
 	"n" flag to 'cpoptions'.
 
 				     *'showcmd'* *'sc'* *'noshowcmd'* *'nosc'*
-'showcmd' 'sc'		boolean	(Vim default: on (off for Unix),
-				 Vi default: off)
+'showcmd' 'sc'		boolean	(Vim default: on, Vi default: off)
 			global
-			{not available when compiled without the
-			|+cmdline_info| feature}
 	Show (partial) command in the last line of the screen.  Set this
 	option off if your terminal is slow.
 	In Visual mode the size of the selected area is shown:
@@ -6709,14 +6703,7 @@ A jump table for the options with a short description can be found at |Q_op|.
 			*'visualbell'* *'vb'* *'novisualbell'* *'novb'* *beep*
 'visualbell' 'vb'	boolean	(default off)
 			global
-	Use visual bell instead of beeping.  The terminal code to display the
-	visual bell is given with 't_vb'.  When no beep or flash is wanted,
-	use ":set vb t_vb=".
-	Note: When the GUI starts, 't_vb' is reset to its default value.  You
-	might want to set it again in your |gvimrc|.
-	In the GUI, 't_vb' defaults to "<Esc>|f", which inverts the display
-	for 20 msec.  If you want to use a different time, use "<Esc>|40f",
-	where 40 is the time in msec.  Also see 'errorbells'.
+	Use visual bell instead of beeping.  Also see 'errorbells'.
 
 						*'warn'* *'nowarn'*
 'warn'			boolean	(default on)
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 14bb934607..d7d31b5853 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -37,6 +37,7 @@ these differences.
 - 'autoread' is set by default
 - 'backspace' defaults to "indent,eol,start"
 - 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|)
+- 'belloff' defaults to "all"
 - 'complete' doesn't include "i"
 - 'directory' defaults to ~/.local/share/nvim/swap// (|xdg|), auto-created
 - 'display' defaults to "lastline"
@@ -49,7 +50,9 @@ these differences.
 - 'listchars' defaults to "tab:> ,trail:-,nbsp:+"
 - 'nocompatible' is always set
 - 'nrformats' defaults to "bin,hex"
+- 'ruler' is set by default
 - 'sessionoptions' doesn't include "options"
+- 'showcmd' is set by default
 - 'smarttab' is set by default
 - 'tabpagemax' defaults to 50
 - 'tags' defaults to "./tags;,tags"
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index e12860c0cc..1476fdda2c 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -190,7 +190,7 @@ return {
       type='string', list='comma', scope={'global'},
       vi_def=true,
       varname='p_bo',
-      defaults={if_true={vi=""}}
+      defaults={if_true={vi="all"}}
     },
     {
       full_name='binary', abbreviation='bin',
@@ -1883,7 +1883,7 @@ return {
       vim=true,
       redraw={'statuslines'},
       varname='p_ru',
-      defaults={if_true={vi=false}}
+      defaults={if_true={vi=true}}
     },
     {
       full_name='rulerformat', abbreviation='ruf',
@@ -2119,11 +2119,7 @@ return {
       type='bool', scope={'global'},
       vim=true,
       varname='p_sc',
-      defaults={
-        condition='UNIX',
-        if_true={vi=false, vim=false},
-        if_false={vi=false, vim=true},
-      }
+      defaults={if_true={vi=false, vim=true}}
     },
     {
       full_name='showfulltag', abbreviation='sft',
diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim
index 52876d1e6c..05257d566d 100644
--- a/src/nvim/testdir/setup.vim
+++ b/src/nvim/testdir/setup.vim
@@ -1,5 +1,9 @@
 " Common preparations for running tests.
 
+set noruler
+set noshowcmd
+set belloff=
+
 " Make sure 'runtimepath' does not include $HOME.
 set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
 
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index a218bb6633..a161e49fc6 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -7,14 +7,10 @@ local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
 
 local shada_file = 'test.shada'
 
---
--- helpers.clear() uses "-i NONE", which is not useful for this test.
---
 local function _clear()
-  set_session(spawn({nvim_prog,
-                     '-u', 'NONE',
-                     '--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.',
-                     '--embed'}))
+  set_session(spawn({nvim_prog, '--embed', '-u', 'NONE', '--cmd',
+                     -- Need shada for these tests.
+                     'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}))
 end
 
 describe(':oldfiles', function()
@@ -63,7 +59,7 @@ describe(':browse oldfiles', function()
     _clear()
     execute('rshada! ' .. shada_file)
 
-    -- Ensure nvim is out of "Press ENTER..." screen
+    -- Ensure nvim is out of "Press ENTER..." prompt.
     feed('<cr>')
 
     -- Ensure v:oldfiles isn't busted.  Since things happen so fast,
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 44fff0e9a7..13a0cff137 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -20,9 +20,12 @@ local filter = global_helpers.filter
 local start_dir = lfs.currentdir()
 -- XXX: NVIM_PROG takes precedence, QuickBuild sets it.
 local nvim_prog = os.getenv('NVIM_PROG') or os.getenv('NVIM_PRG') or 'build/bin/nvim'
+-- Default settings for the test session.
+local nvim_set  = 'set shortmess+=I background=light noswapfile noautoindent'
+                  ..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
+                  ..' belloff= noshowcmd noruler'
 local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
-                   '--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.',
-                   '--embed'}
+                   '--cmd', nvim_set, '--embed'}
 
 local mpack = require('mpack')
 
@@ -597,6 +600,7 @@ local M = {
   nvim = nvim,
   nvim_async = nvim_async,
   nvim_prog = nvim_prog,
+  nvim_set = nvim_set,
   nvim_dir = nvim_dir,
   buffer = buffer,
   window = window,
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index f3328886b5..f57fe5fa23 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -11,9 +11,7 @@ local neq = helpers.neq
 
 local function init_session(...)
   local args = { helpers.nvim_prog, '-i', 'NONE', '--embed',
-    '--cmd', 'set shortmess+=I background=light noswapfile noautoindent',
-    '--cmd', 'set laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
-    }
+                 '--cmd', helpers.nvim_set }
   for _, v in ipairs({...}) do
     table.insert(args, v)
   end
diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua
index 7580670149..2024e6ebbf 100644
--- a/test/functional/plugin/helpers.lua
+++ b/test/functional/plugin/helpers.lua
@@ -10,7 +10,7 @@ local function nvim_argv(shada_file)
   local rtp_value = ('\'%s/runtime\''):format(
       paths.test_source_path:gsub('\'', '\'\''))
   local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
-                     '--cmd', 'set shortmess+=I background=light noswapfile',
+                     '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
                      '--cmd', 'let &runtimepath=' .. rtp_value,
                      '--cmd', additional_cmd,
                      '--embed'}
@@ -23,7 +23,7 @@ end
 
 local session = nil
 
-local reset = function(...)
+local function reset(...)
   if session then
     session:close()
   end
@@ -31,7 +31,7 @@ local reset = function(...)
   set_session(session)
 end
 
-local set_additional_cmd = function(s)
+local function set_additional_cmd(s)
   additional_cmd = s
 end
 
diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua
index 045bdb0749..e28cc03597 100644
--- a/test/functional/terminal/api_spec.lua
+++ b/test/functional/terminal/api_spec.lua
@@ -12,7 +12,7 @@ describe('api', function()
     helpers.clear()
     os.remove(socket_name)
     screen = child_session.screen_setup(0, '["'..helpers.nvim_prog
-      ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+      ..'", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]')
   end)
   after_each(function()
     os.remove(socket_name)
@@ -28,7 +28,7 @@ describe('api', function()
       {4:~                                                 }|
       {4:~                                                 }|
       {4:~                                                 }|
-      {5:[No Name]                                         }|
+      {4:~                                                 }|
       ]]..socket_name..[[                         |
       {3:-- TERMINAL --}                                    |
     ]])
@@ -43,7 +43,7 @@ describe('api', function()
       {4:~                                                 }|
       {4:~                                                 }|
       {4:~                                                 }|
-      {5:[No Name] [+]                                     }|
+      {4:~                                                 }|
       {3:-- INSERT --}                                      |
       {3:-- TERMINAL --}                                    |
     ]])
@@ -59,7 +59,7 @@ describe('api', function()
       [socket 1] this is more t{4:                         }|
       han 25 columns           {4:                         }|
       [socket 2] input{1: }        {4:                         }|
-      {5:[No Name] [+]                                     }|
+      {4:~                                                 }|
       {3:-- INSERT --}                                      |
       {3:-- TERMINAL --}                                    |
     ]])
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 60f989d701..0e5c437c28 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -13,7 +13,8 @@ describe('tui', function()
 
   before_each(function()
     helpers.clear()
-    screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+    screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
+      ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
     -- right now pasting can be really slow in the TUI, especially in ASAN.
     -- this will be fixed later but for now we require a high timeout.
     screen.timeout = 60000
@@ -177,7 +178,8 @@ describe('tui with non-tty file descriptors', function()
   end)
 
   it('can handle pipes as stdout and stderr', function()
-    local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog..' -u NONE -i NONE --cmd \'set noswapfile\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
+    local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog
+      ..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
     feed(':w testF\n:q\n')
     screen:expect([[
       :w testF                                          |
@@ -196,7 +198,8 @@ describe('tui focus event handling', function()
 
   before_each(function()
     helpers.clear()
-    screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+    screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
+      ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
     execute('autocmd FocusGained * echo "gained"')
     execute('autocmd FocusLost * echo "lost"')
   end)
@@ -313,7 +316,7 @@ describe("tui 't_Co' (terminal colors)", function()
     -- This is ugly because :term/termopen() forces TERM=xterm-256color.
     -- TODO: Revisit this after jobstart/termopen accept `env` dict.
     screen = thelpers.screen_setup(0, string.format(
-      [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=],
+      [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile noshowcmd noruler"']]=],
       term,
       (colorterm ~= nil and "COLORTERM="..colorterm or ""),
       helpers.nvim_prog))
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 33086a61b1..c6d564e8dc 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -8,13 +8,13 @@ describe("shell command :!", function()
   before_each(function()
     session.clear()
     screen = child_session.screen_setup(0, '["'..session.nvim_prog..
-      '", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+      '", "-u", "NONE", "-i", "NONE", "--cmd", "'..session.nvim_set..'"]')
     screen:expect([[
       {1: }                                                 |
       {4:~                                                 }|
       {4:~                                                 }|
       {4:~                                                 }|
-      {5:[No Name]                                         }|
+      {4:~                                                 }|
                                                         |
       {3:-- TERMINAL --}                                    |
     ]])
@@ -32,7 +32,7 @@ describe("shell command :!", function()
     screen:expect([[
       {4:~                                                 }|
       {4:~                                                 }|
-      {5:[No Name]                                         }|
+      {4:~                                                 }|
       :!printf foo; sleep 200                           |
                                                         |
       foo                                               |
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 0824585717..e511234e5e 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -9,7 +9,7 @@ local eval = helpers.eval
 describe('Initial screen', function()
   local screen
   local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
-                     '--cmd', 'set shortmess+=I background=light noswapfile',
+                     '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
                      '--embed'}
 
   before_each(function()

From 1dbe7a4decdd7e93153c0c3cb81197531b719b81 Mon Sep 17 00:00:00 2001
From: "Justin M. Keyes" <justinkz@gmail.com>
Date: Thu, 16 Mar 2017 18:43:44 +0100
Subject: [PATCH 2/2] doc: handle_* function declarations

---
 src/nvim/api/private/handle.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/nvim/api/private/handle.h b/src/nvim/api/private/handle.h
index 30bbfbee1b..26e9dc3314 100644
--- a/src/nvim/api/private/handle.h
+++ b/src/nvim/api/private/handle.h
@@ -10,8 +10,11 @@
   void handle_register_##name(type *name); \
   void handle_unregister_##name(type *name);
 
+// handle_get_buffer handle_register_buffer, handle_unregister_buffer
 HANDLE_DECLS(buf_T, buffer)
+// handle_get_window handle_register_window, handle_unregister_window
 HANDLE_DECLS(win_T, window)
+// handle_get_tabpage handle_register_tabpage, handle_unregister_tabpage
 HANDLE_DECLS(tabpage_T, tabpage)
 
 void handle_init(void);