GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
oct-hist.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2026 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26/*
27
28The functions listed below were adapted from similar functions from
29GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
30Software Foundation, Inc.
31
32 do_history edit_history_readline
33 do_edit_history edit_history_add_hist
34
35*/
36
37#if defined (HAVE_CONFIG_H)
38# include "config.h"
39#endif
40
41#include <cstdlib>
42#include <cstring>
43
44#include <fstream>
45#include <string>
46
47#include "cmd-hist.h"
48#include "file-ops.h"
49#include "mappers.h"
50#include "oct-env.h"
51#include "oct-sysdep.h"
52#include "oct-time.h"
53#include "str-vec.h"
54#include "unistd-wrappers.h"
55
56#include "defun.h"
57#include "error.h"
58#include "errwarn.h"
59#include "event-manager.h"
60#include "input.h"
61#include "oct-hist.h"
62#include "ovl.h"
63#include "pager.h"
64#include "parse.h"
65#include "sighandlers.h"
66#include "sysdep.h"
67#include "interpreter.h"
68#include "interpreter-private.h"
69#include "unwind-prot.h"
70#include "utils.h"
71#include "variables.h"
72
74
75// Read the edited history lines from STREAM and return them
76// one at a time. This can read unlimited length lines. The
77// caller should free the storage.
78
79static char *
80edit_history_readline (std::fstream& stream)
81{
82 char c;
83 int line_len = 128;
84 int lindex = 0;
85 char *line = new char [line_len];
86 line[0] = '\0';
87
88 while (stream.get (c))
89 {
90 if (lindex + 2 >= line_len)
91 {
92 char *tmp_line = new char [line_len += 128];
93 strcpy (tmp_line, line);
94 delete [] line;
95 line = tmp_line;
96 }
97
98 if (c == '\n')
99 {
100 line[lindex++] = '\n';
101 line[lindex++] = '\0';
102 return line;
103 }
104 else
105 line[lindex++] = c;
106 }
107
108 if (! lindex)
109 {
110 delete [] line;
111 return nullptr;
112 }
113
114 if (lindex + 2 >= line_len)
115 {
116 char *tmp_line = new char [lindex+3];
117 strcpy (tmp_line, line);
118 delete [] line;
119 line = tmp_line;
120 }
121
122 // Finish with newline if none in file.
123
124 line[lindex++] = '\n';
125 line[lindex++] = '\0';
126 return line;
127}
128
129static void
130edit_history_add_hist (const std::string& line)
131{
132 if (! line.empty ())
133 {
134 std::string tmp = line;
135
136 int len = tmp.length ();
137
138 if (len > 0 && tmp[len-1] == '\n')
139 tmp.resize (len - 1);
140
141 if (! tmp.empty ())
142 {
143 if (command_history::add (tmp))
144 {
146
147 evmgr.append_history (tmp);
148 }
149 }
150 }
151}
152
153static bool
154get_int_arg (const octave_value& arg, int& val)
155{
156 bool ok = true;
157
158 if (arg.is_string ())
159 {
160 std::string tmp = arg.string_value ();
161
162 ok = sscanf (tmp.c_str (), "%d", &val) == 1;
163 }
164 else if (arg.isnumeric ())
165 val = arg.int_value ();
166 else
167 ok = false;
168
169 return ok;
170}
171
172static std::string
173mk_tmp_hist_file (const octave_value_list& args,
174 bool insert_curr, const char *warn_for)
175{
177
178 int hist_count = hlist.numel () - 1; // switch to zero-based indexing
179
180 // The current command line is already part of the history list by
181 // the time we get to this point. Delete the cmd from the list when
182 // executing 'edit_history' so that it doesn't show up in the history
183 // but the actual commands performed will.
184
185 if (! insert_curr)
186 command_history::remove (hist_count);
187
188 hist_count--; // skip last entry in history list
189
190 // If no numbers have been specified, the default is to edit the
191 // last command in the history list.
192
193 int hist_beg = hist_count;
194 int hist_end = hist_count;
195
196 bool reverse = false;
197
198 // Process options.
199
200 int nargin = args.length ();
201
202 if (nargin == 2)
203 {
204 if (! get_int_arg (args(0), hist_beg)
205 || ! get_int_arg (args(1), hist_end))
206 error ("%s: arguments must be integers", warn_for);
207
208 if (hist_beg < 0)
209 hist_beg += (hist_count + 1);
210 else
211 hist_beg--;
212 if (hist_end < 0)
213 hist_end += (hist_count + 1);
214 else
215 hist_end--;
216 }
217 else if (nargin == 1)
218 {
219 if (! get_int_arg (args(0), hist_beg))
220 error ("%s: argument must be an integer", warn_for);
221
222 if (hist_beg < 0)
223 hist_beg += (hist_count + 1);
224 else
225 hist_beg--;
226
227 hist_end = hist_beg;
228 }
229
230 if (hist_beg > hist_count || hist_end > hist_count)
231 error ("%s: history specification out of range", warn_for);
232
233 if (hist_end < hist_beg)
234 {
235 std::swap (hist_end, hist_beg);
236 reverse = true;
237 }
238
239 std::string name = sys::tempnam ("", "oct-");
240
241 std::ofstream file = sys::ofstream (name.c_str (), std::ios::out);
242
243 if (! file)
244 error ("%s: couldn't open temporary file '%s'", warn_for,
245 name.c_str ());
246
247 if (reverse)
248 {
249 for (int i = hist_end; i >= hist_beg; i--)
250 file << hlist[i] << "\n";
251 }
252 else
253 {
254 for (int i = hist_beg; i <= hist_end; i++)
255 file << hlist[i] << "\n";
256 }
257
258 file.close ();
259
260 return name;
261}
262
264 : m_interpreter (interp), m_input_from_tmp_file (false),
265 m_timestamp_format_string (default_timestamp_format ())
266{ }
267
268void
269history_system::initialize (bool read_history_file)
270{
271 command_history::initialize (read_history_file, default_file (),
272 default_size (),
273 sys::env::getenv ("OCTAVE_HISTCONTROL"));
274
275 event_manager& evmgr = m_interpreter.get_event_manager ();
276
278}
279
280void
282{
283 sys::localtime now;
284
285 std::string timestamp = now.strftime (m_timestamp_format_string);
286
287 if (! timestamp.empty ())
288 {
289 if (command_history::add (timestamp))
290 {
291 event_manager& evmgr = m_interpreter.get_event_manager ();
292
293 evmgr.append_history (timestamp);
294 }
295 }
296}
297
300 int nargout)
301{
302 return set_internal_variable (m_input_from_tmp_file, args, nargout,
303 "input_from_tmp_file");
304}
305
308 int nargout)
309{
310 return set_internal_variable (m_timestamp_format_string, args, nargout,
311 "timestamp_format_string");
312}
313
314// Display, save, or load history. Stolen and modified from bash.
315//
316// Arg of -w FILENAME means write file, arg of -r FILENAME
317// means read file, arg of -q means don't number lines. Arg of N
318// means only display that many items.
319
322 int nargout)
323{
324 bool numbered_output = nargout == 0;
325
326 unwind_action restore_history_filename
327 ([] (const std::string& old_filename)
328 {
329 command_history::set_file (old_filename);
331
332 string_vector hlist;
333
334 int nargin = args.length ();
335
336 // Number of history lines to show (-1 = all)
337 int limit = -1;
338
339 for (octave_idx_type i = 0; i < nargin; i++)
340 {
341 octave_value arg = args(i);
342
343 std::string option;
344
345 if (arg.is_string ())
346 option = arg.string_value ();
347 else if (arg.isnumeric ())
348 {
349 limit = arg.int_value ();
350 if (limit < 0)
351 limit = -limit;
352 continue;
353 }
354 else
355 err_wrong_type_arg ("history", arg);
356
357 event_manager& evmgr = m_interpreter.get_event_manager ();
358
359 if (option == "-r" || option == "-w" || option == "-a"
360 || option == "-n")
361 {
362 if (i < nargin - 1)
363 {
364 std::string fname
365 = args(++i).xstring_value ("history: filename must be a string for %s option",
366 option.c_str ());
367
369 }
370 else
371 command_history::set_file (default_file ());
372
373 if (option == "-a")
374 // Append 'new' lines to file.
376
377 else if (option == "-w")
378 // Write entire history.
380
381 else if (option == "-r")
382 {
383 // Read entire file.
386 }
387
388 else if (option == "-n")
389 {
390 // Read 'new' history from file.
393 }
394
395 else
396 error ("history: invalid option '%s' - please report this bug", option.c_str ());
397
398 return hlist;
399 }
400 else if (option == "-c")
401 {
403 evmgr.clear_history ();
404 }
405 else if (option == "-q")
406 numbered_output = false;
407 else if (option == "--")
408 {
409 i++;
410 break;
411 }
412 else
413 {
414 // The last argument found in the command list that looks like
415 // an integer will be used
416 int tmp;
417
418 if (sscanf (option.c_str (), "%d", &tmp) == 1)
419 {
420 if (tmp > 0)
421 limit = tmp;
422 else
423 limit = -tmp;
424 }
425
426 else
427 {
428 if (option.length () > 0 && option[0] == '-')
429 error ("history: unrecognized option '%s'", option.c_str ());
430 else
431 error ("history: bad non-numeric arg '%s'", option.c_str ());
432 }
433 }
434 }
435
436 hlist = command_history::list (limit, numbered_output);
437
438 int len = hlist.numel ();
439
440 if (nargout == 0)
441 {
442 for (octave_idx_type i = 0; i < len; i++)
443 octave_stdout << hlist[i] << "\n";
444 }
445
446 return hlist;
447}
448
449void
451{
452 std::string name = mk_tmp_hist_file (args, false, "edit_history");
453
454 if (name.empty ())
455 return;
456
457 // Call up our favorite editor on the file of commands.
458
459 environment& env = m_interpreter.get_environment ();
460 std::string cmd = env.editor ();
461 cmd.append (R"( ")" + name + '"');
462
463 // Ignore interrupts while we are off editing commands. Should we
464 // maybe avoid using system()?
465
466 interrupt_handler old_interrupt_handler = ignore_interrupts ();
467
468 int status = sys::system (cmd);
469
470 set_interrupt_handler (old_interrupt_handler);
471
472 // Check if text edition was successful. Abort the operation
473 // in case of failure.
474 if (status != EXIT_SUCCESS)
475 error ("edit_history: text editor command failed");
476
477 // Write the commands to the history file since source_file
478 // disables command line history while it executes.
479
480 std::fstream file = sys::fstream (name.c_str (), std::ios::in);
481
482 char *line;
483 //int first = 1;
484 while ((line = edit_history_readline (file)) != nullptr)
485 {
486 // Skip blank lines.
487
488 if (line[0] == '\n')
489 {
490 delete [] line;
491 continue;
492 }
493
494 edit_history_add_hist (line);
495
496 delete [] line;
497 }
498
499 file.close ();
500
501 int(*unlink_fptr)(const std::string&) = sys::unlink;
502 unwind_action unlink_action (unlink_fptr, name);
503 unwind_protect_var<bool> upv (m_input_from_tmp_file, true);
504
505 // FIXME: instead of sourcing a file, we should just iterate through
506 // the list of commands, parsing and executing them one at a time as
507 // if they were entered interactively.
508
509 source_file (name);
510}
511
512void
514{
515 std::string name = mk_tmp_hist_file (args, false, "run_history");
516
517 if (name.empty ())
518 return;
519
520 int(*unlink_fptr)(const std::string&) = sys::unlink;
521 unwind_action unlink_action (unlink_fptr, name);
522 unwind_protect_var<bool> upv (m_input_from_tmp_file, true);
523
524 // FIXME: instead of sourcing a file, we should just iterate through
525 // the list of commands, parsing and executing them one at a time as
526 // if they were entered interactively.
527
528 source_file (name);
529}
530
531std::string
532history_system::default_file ()
533{
534 std::string file;
535
536 std::string env_file = sys::env::getenv ("OCTAVE_HISTFILE");
537
538 if (! env_file.empty ())
539 file = env_file;
540
541 if (file.empty ())
542 {
543 // Default to $DATA/octave/history, where $DATA is the platform-
544 // dependent location for (roaming) user data files.
545
546 std::string user_data_dir = sys::env::get_user_data_directory ();
547
548 std::string hist_dir = user_data_dir + sys::file_ops::dir_sep_str ()
549 + "octave";
550
551 file = sys::env::make_absolute ("history", hist_dir);
552 }
553
554
555 return file;
556}
557
558int
559history_system::default_size ()
560{
561 int size = 1000;
562
563 std::string env_size = sys::env::getenv ("OCTAVE_HISTSIZE");
564
565 if (! env_size.empty ())
566 {
567 int val;
568
569 if (sscanf (env_size.c_str (), "%d", &val) == 1)
570 size = (val > 0 ? val : 0);
571 }
572
573 return size;
574}
575
576std::string
577history_system::default_timestamp_format ()
578{
579 return "# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z";
580}
581
582DEFMETHOD (edit_history, interp, args, ,
583 doc: /* -*- texinfo -*-
584@deftypefn {} {} edit_history
585@deftypefnx {} {} edit_history @var{cmd_number}
586@deftypefnx {} {} edit_history @var{first} @var{last}
587Edit the history list using the editor named by the variable @env{EDITOR}.
588
589The commands to be edited are first copied to a temporary file. When you
590exit the editor, Octave executes the commands that remain in the file. It
591is often more convenient to use @code{edit_history} to define functions
592rather than attempting to enter them directly on the command line.
593The block of commands is executed as soon as you exit the editor.
594To avoid executing any commands, simply delete all the lines from the buffer
595before leaving the editor.
596
597When invoked with no arguments, edit the previously executed command;
598With one argument, edit the specified command @var{cmd_number};
599With two arguments, edit the list of commands between @var{first} and
600@var{last}. Command number specifiers may also be negative where -1
601refers to the most recently executed command.
602The following are equivalent and edit the most recently executed command.
603
604@example
605@group
606edit_history
607edit_history -1
608@end group
609@end example
610
611When using ranges, specifying a larger number for the first command than the
612last command reverses the list of commands before they are placed in the
613buffer to be edited.
614@seealso{run_history, history}
615@end deftypefn */)
616{
617 // FIXME: should this be limited to the top-level context?
618 if (args.length () > 2)
619 print_usage ();
620
621 history_system& history_sys = interp.get_history_system ();
622
623 history_sys.do_edit_history (args);
624
625 return ovl ();
626}
627
628DEFMETHOD (history, interp, args, nargout,
629 doc: /* -*- texinfo -*-
630@deftypefn {} {} history
631@deftypefnx {} {} history @var{opt1} @dots{}
632@deftypefnx {} {@var{H} =} history ()
633@deftypefnx {} {@var{H} =} history (@var{opt1}, @dots{})
634If invoked with no arguments, @code{history} displays a list of commands that
635you have executed.
636
637Valid options are:
638
639@table @code
640@item @var{n}
641@itemx -@var{n}
642Display only the most recent @var{n} lines of history.
643
644@item -c
645Clear the history list.
646
647@item -q
648Don't number the displayed lines of history. This is useful for cutting and
649pasting commands using the X Window System.
650
651@item -r @var{file}
652Read the file @var{file}, appending its contents to the current history list.
653If the name is omitted, use the default history file
654(@pxref{XREFhistory_file,,@code{history_file}}).
655
656@item -w @var{file}
657Write the current history to the file @var{file}. If the name is omitted, use
658the default history file (@pxref{XREFhistory_file,,@code{history_file}}).
659@end table
660
661For example, to display the five most recent commands that you have typed
662without displaying line numbers, use the command @kbd{history -q 5}.
663
664If invoked with a single output argument, the history will be saved to that
665argument as a cell string and will not be output to screen.
666@seealso{edit_history, run_history, history_file, history_save}
667@end deftypefn */)
668{
669 // FIXME: should this be limited to the top-level context?
670
671 history_system& history_sys = interp.get_history_system ();
672
673 // Call do_history even if nargout is zero to display history list.
674
675 string_vector hlist = history_sys.do_history (args, nargout);
676
677 return nargout > 0 ? ovl (Cell (hlist)) : ovl ();
678}
679
680DEFMETHOD (run_history, interp, args, ,
681 doc: /* -*- texinfo -*-
682@deftypefn {} {} run_history
683@deftypefnx {} {} run_history @var{cmd_number}
684@deftypefnx {} {} run_history @var{first} @var{last}
685Run commands from the history list.
686
687When invoked with no arguments, run the previously executed command;
688
689With one argument, run the specified command @var{cmd_number};
690
691With two arguments, run the list of commands between @var{first} and
692@var{last}. Command number specifiers may also be negative where -1
693refers to the most recently executed command. For example, the command
694
695@example
696@group
697run_history
698 OR
699run_history -1
700@end group
701@end example
702
703@noindent
704executes the most recent command again.
705The command
706
707@example
708run_history 13 169
709@end example
710
711@noindent
712executes commands 13 through 169.
713
714Specifying a larger number for the first command than the last command
715reverses the list of commands before executing them.
716For example:
717
718@example
719@group
720disp (1)
721disp (2)
722run_history -1 -2
723@xresult{}
724 2
725 1
726@end group
727@end example
728
729@seealso{edit_history, history}
730@end deftypefn */)
731{
732 // FIXME: should this be limited to the top-level context?
733
734 history_system& history_sys = interp.get_history_system ();
735
736 if (args.length () > 2)
737 print_usage ();
738
739 history_sys.do_run_history (args);
740
741 return ovl ();
742}
743
744DEFUN (history_control, args, nargout,
745 doc: /* -*- texinfo -*-
746@deftypefn {} {@var{val} =} history_control ()
747@deftypefnx {} {@var{old_val} =} history_control (@var{new_val})
748Query or set the internal variable that specifies how commands are saved
749to the history list.
750
751The default value is an empty character string, but may be overridden by the
752environment variable @w{@env{OCTAVE_HISTCONTROL}}.
753
754The value of @code{history_control} is a colon-separated list of values
755controlling how commands are saved on the history list. If the list
756of values includes @code{ignorespace}, lines which begin with a space
757character are not saved in the history list. A value of @code{ignoredups}
758causes lines matching the previous history entry to not be saved.
759A value of @code{ignoreboth} is shorthand for @code{ignorespace} and
760@code{ignoredups}. A value of @code{erasedups} causes all previous lines
761matching the current line to be removed from the history list before that
762line is saved. Any value not in the above list is ignored. If
763@code{history_control} is the empty string, all commands are saved on
764the history list, subject to the value of @code{history_save}.
765@seealso{history_file, history_size, history_timestamp_format_string,
766history_save}
767@end deftypefn */)
768{
769 octave_value retval;
770
771 std::string old_history_control = command_history::histcontrol ();
772
773 std::string tmp = old_history_control;
774
775 retval = set_internal_variable (tmp, args, nargout, "history_control");
776
777 if (tmp != old_history_control)
779
780 return retval;
781}
782
783DEFUN (history_size, args, nargout,
784 doc: /* -*- texinfo -*-
785@deftypefn {} {@var{val} =} history_size ()
786@deftypefnx {} {@var{old_val} =} history_size (@var{new_val})
787Query or set the internal variable that specifies how many entries
788to store in the history file.
789
790The default value is @code{1000}, but may be overridden by the environment
791variable @w{@env{OCTAVE_HISTSIZE}}.
792@seealso{history_file, history_timestamp_format_string, history_save}
793@end deftypefn */)
794{
795 octave_value retval;
796
797 int old_history_size = command_history::size ();
798
799 int tmp = old_history_size;
800
801 retval = set_internal_variable (tmp, args, nargout,
802 "history_size", -1,
803 std::numeric_limits<int>::max ());
804
805 if (tmp != old_history_size)
807
808 return retval;
809}
810
811DEFUN (history_file, args, nargout,
812 doc: /* -*- texinfo -*-
813@deftypefn {} {@var{val} =} history_file ()
814@deftypefnx {} {@var{old_val} =} history_file (@var{new_val})
815Query or set the internal variable that specifies the name of the file used to
816store command history.
817
818All future commands issued during the current Octave session will be written to
819this new file (if the current setting of @code{history_save} allows for this).
820
821The default value is @file{@w{@env{$DATA}}/octave/history}, where
822@w{@env{$DATA}}@ is the platform-specific location for (roaming) user data files
823(e.g., @w{@env{$XDG_DATA_HOME}}@ or, if that is not set, @file{~/.local/share}
824on Unix-like operating systems or @w{@env{%APPDATA%}}@ on Windows). The
825default value may be overridden by the environment variable
826@w{@env{OCTAVE_HISTFILE}}.
827
828Programming Notes:
829
830If you want to permanently change the location of Octave's history file you
831need to issue the @code{history_file} command in every new Octave session.
832This can be achieved by using Octave's @file{.octaverc} startup file.
833
834If you also want to read the saved history commands of past Octave sessions
835from this different history file, then you need to use the additional command
836@code{history -r} after setting the new value of the history file. Example
837code in Octave's startup file to do this might look like this:
838
839@example
840@group
841history_file ("~/new/.octave_hist");
842if (exist (history_file ()))
843 history ("-r", history_file());
844endif
845@end group
846@end example
847
848@seealso{history, history_control, history_save, history_size,
849history_timestamp_format_string}
850@end deftypefn */)
851{
852 octave_value retval;
853
854 std::string old_history_file = command_history::file ();
855
856 std::string tmp = old_history_file;
857
858 retval = set_internal_variable (tmp, args, nargout, "history_file");
859
860 if (tmp != old_history_file)
862
863 return retval;
864}
865
866DEFMETHOD (history_timestamp_format_string, interp, args, nargout,
867 doc: /* -*- texinfo -*-
868@deftypefn {} {@var{val} =} history_timestamp_format_string ()
869@deftypefnx {} {@var{old_val} =} history_timestamp_format_string (@var{new_val})
870@deftypefnx {} {@var{old_val} =} history_timestamp_format_string (@var{new_val}, "local")
871Query or set the internal variable that specifies the format string
872for the comment line that is written to the history file when Octave
873exits.
874
875The format string is passed to @code{strftime}. The default value is
876
877@example
878"# Octave VERSION, %a %b %d %H:%M:%S %Y %Z"
879@end example
880
881When called from inside a function with the @qcode{"local"} option, the
882variable is changed locally for the function and any subroutines it calls.
883The original variable value is restored when exiting the function.
884@seealso{strftime, history_file, history_size, history_save}
885@end deftypefn */)
886{
887 history_system& history_sys = interp.get_history_system ();
888
889 return history_sys.timestamp_format_string (args, nargout);
890}
891
892/*
893%!test
894%! history_timestamp_format_string ("# Example history marker", "local");
895%! assert (history_timestamp_format_string (), "# Example history marker");
896%!test <*57843>
897%! history_timestamp_format_string ("", "local");
898%! assert (history_timestamp_format_string (), "");
899*/
900
901DEFUN (history_save, args, nargout,
902 doc: /* -*- texinfo -*-
903@deftypefn {} {@var{val} =} history_save ()
904@deftypefnx {} {@var{old_val} =} history_save (@var{new_val})
905@deftypefnx {} {@var{old_val} =} history_save (@var{new_val}, "local")
906Query or set the internal variable that controls whether commands entered
907on the command line are saved in the history file.
908
909When called from inside a function with the @qcode{"local"} option, the
910variable is changed locally for the function and any subroutines it calls.
911The original variable value is restored when exiting the function.
912@seealso{history_control, history_file, history_size,
913history_timestamp_format_string}
914@end deftypefn */)
915{
916 octave_value retval;
917
918 bool old_history_save = ! command_history::ignoring_entries ();
919
920 bool tmp = old_history_save;
921
922 retval = set_internal_variable (tmp, args, nargout, "history_save");
923
924 if (tmp != old_history_save)
926
927 return retval;
928}
929
930OCTAVE_END_NAMESPACE(octave)
Definition Cell.h:41
static bool ignoring_entries()
Definition cmd-hist.cc:610
static void read(bool=true)
Definition cmd-hist.cc:700
static void clear()
Definition cmd-hist.cc:631
static int size()
Definition cmd-hist.cc:597
static void initialize(bool, const std::string &, int, const std::string &)
Definition cmd-hist.cc:543
static void append(const std::string &="")
Definition cmd-hist.cc:734
static std::string file()
Definition cmd-hist.cc:571
static void set_file(const std::string &)
Definition cmd-hist.cc:560
static std::string histcontrol()
Definition cmd-hist.cc:584
static bool add(const std::string &)
Definition cmd-hist.cc:616
static void set_size(int)
Definition cmd-hist.cc:590
static void remove(int)
Definition cmd-hist.cc:624
static void ignore_entries(bool=true)
Definition cmd-hist.cc:603
static void process_histcontrol(const std::string &)
Definition cmd-hist.cc:577
static void read_range(int=-1, int=-1, bool=true)
Definition cmd-hist.cc:713
static string_vector list(int=-1, bool=false)
Definition cmd-hist.cc:748
static void write(const std::string &="")
Definition cmd-hist.cc:727
Definition oct-env.h:37
Provides threadsafe access to octave.
void append_history(const std::string &hist_entry)
void write_timestamp()
Definition oct-hist.cc:281
void do_edit_history(const octave_value_list &args=octave_value_list())
Definition oct-hist.cc:450
bool input_from_tmp_file() const
Definition oct-hist.h:58
history_system(interpreter &interp)
Definition oct-hist.cc:263
void do_run_history(const octave_value_list &args=octave_value_list())
Definition oct-hist.cc:513
octave_value timestamp_format_string(const octave_value_list &args, int nargout)
Definition oct-hist.cc:307
void initialize(bool read_history_file=false)
Definition oct-hist.cc:269
std::string timestamp_format_string() const
Definition oct-hist.h:71
string_vector do_history(const octave_value_list &args=octave_value_list(), int nargout=0)
Definition oct-hist.cc:321
environment & get_environment()
event_manager & get_event_manager()
octave_idx_type length() const
Definition ovl.h:111
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition ov.h:810
bool is_string() const
Definition ov.h:635
bool isnumeric() const
Definition ov.h:748
std::string string_value(bool force=false) const
Definition ov.h:981
octave_idx_type numel() const
Definition str-vec.h:98
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage()
Definition defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition defun.h:111
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition defun.h:56
void error(const char *fmt,...)
Definition error.cc:1008
void err_wrong_type_arg(const char *name, const char *s)
Definition errwarn.cc:166
event_manager & __get_event_manager__()
#define OCTAVE_VERSION
Definition main.in.cc:63
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition ovl.h:217
#define octave_stdout
Definition pager.h:301
interrupt_handler ignore_interrupts()
interrupt_handler set_interrupt_handler(const interrupt_handler &h, bool restart_syscalls)
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition variables.cc:583
F77_RET_T len
Definition xerbla.cc:61