changeset 4208:e96f52432059

[project @ 2002-12-03 19:48:57 by jwe]
author jwe
date Tue, 03 Dec 2002 19:48:57 +0000
parents fa3482b34599
children af97dc493a2c
files src/ChangeLog src/debug.cc src/defun-int.h src/defun.cc src/defun.h src/dirfns.cc src/help.cc src/input.cc src/lex.l src/load-save.cc src/oct-hist.cc src/pager.cc src/pr-output.cc src/pt-plot.cc src/symtab.cc src/symtab.h src/sysdep.cc src/toplev.cc src/variables.cc src/variables.h
diffstat 20 files changed, 162 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/ChangeLog	Tue Dec 03 19:48:57 2002 +0000
@@ -1,5 +1,33 @@
 2002-12-03  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* defun.h (DEFCMD): Rename from DEFUN_TEXT.  Provide DEFUN_TEXT as
+	an alias for DEFCMD.  Change all uses.
+
+	* variables.cc (at_top_level): New function.
+	(do_who, Fmark_as_command, Funmark_command): Use it.
+
+	* lex.l (COMMAND_START): Rename from TEXT_FCN.  Change all uses.
+	(MATRIX_START): Rename from MATRIX.  Change all uses.
+	* variables.cc (command_function_set): Rename from
+	text_function_set.
+	(mark_as_command): Rename from mark_as_text_function.
+	(is_marked_as_command): Rename from is_marked_as_text_function.
+	(Fmark_as_command): Rename from Fmark_as_text_function.
+	(Funmark_command): Rename from Funmark_text_function.
+	(is_command_name): Rename from is_text_function_name.
+	* symtab.h (symbol_record::COMMAND): Rename from TEXT_FUNCTION.
+	(symbol_record::mark_as_command): Rename from mark_as_text_function.
+	(symbol_record::unmark_command): Rename from
+	symbol_record::unmark_text_function.
+	(symbol_record::is_command): Rename from
+	symbol_record::is_text_function.
+	(symbol_record::symbol_def::mark_as_command): Rename from
+	symbol_record::symbol_def::mark_as_text_function.
+	(symbol_record::symbol_def::unmark_command): Rename from
+	symbol_record::symbol_def::unmark_text_function.
+	(symbol_record::symbol_def::is_command): Rename from
+	symbol_record::symbol_def::is_text_function.
+
 	* pt-jump.h, pt-jump.cc: Undo previous changes.
 	* parse.y: Undo previous changes for brea, continue, and return.
 
--- a/src/debug.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/debug.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -80,7 +80,7 @@
 }
 
 
