# HG changeset patch # User jwe # Date 1162932739 0 # Node ID e8868fde0fc5ce0d99ffea041de31d1c8bb4b44b # Parent 47f0cab13a0275ffa30cf692ee21507a77bfbb69 [project @ 2006-11-07 20:52:18 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2006-11-07 John W. Eaton + + * startup/main-rcfile: Conditionally set PAGER_FLAGS. + 2006-11-06 Søren Hauberg * pkg/pkg.m (extract_pkg): No need to pass "dotexceptnewline" diff --git a/scripts/startup/main-rcfile b/scripts/startup/main-rcfile --- a/scripts/startup/main-rcfile +++ b/scripts/startup/main-rcfile @@ -9,3 +9,7 @@ read_readline_init_file (sprintf ("%s%s%s", octave_config_info ("startupfiledir"), filesep, "inputrc")); + +if (strcmp (PAGER (), "less") && isempty (getenv ("LESS"))) + PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"'); +endif diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2006-11-07 John W. Eaton + + * utils.cc (file_in_path): Don't unconditionally return "". + + * pager.cc (default_pager): Don't append options here. + (pager_command): New function. + (do_sync): Use it. + (VPAGER_FLAGS): New variable. + (FPAGER_FLAGS): New function. + 2006-11-06 John W. Eaton * oct-hist.cc (default_history_file): If env_file is not empty, diff --git a/src/pager.cc b/src/pager.cc --- a/src/pager.cc +++ b/src/pager.cc @@ -64,19 +64,7 @@ #ifdef OCTAVE_DEFAULT_PAGER if (pager_binary.empty ()) - { - pager_binary = std::string (OCTAVE_DEFAULT_PAGER); - - if (pager_binary == "less") - { - pager_binary.append (" -e"); - - std::string lessflags = octave_env::getenv ("LESS"); - if (lessflags.empty ()) - pager_binary.append - (" -X -P'-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$'"); - } - } + pager_binary = OCTAVE_DEFAULT_PAGER; #endif return pager_binary; @@ -85,6 +73,9 @@ // The shell command to run as the pager. static std::string VPAGER = default_pager (); +// The options to pass to the pager. +static std::string VPAGER_FLAGS; + // TRUE means that if output is going to the pager, it is sent as soon // as it is available. Otherwise, it is buffered and only sent to the // pager when it is time to print another prompt. @@ -137,6 +128,17 @@ return retval; } +static std::string +pager_command (void) +{ + std::string cmd = VPAGER; + + if (! (cmd.empty () || VPAGER_FLAGS.empty ())) + cmd += " " + VPAGER_FLAGS; + + return cmd; +} + static void do_sync (const char *msg, int len, bool bypass_pager) { @@ -151,7 +153,7 @@ { if (! external_pager) { - std::string pgr = VPAGER; + std::string pgr = pager_command (); if (! pgr.empty ()) { @@ -576,12 +578,24 @@ normally @code{\"less\"}, @code{\"more\"}, or\n\ @code{\"pg\"}, depending on what programs are installed on your system.\n\ @xref{Installation}.\n\ -@seealso{page_screen_output, page_output_immediately}\n\ +@seealso{more, page_screen_output, page_output_immediately, PAGER_FLAGS}\n\ @end deftypefn") { return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER); } +DEFUN (PAGER_FLAGS, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {@var{val} =} PAGER_FLAGS ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} PAGER_FLAGS (@var{new_val})\n\ +Query or set the internal variable that specifies the options to pass\n\ +to the pager.\n\ +@seealso{PAGER}\n\ +@end deftypefn") +{ + return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER_FLAGS); +} + /* ;;; Local Variables: *** ;;; mode: C++ *** diff --git a/src/utils.cc b/src/utils.cc --- a/src/utils.cc +++ b/src/utils.cc @@ -399,8 +399,6 @@ if (! suffix.empty ()) nm.append (suffix); - return std::string (); - return octave_env::make_absolute (load_path::find_file (nm), octave_env::getcwd ()); }