Hi,

I wanted less.vim and less.sh to behave more like 'less'.
The attached patch changes the following behavior:

1. Do not quit Vim automatically at the end of file. (less.vim)
   'more' quits at the end of file, but 'less' does not.

2. Do not wait the input of user, if no arguments were given
   and stdin was not redirected. (less.sh)
   If there is nothing to show, just show an error message and quit.

3. Add a batch file for Windows users. (less.bat)
   This is an alternative of less.sh.

Thanks.
--
Ken Takata

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 8201108e9cf0 runtime/macros/less.bat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runtime/macros/less.bat	Thu May 10 22:46:56 2012 +0900
@@ -0,0 +1,9 @@
+@echo off
+rem batch file to start Vim with less.vim.
+rem Read stdin if no arguments were given.
+
+if "%1"=="" (
+  vim --cmd "let no_plugin_maps = 1" -c "runtime! macros/less.vim" -
+) else (
+  vim --cmd "let no_plugin_maps = 1" -c "runtime! macros/less.vim" %*
+)
diff -r 8201108e9cf0 runtime/macros/less.sh
--- a/runtime/macros/less.sh	Tue May 01 21:14:34 2012 +0200
+++ b/runtime/macros/less.sh	Thu May 10 22:46:56 2012 +0900
@@ -1,16 +1,24 @@
 #!/bin/sh
 # Shell script to start Vim with less.vim.
-# Read stdin if no arguments were given.
+# Read stdin if no arguments were given and stdin was redirected.
 
 if test -t 1; then
- if test $# = 0; then
-   vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' -
+  if test $# = 0; then
+    if test -t 0; then
+      echo "Missing filename" 1>&2
+      exit
+    fi
+    vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' -
   else
-   vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$@"
+    vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$@"
   fi
 else
   # Output is not a terminal, cat arguments or stdin
   if test $# = 0; then
+    if test -t 0; then
+      echo "Missing filename" 1>&2
+      exit
+    fi
     cat
   else
     cat "$@"
diff -r 8201108e9cf0 runtime/macros/less.vim
--- a/runtime/macros/less.vim	Tue May 01 21:14:34 2012 +0200
+++ b/runtime/macros/less.vim	Thu May 10 22:46:56 2012 +0900
@@ -92,7 +92,8 @@
 fun! s:NextPage()
   if line(".") == line("$")
     if argidx() + 1 >= argc()
-      quit
+      " Don't quit at the end of the last file
+      return
     endif
     next
     1

Raspunde prin e-mail lui