-DEFUN_TEXT (dbstop, args, ,
+DEFCMD (dbstop, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {rline =} dbstop (func, line)\n\
 Set a breakpoint in a function\n\
@@ -149,7 +149,7 @@
   return retval;
 }
 
-DEFUN_TEXT (dbclear, args, ,
+DEFCMD (dbclear, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {} dbclear (func, line)\n\
 Delete a breakpoint in a function\n\
@@ -214,7 +214,7 @@
   return retval;
 }
 
-DEFUN_TEXT (dbstatus, args, ,
+DEFCMD (dbstatus, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {lst =} dbstatus ([func])\n\
 Return a vector containing the lines on which a function has \n\
@@ -273,7 +273,7 @@
   return retval;
 }
 
-DEFUN_TEXT (dbwhere, , ,
+DEFCMD (dbwhere, , ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {} dbwhere ()\n\
 Show where we are in the code\n\
@@ -348,7 +348,7 @@
 
 }
 
-DEFUN_TEXT (dbtype, args, ,
+DEFCMD (dbtype, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {} dbtype ()\n\
 List script file with line numbers.\n\
--- a/src/defun-int.h	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/defun-int.h	Tue Dec 03 19:48:57 2002 +0000
@@ -100,7 +100,7 @@
 
 // Generate code to install name in the symbol table.  The script
 // mkdefs will create a .def file for every .cc file that uses DEFUN,
-// or DEFUN_TEXT.
+// or DEFCMD.
 
 #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \
   BEGIN_INSTALL_BUILTIN \
--- a/src/defun.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/defun.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -104,7 +104,7 @@
   unsigned int t = symbol_record::BUILTIN_FUNCTION;
 
   if (is_text_fcn)
-    t |= symbol_record::TEXT_FUNCTION;
+    t |= symbol_record::COMMAND;
 
   sym_rec->unprotect ();
   sym_rec->define (new octave_builtin (f, name, doc), t);
@@ -139,7 +139,7 @@
   unsigned int t = symbol_record::DLD_FUNCTION;
 
   if (is_text_fcn)
-    t |= symbol_record::TEXT_FUNCTION;
+    t |= symbol_record::COMMAND;
 
   sym_rec->unprotect ();
   sym_rec->define (new octave_dld_function (f, shl, name, doc), t);
--- a/src/defun.h	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/defun.h	Tue Dec 03 19:48:57 2002 +0000
@@ -88,15 +88,19 @@
 #define DEFUNX(name, fname, args_name, nargout_name, doc) \
   DEFUNX_INTERNAL (name, fname, args_name, nargout_name, false, doc)
 
-// Define a builtin text-style function.
+// Define a builtin command-style function.
 //
 // This is like DEFUN, except that it defines a function that can be
 // called from the Octave language without using parenthesis to
 // surround the arguments). 
 
-#define DEFUN_TEXT(name, args_name, nargout_name, doc) \
+#define DEFCMD(name, args_name, nargout_name, doc) \
   DEFUN_INTERNAL (name, args_name, nargout_name, true, doc)
 
+// For backward compatibility.
+
+#define DEFUN_TEXT DEFCMD
+
 // Define a mapper function.
 //
 //   name is the name of the function, unquoqted.
--- a/src/dirfns.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/dirfns.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -82,7 +82,7 @@
   return cd_ok;
 }
 
-DEFUN_TEXT (cd, args, ,
+DEFCMD (cd, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} cd dir\n\
 @deffnx {Command} chdir dir\n\
@@ -140,7 +140,7 @@
   delete static_cast <iprocstream *> (p);
 }
 
-DEFUN_TEXT (ls, args, ,
+DEFCMD (ls, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} ls options\n\
 @deffnx {Command} dir options\n\
--- a/src/help.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/help.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -468,8 +468,7 @@
 
   LIST_SYMBOLS (symbol_record::BUILTIN_VARIABLE, "built-in variables");
 
-  LIST_SYMBOLS (symbol_record::TEXT_FUNCTION,
-		"text functions (these names are also reserved)");
+  LIST_SYMBOLS (symbol_record::COMMAND, "commands");
 
   LIST_SYMBOLS (symbol_record::MAPPER_FUNCTION, "mapper functions");
 
@@ -770,7 +769,7 @@
   additional_help_message (octave_stdout);
 }
 
-DEFUN_TEXT (help, args, ,
+DEFCMD (help, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} help\n\
 Octave's @code{help} command can be used to print brief usage-style\n\
@@ -845,7 +844,7 @@
     }
 }
 
-DEFUN_TEXT (type, args, nargout,
+DEFCMD (type, args, nargout,
   "-*- texinfo -*-\n\
 \n\
 @deffn {Command} type options name @dots{}\n\
@@ -969,7 +968,7 @@
     }
 }
 
-DEFUN_TEXT (which, args, nargout,
+DEFCMD (which, args, nargout,
   "-*- texinfo -*-\n\
 @deffn {Command} which name @dots{}\n\
 Display the type of each @var{name}.  If @var{name} is defined from a\n\
--- a/src/input.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/input.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -753,7 +753,7 @@
   return retval;
 }
 
-DEFUN_TEXT (echo, args, ,
+DEFCMD (echo, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} echo options\n\
 Control whether commands are displayed as they are executed.  Valid\n\
--- a/src/lex.l	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/lex.l	Tue Dec 03 19:48:57 2002 +0000
@@ -20,8 +20,8 @@
 
 */
 
-%s TEXT_FCN
-%s MATRIX
+%s COMMAND_START
+%s MATRIX_START
 
 %{
 #ifdef HAVE_CONFIG_H
@@ -233,12 +233,12 @@
 %%
 
 %{
-// Help and other text-style functions are a pain in the ass.  This
+// Help and other command-style functions are a pain in the ass.  This
 // stuff needs to be simplified.  May require some changes in the
 // parser too.
 %}
 
-<TEXT_FCN>{NL} {
+<COMMAND_START>{NL} {
     BEGIN 0;
     current_input_column = 1;
     lexer_flags.quote_is_transpose = false;
@@ -247,7 +247,7 @@
     return '\n';
   }
 
-<TEXT_FCN>[\;\,] {
+<COMMAND_START>[\;\,] {
     if (lexer_flags.doing_set && strcmp (yytext, ",") == 0)
       {
 	TOK_PUSH_AND_RETURN (yytext, STRING);
@@ -262,12 +262,12 @@
       }
   }
 
-<TEXT_FCN>[\"\'] {
+<COMMAND_START>[\"\'] {
     current_input_column++;
     return handle_string (yytext[0], true);
   }
 
-<TEXT_FCN>[^#% \t\n\;\,\"\'][^ \t\n\;\,]*{S}* {
+<COMMAND_START>[^#% \t\n\;\,\"\'][^ \t\n\;\,]*{S}* {
     std::string tok = strip_trailing_whitespace (yytext);
     TOK_PUSH_AND_RETURN (tok, STRING);
   }
@@ -284,7 +284,7 @@
 // after seeing a ']' character...
 %}
 
-<MATRIX>{SNLCMT}*\]{S}* {
+<MATRIX_START>{SNLCMT}*\]{S}* {
     scan_for_comments (yytext);
     fixup_column_count (yytext);
     int c = yytext[yyleng-1];
@@ -299,7 +299,7 @@
 // commas.
 %}
 
-<MATRIX>{S}*\,{S}* {
+<MATRIX_START>{S}*\,{S}* {
     current_input_column += yyleng;
 
     int tmp = eat_continuation ();
@@ -326,7 +326,7 @@
 // here we can end up inserting too many commas.
 %}
 
-<MATRIX>{S}+ {
+<MATRIX_START>{S}+ {
     current_input_column += yyleng;
 
     int tmp = eat_continuation ();
@@ -364,7 +364,7 @@
 // semicolons.
 %}
 
-<MATRIX>{SNLCMT}*;{SNLCMT}* {
+<MATRIX_START>{SNLCMT}*;{SNLCMT}* {
     scan_for_comments (yytext);
     fixup_column_count (yytext);
     eat_whitespace ();
@@ -380,8 +380,8 @@
 // semicolons.
 %}
 
-<MATRIX>{S}*{COMMENT}{SNLCMT}* |
-<MATRIX>{S}*{NL}{SNLCMT}* {
+<MATRIX_START>{S}*{COMMENT}{SNLCMT}* |
+<MATRIX_START>{S}*{NL}{SNLCMT}* {
     scan_for_comments (yytext);
     fixup_column_count (yytext);
     eat_whitespace ();
@@ -430,7 +430,7 @@
     else
       {
 	lexer_flags.bracketflag++;
-	BEGIN MATRIX;
+	BEGIN MATRIX_START;
 	return '[';
       }
   }
@@ -469,7 +469,7 @@
 
 %{
 // Eat whitespace.  Whitespace inside matrix constants is handled by
-// the <MATRIX> start state code above.
+// the <MATRIX_START> start state code above.
 %}
 
 {S}* {
@@ -528,7 +528,7 @@
 
 %{
 // A new line character.  New line characters inside matrix constants
-// are handled by the <MATRIX> start state code above.  If closest
+// are handled by the <MATRIX_START> start state code above.  If closest
 // nesting is inside parentheses, don't return a row separator.
 %}
 
@@ -2356,7 +2356,7 @@
   // something like [ab,cd] = foo (), force the symbol to be inserted
   // as a variable in the current symbol table.
 
-  if (is_text_function_name (tok) && ! is_variable (tok))
+  if (is_command_name (tok) && ! is_variable (tok))
     {
       if (next_tok_is_eq
 	  || lexer_flags.looking_at_return_list
@@ -2370,7 +2370,7 @@
 	  if (tok == "gset")
 	    lexer_flags.doing_set = true;
 
-	  BEGIN TEXT_FCN;
+	  BEGIN COMMAND_START;
 	}
     }
 
--- a/src/load-save.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/load-save.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -3071,7 +3071,7 @@
 not linked with the HDF5 library."
 #endif /* ! HAVE HDF5 */
 
-DEFUN_TEXT (load, args, nargout,
+DEFCMD (load, args, nargout,
   "-*- texinfo -*-\n\
 @deffn {Command} load options file v1 v2 @dots{}\n\
 Load the named variables from the file @var{file}.  As with @code{save},\n\
@@ -4881,7 +4881,7 @@
     }
 }
 
-DEFUN_TEXT (save, args, ,
+DEFCMD (save, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} save options file v1 v2 @dots{}\n\
 Save the named variables @var{v1}, @var{v2}, @dots{} in the file\n\
--- a/src/oct-hist.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/oct-hist.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -532,7 +532,7 @@
   unlink (name.c_str ());
 }
 
-DEFUN_TEXT (edit_history, args, ,
+DEFCMD (edit_history, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} edit_history options\n\
 If invoked with no arguments, @code{edit_history} allows you to edit the\n\
@@ -582,7 +582,7 @@
   return retval;
 }
 
-DEFUN_TEXT (history, args, ,
+DEFCMD (history, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} history options\n\
 If invoked with no arguments, @code{history} displays a list of commands\n\
@@ -625,7 +625,7 @@
   return retval;
 }
 
-DEFUN_TEXT (run_history, args, ,
+DEFCMD (run_history, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} run_history [first] [last]\n\
 Similar to @code{edit_history}, except that the editor is not invoked,\n\
--- a/src/pager.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/pager.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -407,7 +407,7 @@
     error ("diary: can't open diary file `%s'", diary_file.c_str ());
 }
 
-DEFUN_TEXT (diary, args, ,
+DEFCMD (diary, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} diary options\n\
 Create a list of all commands @emph{and} the output they produce, mixed\n\
@@ -478,7 +478,7 @@
   return retval;
 }
 
-DEFUN_TEXT (more, args, ,
+DEFCMD (more, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} more\n\
 @deffnx {Command} more on\n\
--- a/src/pr-output.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/pr-output.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -2011,7 +2011,7 @@
     }
 }
 
-DEFUN_TEXT (format, args, ,
+DEFCMD (format, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} format options\n\
 Control the format of the output produced by @code{disp} and Octave's\n\
--- a/src/pt-plot.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/pt-plot.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -982,7 +982,7 @@
   return retval;
 }
 
-DEFUN_TEXT (hold, args, ,
+DEFCMD (hold, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} hold @var{args}\n\
 Tell Octave to `hold' the current data on the plot when executing\n\
@@ -1090,7 +1090,7 @@
   return retval;
 }
 
-DEFUN_TEXT (gset, args, ,
+DEFCMD (gset, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} gset options\n\
 Set plotting options for gnuplot\n\
@@ -1144,7 +1144,7 @@
   return retval;
 }
 
-DEFUN_TEXT (set, args, nargout,
+DEFCMD (set, args, nargout,
   "-*- texinfo -*-\n\
 This command is has been replaced by @code{gset}.")
 {
@@ -1152,7 +1152,7 @@
   return Fgset (args, nargout);
 }
 
-DEFUN_TEXT (gshow, args, ,
+DEFCMD (gshow, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} gshow options\n\
 Show plotting options.\n\
@@ -1184,7 +1184,7 @@
   return retval;
 }
 
-DEFUN_TEXT (show, args, nargout,
+DEFCMD (show, args, nargout,
   "-*- texinfo -*-\n\
 This command is has been replaced by @code{gshow}.")
 {
--- a/src/symtab.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/symtab.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -64,8 +64,8 @@
 
   if (is_user_variable ())
     retval = "user-defined variable";
-  else if (is_text_function ())
-    retval = "built-in text function";
+  else if (is_command ())
+    retval = "built-in command";
   else if (is_mapper_function ())
     retval = "built-in mapper function";
   else if (is_user_function ())
--- a/src/symtab.h	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/symtab.h	Tue Dec 03 19:48:57 2002 +0000
@@ -62,7 +62,7 @@
       USER_VARIABLE = 2,
       DLD_FUNCTION = 4,
       BUILTIN_FUNCTION = 8,
-      TEXT_FUNCTION = 16,
+      COMMAND = 16,
       MAPPER_FUNCTION = 32,
       BUILTIN_VARIABLE = 64,
       BUILTIN_CONSTANT = 128
@@ -92,7 +92,7 @@
 		|| symbol_type & symbol_record::BUILTIN_VARIABLE);
       }
 
-    // It's not necessary to check for TEXT_FUNCTION and MAPPER_FUNCTION
+    // It's not necessary to check for COMMAND and MAPPER_FUNCTION
     // here.  Those tags are just used as additional qualifiers for
     // the other types of functions.
 
@@ -106,14 +106,14 @@
     bool is_user_variable (void) const
       { return (symbol_type & symbol_record::USER_VARIABLE); }
 
-    void mark_as_text_function (void)
-      { symbol_type |= symbol_record::TEXT_FUNCTION; }
+    void mark_as_command (void)
+      { symbol_type |= symbol_record::COMMAND; }
 
-    void unmark_text_function (void)
-      { symbol_type &= ~symbol_record::TEXT_FUNCTION; }
+    void unmark_command (void)
+      { symbol_type &= ~symbol_record::COMMAND; }
 
-    bool is_text_function (void) const
-      { return (symbol_type & symbol_record::TEXT_FUNCTION); }
+    bool is_command (void) const
+      { return (symbol_type & symbol_record::COMMAND); }
 
     bool is_mapper_function (void) const
       { return (symbol_type & symbol_record::MAPPER_FUNCTION); }
@@ -243,14 +243,14 @@
   bool is_function (void) const
     { return definition->is_function (); }
 
-  void mark_as_text_function (void)
-    { definition->mark_as_text_function (); }
+  void mark_as_command (void)
+    { definition->mark_as_command (); }
 
-  void unmark_text_function (void)
-    { definition->unmark_text_function (); }
+  void unmark_command (void)
+    { definition->unmark_command (); }
 
-  bool is_text_function (void) const
-    { return definition->is_text_function (); }
+  bool is_command (void) const
+    { return definition->is_command (); }
 
   bool is_mapper_function (void) const
     { return definition->is_mapper_function (); }
@@ -390,7 +390,7 @@
 			  | symbol_record::USER_VARIABLE \
 			  | symbol_record::DLD_FUNCTION \
 			  | symbol_record::BUILTIN_FUNCTION \
-			  | symbol_record::TEXT_FUNCTION \
+			  | symbol_record::COMMAND \
 			  | symbol_record::MAPPER_FUNCTION \
 			  | symbol_record::BUILTIN_VARIABLE \
 			  | symbol_record::BUILTIN_CONSTANT)
--- a/src/sysdep.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/sysdep.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -647,7 +647,7 @@
 
 #if defined (__EMX__) && defined (OS2)
 
-DEFUN_TEXT (extproc, , ,
+DEFCMD (extproc, , ,
   "extproc: ignored by Octave")
 {
   return octave_value_list ();
--- a/src/toplev.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/toplev.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -213,7 +213,7 @@
   exit (retval == EOF ? 0 : retval);
 }
 
-DEFUN_TEXT (casesen, args, ,
+DEFCMD (casesen, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} casesen arg\n\
 Provided for compatibility with Matlab, but does nothing.\n\
--- a/src/variables.cc	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/variables.cc	Tue Dec 03 19:48:57 2002 +0000
@@ -71,6 +71,12 @@
 // Symbol table for functions and built-in symbols.
 symbol_table *fbi_sym_tab = 0;
 
+static inline bool
+at_top_level (void)
+{
+  return (curr_sym_tab == top_level_sym_tab);
+}
+
 // Initialization.
 
 // Create the initial symbol tables and set the current scope at the
@@ -102,91 +108,101 @@
   return (sr && sr->is_builtin_variable ());
 }
 
-// Is this a text-style function?
+// Is this a command-style function?
 
-static std::set <std::string> text_function_set;
+static std::set <std::string> command_set;
 
 static inline bool
-is_marked_as_text_function (const std::string& s)
+is_marked_as_command (const std::string& s)
 {
-  return text_function_set.find (s) != text_function_set.end ();
+  return command_set.find (s) != command_set.end ();
 }
 
 static inline void
-mark_as_text_function (const std::string& s)
+mark_as_command (const std::string& s)
 {
-  text_function_set.insert (s);
+  command_set.insert (s);
 }
 
 static inline void
-unmark_text_function (const std::string& s)
+unmark_command (const std::string& s)
 {
-  text_function_set.erase (s);
+  command_set.erase (s);
 
   symbol_record *sr = fbi_sym_tab->lookup (s);
 
   if (sr)
-    sr->unmark_text_function ();
+    sr->unmark_command ();
 }
 
-DEFUN_TEXT (mark_as_text_function, args, ,
+DEFCMD (mark_as_command, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\
-Enter @var{name} into the list of text functions\n\
+@deftypefn {Built-in Function} {} mark_as_command (@var{name})\n\
+Enter @var{name} into the list of commands.\n\
 @end deftypefn")
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
+  if (at_top_level ())
+    {
+      int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      int argc = nargin + 1;
+      if (nargin > 0)
+	{
+	  int argc = nargin + 1;
 
-      string_vector argv = args.make_argv ("mark_as_text_function");
+	  string_vector argv = args.make_argv ("mark_as_command");
 
-      if (! error_state)
-	{
-	  for (int i = 1; i < argc; i++)
-	    mark_as_text_function (argv[i]);
+	  if (! error_state)
+	    {
+	      for (int i = 1; i < argc; i++)
+		mark_as_command (argv[i]);
+	    }
 	}
+      else
+	print_usage ("mark_as_command");
     }
   else
-    print_usage ("mark_as_text_function");
+    warning ("mark_as_command: invalid use inside function body");
 
   return retval;
 }
 
-DEFUN_TEXT (unmark_text_function, args, ,
+DEFCMD (unmark_command, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\
-Enter @var{name} into the list of text functions\n\
+@deftypefn {Built-in Function} {} mark_as_command (@var{name})\n\
+Remove @var{name} from the list of commands.\n\
 @end deftypefn")
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
+  if (at_top_level ())
+    {
+      int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      int argc = nargin + 1;
+      if (nargin > 0)
+	{
+	  int argc = nargin + 1;
 
-      string_vector argv = args.make_argv ("unmark_text_function");
+	  string_vector argv = args.make_argv ("unmark_command");
 
-      if (! error_state)
-	{
-	  for (int i = 1; i < argc; i++)
-	    unmark_text_function (argv[i]);
+	  if (! error_state)
+	    {
+	      for (int i = 1; i < argc; i++)
+		unmark_command (argv[i]);
+	    }
 	}
+      else
+	print_usage ("unmark_command");
     }
   else
-    print_usage ("unmark_text_function");
+    warning ("mark_as_command: invalid use inside function body");
 
   return retval;
 }
 
 bool
-is_text_function_name (const std::string& s)
+is_command_name (const std::string& s)
 {
   bool retval = false;
 
@@ -194,16 +210,16 @@
 
   if (sr)
     {
-      if (sr->is_text_function ())
+      if (sr->is_command ())
 	retval = true;
-      else if (is_marked_as_text_function (s))
+      else if (is_marked_as_command (s))
 	{
-	  sr->mark_as_text_function ();
+	  sr->mark_as_command ();
 	  retval = true;
 	}
     }
   else
-    retval = is_marked_as_text_function (s);
+    retval = is_marked_as_command (s);
 
   return retval;
 }
@@ -958,7 +974,7 @@
 	  if (! error_state)
 	    {
 	      if (is_builtin_variable (name)
-		  || is_text_function_name (name)
+		  || is_command_name (name)
 		  || is_mapper_function_name (name)
 		  || is_builtin_function_name (name))
 		error ("document: can't redefine help for built-in variables and functions");
@@ -1021,7 +1037,7 @@
 
   if (! (show_builtins || show_functions || show_variables))
     {
-      show_functions = (curr_sym_tab == top_level_sym_tab);
+      show_functions = at_top_level ();
       show_variables = true;
     }
 
@@ -1035,7 +1051,7 @@
 
   if (show_verbose && ! (show_builtins || show_functions || show_variables))
     {
-      show_functions = (curr_sym_tab == top_level_sym_tab);
+      show_functions = at_top_level ();
       show_variables = 1;
     }
 
@@ -1087,7 +1103,7 @@
   return retval;
 }
 
-DEFUN_TEXT (who, args, ,
+DEFCMD (who, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} who options pattern @dots{}\n\
 @deffnx {Command} whos options pattern @dots{}\n\
@@ -1139,7 +1155,7 @@
   return retval;
 }
 
-DEFUN_TEXT (whos, args, ,
+DEFCMD (whos, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} whos options pattern @dots{}\n\
 See who.\n\
@@ -1577,7 +1593,7 @@
     } \
   while (0)
 
-DEFUN_TEXT (clear, args, ,
+DEFCMD (clear, args, ,
   "-*- texinfo -*-\n\
 @deffn {Command} clear [-x] pattern @dots{}\n\
 Delete the names matching the given patterns from the symbol table.  The\n\
--- a/src/variables.h	Tue Dec 03 18:22:51 2002 +0000
+++ b/src/variables.h	Tue Dec 03 19:48:57 2002 +0000
@@ -43,7 +43,7 @@
 extern void initialize_symbol_tables (void);
 
 extern bool is_builtin_variable (const std::string&);
-extern bool is_text_function_name (const std::string&);
+extern bool is_command_name (const std::string&);
 extern bool is_mapper_function_name (const std::string&);
 extern bool is_builtin_function_name (const std::string&);
 extern bool is_globally_visible (const std::string&);