octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python to Octave bridge


From: John W. Eaton
Subject: Re: Python to Octave bridge
Date: Thu, 23 Oct 2008 16:05:30 -0400

On 23-Oct-2008, David Grundberg wrote:

| I've changed the trunk to use octave_main to initiate Octave now. There 
| is one obvious annoyance though. Unfortunately Octave's command line 
| history is appended to the readline history of Python's interactive 
| interpreter, even though I pass --no-history --no-line-editing as 
| arguments to octave_main.
| 
| So basically one runs `import pytave' inside the interpreter, and then 
| the history is filled by a lot of Octave code.

Please try the following patch.

Thanks,

jwe


# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1224792066 14400
# Node ID 2c1ba965b486994c619a508e0fb7c12df473a739
# Parent  ed5811a1ec8f9a0c5dd094db5b666cd87e8a1dc7
skip reading history file with --no-history option

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,10 @@
 2008-10-23  John W. Eaton  <address@hidden>
+
+       * oct-hist.c (initialize_history): New arg, read_history_file)
+       * oct-hist.h: Fix decl.
+       * octave.cc (octave_main): Set read_history_file to false if
+       --no-history option is specified.  Pass read_history_file to
+       initialize_history.
 
        * DLD-FUNCTIONS/fltk_backend.cc: Update initialization comment.
 
diff --git a/src/oct-hist.cc b/src/oct-hist.cc
--- a/src/oct-hist.cc
+++ b/src/oct-hist.cc
@@ -529,12 +529,13 @@
 }
 
 void
-initialize_history (void)
+initialize_history (bool read_history_file)
 {
   command_history::set_file (Vhistory_file);
   command_history::set_size (Vhistory_size);
 
-  command_history::read (false);
+  if (read_history_file)
+    command_history::read (false);
 }
 
 void
diff --git a/src/oct-hist.h b/src/oct-hist.h
--- a/src/oct-hist.h
+++ b/src/oct-hist.h
@@ -28,7 +28,7 @@
 
 #include "cmd-hist.h"
 
-extern void initialize_history (void);
+extern void initialize_history (bool read_history_file = false);
 
 // Write timestamp to history file.
 extern void octave_history_write_timestamp (void);
diff --git a/src/octave.cc b/src/octave.cc
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -628,12 +628,15 @@
 
   bool forced_line_editing = false;
 
+  bool read_history_file = true;
+
   int optc;
   while ((optc = args.getopt ()) != EOF)
     {
       switch (optc)
        {
        case 'H':
+         read_history_file = false;
          bind_internal_variable ("saving_history", false);
          break;
 
@@ -776,7 +779,7 @@
 
   execute_startup_files ();
 
-  initialize_history ();
+  initialize_history (read_history_file);
 
   if (! inhibit_startup_message && reading_startup_message_printed)
     std::cout << std::endl;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]