changeset 21350:ea31a050bdd8

Execute commands in startup.m at start for compatibility with Matlab. * NEWS: Announce new behavior. * basics.txi: Document file * version-rcfile: Add command to execute startup.m if it exists. Clean up formatting of file. * __finish__.m: Fix typo in docstring. Clean up comments to match version-rcfile. * site-rcfile: Clean up formatting.
author Rik <rik@octave.org>
date Thu, 25 Feb 2016 11:25:29 -0800
parents e5a63df8cf3a
children 1e0889a31c6a
files NEWS doc/interpreter/basics.txi scripts/startup/__finish__.m scripts/startup/site-rcfile scripts/startup/version-rcfile
diffstat 5 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Feb 25 10:44:09 2016 -0800
+++ b/NEWS	Thu Feb 25 11:25:29 2016 -0800
@@ -22,6 +22,11 @@
     "luminance profile" and is also more similar to Matlab's new default
     colormap "parula".
 
+ ** When starting, Octave now looks in the function path for a file
+    startup.m and executes any commands found there.  This change was made
+    to accommodate Matlab users.  Octave has it's own configuration
+    system based on the file .octaverc which is preferred.
+
  ** Octal ('\NNN') and hex ('\xNN') escape sequences in single quoted
     strings are now interpreted by the function do_string_escapes().
     The *printf family of functions now supports octal and hex escape
--- a/doc/interpreter/basics.txi	Thu Feb 25 10:44:09 2016 -0800
+++ b/doc/interpreter/basics.txi	Thu Feb 25 11:25:29 2016 -0800
@@ -374,6 +374,11 @@
 
 If you start Octave in your home directory, commands from the file
 @file{~/.octaverc} will only be executed once.
+
+@item startup.m
+This file is used to make personal changes to the default
+Octave environment.  It is executed for @sc{matlab} compatibility, but
+@file{~/.octaverc} is the preferred location for configuration changes.
 @end table
 
 A message will be displayed as each of the startup files is read if you
--- a/scripts/startup/__finish__.m	Thu Feb 25 10:44:09 2016 -0800
+++ b/scripts/startup/__finish__.m	Thu Feb 25 11:25:29 2016 -0800
@@ -21,7 +21,7 @@
 ## Check for the existence of the function/script, @file{finish}, in the
 ## path or current working directory and execute it.
 ##
-## This function is intended to be excecuted upon a clean exit from Octave.
+## This function is intended to be executed upon a clean exit from Octave.
 ## This is accomplished in the system script @file{startup/octaverc} by use of
 ## the built-in function @code{atexit}.
 ## @seealso{atexit}
@@ -31,8 +31,7 @@
 ## still in the base workspace with access to all user variables.
 
 if (exist ("finish", "file"))
-  ## No arg list here since finish might be a script.
-  finish;
+  finish;  # No arg list here since finish might be a script.
 endif
 
 
--- a/scripts/startup/site-rcfile	Thu Feb 25 10:44:09 2016 -0800
+++ b/scripts/startup/site-rcfile	Thu Feb 25 11:25:29 2016 -0800
@@ -3,5 +3,5 @@
 ## If the environment variable OCTAVE_SITE_INITFILE is set when Octave
 ## starts, then that file is executed instead of this file.
 ##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
+## This file contain commands that should be executed each time Octave starts
+## for every user at this site.
--- a/scripts/startup/version-rcfile	Thu Feb 25 10:44:09 2016 -0800
+++ b/scripts/startup/version-rcfile	Thu Feb 25 11:25:29 2016 -0800
@@ -3,23 +3,28 @@
 ## If the environment variable OCTAVE_VERSION_INITFILE is set when Octave
 ## starts, then that file is executed instead of this file.
 ##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
+## This file contains commands that should be executed each time Octave starts
+## for every user at this site.
 
-## Configure readline using the file inputrc in the Octave startup
-## directory.
-
+## Configure readline using the file inputrc in the Octave startup directory.
 readline_read_init_file (sprintf ("%s%s%s",
                                   octave_config_info ("startupfiledir"),
                                   filesep, "inputrc"));
 
+## Configure LESS pager if present
 if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
   PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
 endif
 
 ## This appears here instead of in the pkg/PKG_ADD file so that --norc
 ## will also skip automatic loading of packages.
-
 pkg ("load", "auto");
 
+## For Matlab compatibility, run startup.m when starting Octave.
+if (exist ("startup", "file))
+  startup;  # No arg list here since startup might be a script.
+endif
+
+## For Matlab compatibility, schedule finish.m to run when exiting Octave.
 atexit ("__finish__");
+