Index: main.c
--- main.c.orig	2009-03-30 21:45:52 +0200
+++ main.c	2009-04-12 18:34:20 +0200
@@ -57,6 +57,7 @@
 
 extern int	missing_cap;
 extern int	know_dumb;
+extern int	no_init;
 extern int	quit_if_one_screen;
 extern int	pr_type;
 
@@ -158,6 +159,8 @@
 		quit(QUIT_OK);
 	}
 
+	if (less_is_more)
+		no_init = TRUE;
 	if (less_is_more && get_quit_at_eof())
 		quit_if_one_screen = TRUE;
 
@@ -171,7 +174,7 @@
 	}
 	editproto = lgetenv("LESSEDIT");
 	if (editproto == NULL || *editproto == '\0')
-		editproto = "%E ?lm+%lm. %f";
+		editproto = "%E ?lm+%lm. '%f'";
 #endif
 
 	/*

=============================================================================

The following patch changes the order in which "less" tries to find
workable terminal libraries. By default it prefers curses and especially
ncurses. That is fine in general, because ncurses is superior in
features and stability to mostly all terminal libraries. Unfortunately,
ncurses _always_ renders on a new blank and second screen and so cannot
be used for "ls -l | less -E -r" or similar commands on an xterm where
the input to display is less than a terminal height (because in this
case the screen will flicker once and then you're back at your shell
prompt without seeing the contents). On the other hand, less does not
need such a sophisticated terminal library, so allow it to prefer
termlib or termcap before the curses variants. As a side-effect we can
remove the ncurses dependency from the package, too. -- rse

Index: configure.ac
--- configure.ac.orig	2008-05-29 18:47:11 +0200
+++ configure.ac	2009-04-12 18:34:20 +0200
@@ -53,10 +53,10 @@
 
 if test $curses_broken = 0; then
 
-# -- Try tinfo.
+# -- Try termcap.
 if test "x$TERMLIBS" = x; then
-  if test $have_tinfo = yes; then
-    TERMLIBS="-ltinfo"
+  if test $have_termcap = yes; then
+    TERMLIBS="-ltermcap"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -66,10 +66,10 @@
   fi
 fi
 
-# -- Try xcurses.
+# -- Try termlib.
 if test "x$TERMLIBS" = x; then
-  if test $have_xcurses = yes; then
-    TERMLIBS="-lxcurses"
+  if test $have_termlib = yes; then
+    TERMLIBS="-lcurses -ltermlib"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -79,10 +79,10 @@
   fi
 fi
 
-# -- Try ncursesw.
+# -- Try tinfo.
 if test "x$TERMLIBS" = x; then
-  if test $have_ncursesw = yes; then
-    TERMLIBS="-lncursesw"
+  if test $have_tinfo = yes; then
+    TERMLIBS="-ltinfo"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -92,10 +92,10 @@
   fi
 fi
 
-# -- Try ncurses.
+# -- Try ncursesw.
 if test "x$TERMLIBS" = x; then
-  if test $have_ncurses = yes; then
-    TERMLIBS="-lncurses"
+  if test $have_ncursesw = yes; then
+    TERMLIBS="-lncursesw"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -105,10 +105,10 @@
   fi
 fi
 
-# -- Try curses.
+# -- Try ncurses.
 if test "x$TERMLIBS" = x; then
-  if test $have_curses = yes; then
-    TERMLIBS="-lcurses"
+  if test $have_ncurses = yes; then
+    TERMLIBS="-lncurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -132,12 +132,11 @@
   fi
   fi
 fi
-fi
 
-# -- Try termcap.
+# -- Try curses.
 if test "x$TERMLIBS" = x; then
-  if test $have_termcap = yes; then
-    TERMLIBS="-ltermcap"
+  if test $have_curses = yes; then
+    TERMLIBS="-lcurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -147,10 +146,10 @@
   fi
 fi
 
-# -- Try termlib.
+# -- Try xcurses.
 if test "x$TERMLIBS" = x; then
-  if test $have_termlib = yes; then
-    TERMLIBS="-lcurses -ltermlib"
+  if test $have_xcurses = yes; then
+    TERMLIBS="-lxcurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
@@ -160,6 +159,8 @@
   fi
 fi
 
+fi
+
 if test "x$TERMLIBS" = x; then
   AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
   exit 1
Index: configure
--- configure.orig	2009-03-09 07:54:40 +0100
+++ configure	2009-04-12 18:34:20 +0200
@@ -4466,10 +4466,10 @@
 
 if test $curses_broken = 0; then
 
-# -- Try tinfo.
+# -- Try termcap.
 if test "x$TERMLIBS" = x; then
-  if test $have_tinfo = yes; then
-    TERMLIBS="-ltinfo"
+  if test $have_termcap = yes; then
+    TERMLIBS="-ltermcap"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4524,10 +4524,10 @@
   fi
 fi
 
-# -- Try xcurses.
+# -- Try termlib.
 if test "x$TERMLIBS" = x; then
-  if test $have_xcurses = yes; then
-    TERMLIBS="-lxcurses"
+  if test $have_termlib = yes; then
+    TERMLIBS="-lcurses -ltermlib"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4582,10 +4582,10 @@
   fi
 fi
 
-# -- Try ncursesw.
+# -- Try tinfo.
 if test "x$TERMLIBS" = x; then
-  if test $have_ncursesw = yes; then
-    TERMLIBS="-lncursesw"
+  if test $have_tinfo = yes; then
+    TERMLIBS="-ltinfo"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4640,10 +4640,10 @@
   fi
 fi
 
-# -- Try ncurses.
+# -- Try ncursesw.
 if test "x$TERMLIBS" = x; then
-  if test $have_ncurses = yes; then
-    TERMLIBS="-lncurses"
+  if test $have_ncursesw = yes; then
+    TERMLIBS="-lncursesw"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4698,10 +4698,10 @@
   fi
 fi
 
-# -- Try curses.
+# -- Try ncurses.
 if test "x$TERMLIBS" = x; then
-  if test $have_curses = yes; then
-    TERMLIBS="-lcurses"
+  if test $have_ncurses = yes; then
+    TERMLIBS="-lncurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4815,12 +4815,11 @@
   fi
   fi
 fi
-fi
 
-# -- Try termcap.
+# -- Try curses.
 if test "x$TERMLIBS" = x; then
-  if test $have_termcap = yes; then
-    TERMLIBS="-ltermcap"
+  if test $have_curses = yes; then
+    TERMLIBS="-lcurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4875,10 +4874,10 @@
   fi
 fi
 
-# -- Try termlib.
+# -- Try xcurses.
 if test "x$TERMLIBS" = x; then
-  if test $have_termlib = yes; then
-    TERMLIBS="-lcurses -ltermlib"
+  if test $have_xcurses = yes; then
+    TERMLIBS="-lxcurses"
     SAVE_LIBS=$LIBS
     LIBS="$LIBS $TERMLIBS"
     cat >conftest.$ac_ext <<_ACEOF
@@ -4933,6 +4932,8 @@
   fi
 fi
 
+fi
+
 if test "x$TERMLIBS" = x; then
   { $as_echo "$as_me:$LINENO: result: Cannot find terminal libraries - configure failed" >&5
 $as_echo "Cannot find terminal libraries - configure failed" >&6; }
