annotate libinterp/corefcn/environment.cc @ 27102:84ff9953faa1

where possible, eliminate octave:: namespace qualifier inside octave namespace Affected files: file-editor-tab.cc, file-editor.cc, main-window.cc, octave-cmd.h, octave-qt-link.cc, settings-dialog.cc, call-stack.cc, environment.cc, ft-text-renderer.cc, gl2ps-print.cc, help.cc, input.cc, interpreter-private.cc, interpreter-private.h, interpreter.cc, load-path.cc, oct-hist.cc, oct-process.cc, oct-stream.cc, pager.cc, syminfo.cc, symtab.h, sysdep.cc, text-renderer.cc, utils.cc, gzip.cc, cdef-manager.cc, ov-fcn-handle.cc, ov-java.cc, jit-typeinfo.cc, oct-parse.yy, pt-eval.cc, pt-tm-const.cc, chol.cc, gsvd.cc, oct-rand.cc, oct-rand.h, randmtzig.cc, randpoisson.cc, file-ops.cc, lo-sysdep.cc, file-info.cc, oct-glob.cc, oct-sparse.cc, and url-transfer.cc.
author John W. Eaton <jwe@octave.org>
date Wed, 22 May 2019 13:57:30 +0000
parents 097774bed4ed
children b442ec6dda5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25460
diff changeset
3 Copyright (C) 2017-2019 John W. Eaton
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23719
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23719
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 (at your option) any later version.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 GNU General Public License for more details.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23719
diff changeset
19 <https://www.gnu.org/licenses/>.
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if defined (HAVE_CONFIG_H)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 # include "config.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <string>
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "dir-ops.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "oct-env.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "file-stat.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "pathsearch.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "str-vec.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
35 #include "defaults.h"
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "defun.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "environment.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "interpreter.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "variables.h"
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 namespace octave
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
43 static void append_to_shell_path (const std::string& exec_path)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
44 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
45 // FIXME: should there be a way to remove a previous setting from
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
46 // PATH?
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
47
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
48 if (exec_path.empty ())
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
49 return;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
50
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
51 // FIXME: should we really be modifying PATH in the environment?
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
52
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
53 std::string shell_path = sys::env::getenv ("PATH");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
54
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
55 if (shell_path.empty ())
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
56 sys::env::putenv ("PATH", exec_path);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
57 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
58 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
59 // If PATH doesn't already have exec_path, append it.
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
60 // FIXME: should we search for the elements individually, and
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
61 // only append those that are missing?
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
62
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
63 std::string path_sep = directory_path::path_sep_str ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
64
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
65 if (shell_path.find (exec_path) == std::string::npos)
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
66 sys::env::putenv ("PATH", shell_path + path_sep + exec_path);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
67 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
68 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
69
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 octave_value
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 environment::editor (const octave_value_list& args, int nargout)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 return set_internal_variable (m_editor, args, nargout, "EDITOR", false);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 octave_value
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 environment::exec_path (const octave_value_list& args, int nargout)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 octave_value retval
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 = set_internal_variable (m_exec_path, args, nargout, "EXEC_PATH", false);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 append_to_shell_path (m_exec_path);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 return retval;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 std::string environment::exec_path (const std::string& path)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 std::string old_val = set (m_exec_path, path);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 append_to_shell_path (m_exec_path);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 return old_val;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 octave_value
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 environment::image_path (const octave_value_list& args, int nargout)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 return set_internal_variable (m_image_path, args, nargout, "IMAGE_PATH",
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 false);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 std::string environment::init_editor (void)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 std::string retval = "emacs";
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
108 std::string env_editor = sys::env::getenv ("EDITOR");
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 if (! env_editor.empty ())
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 retval = env_editor;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 return retval;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
116 std::string environment::init_exec_path (void)
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
118 std::string exec_path = sys::env::getenv ("OCTAVE_EXEC_PATH");
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
120 std::string path_sep = directory_path::path_sep_str ();
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 if (exec_path.empty ())
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
123 exec_path = (config::local_ver_arch_lib_dir () + path_sep
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
124 + config::local_api_arch_lib_dir () + path_sep
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
125 + config::local_arch_lib_dir () + path_sep
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
126 + config::arch_lib_dir () + path_sep
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
127 + config::bin_dir ());
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 append_to_shell_path (exec_path);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 return exec_path;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
134 std::string environment::init_image_path (void)
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 std::string image_path = ".";
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
138 std::string path_sep = directory_path::path_sep_str ();
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
140 std::string env_path = sys::env::getenv ("OCTAVE_IMAGE_PATH");
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 if (! env_path.empty ())
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 image_path += path_sep + env_path;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
145 std::string gen_path = genpath (config::image_dir (), "");
23719
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 if (! gen_path.empty ())
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 image_path += path_sep + gen_path;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 return image_path;
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 DEFMETHOD (EDITOR, interp, args, nargout,
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 doc: /* -*- texinfo -*-
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 @deftypefn {} {@var{val} =} EDITOR ()
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 @deftypefnx {} {@var{old_val} =} EDITOR (@var{new_val})
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 @deftypefnx {} {} EDITOR (@var{new_val}, "local")
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 Query or set the internal variable that specifies the default text editor.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 The default value is taken from the environment variable @w{@env{EDITOR}}
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 when Octave starts. If the environment variable is not initialized,
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 @w{@env{EDITOR}} will be set to @qcode{"emacs"}.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165 When called from inside a function with the @qcode{"local"} option, the
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 variable is changed locally for the function and any subroutines it calls.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 The original variable value is restored when exiting the function.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 @seealso{edit, edit_history}
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 @end deftypefn */)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 octave::environment& env = interp.get_environment ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 return env.editor (args, nargout);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 /*
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 %!test
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 %! orig_val = EDITOR ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180 %! old_val = EDITOR ("X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181 %! assert (orig_val, old_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182 %! assert (EDITOR (), "X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183 %! EDITOR (orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184 %! assert (EDITOR (), orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 %!error (EDITOR (1, 2))
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 */
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189 DEFMETHOD (EXEC_PATH, interp, args, nargout,
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 doc: /* -*- texinfo -*-
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191 @deftypefn {} {@var{val} =} EXEC_PATH ()
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 @deftypefnx {} {@var{old_val} =} EXEC_PATH (@var{new_val})
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 @deftypefnx {} {} EXEC_PATH (@var{new_val}, "local")
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194 Query or set the internal variable that specifies a colon separated
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195 list of directories to append to the shell PATH when executing external
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196 programs.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198 The initial value of is taken from the environment variable
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 @w{@env{OCTAVE_EXEC_PATH}}, but that value can be overridden by the command
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 line argument @option{--exec-path PATH}.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 When called from inside a function with the @qcode{"local"} option, the
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203 variable is changed locally for the function and any subroutines it calls.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 The original variable value is restored when exiting the function.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206 @seealso{IMAGE_PATH, OCTAVE_HOME, OCTAVE_EXEC_HOME}
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 @end deftypefn */)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 octave::environment& env = interp.get_environment ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 return env.exec_path (args, nargout);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214 /*
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215 %!test
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216 %! orig_val = EXEC_PATH ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217 %! old_val = EXEC_PATH ("X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
218 %! assert (orig_val, old_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219 %! assert (EXEC_PATH (), "X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220 %! EXEC_PATH (orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221 %! assert (EXEC_PATH (), orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223 %!error (EXEC_PATH (1, 2))
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 */
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 DEFMETHOD (IMAGE_PATH, interp, args, nargout,
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
227 doc: /* -*- texinfo -*-
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 @deftypefn {} {@var{val} =} IMAGE_PATH ()
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229 @deftypefnx {} {@var{old_val} =} IMAGE_PATH (@var{new_val})
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230 @deftypefnx {} {} IMAGE_PATH (@var{new_val}, "local")
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231 Query or set the internal variable that specifies a colon separated
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
232 list of directories in which to search for image files.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
233
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
234 When called from inside a function with the @qcode{"local"} option, the
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
235 variable is changed locally for the function and any subroutines it calls.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236 The original variable value is restored when exiting the function.
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
237
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
238 @seealso{EXEC_PATH, OCTAVE_HOME, OCTAVE_EXEC_HOME}
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
239 @end deftypefn */)
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240 {
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
241 octave::environment& env = interp.get_environment ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
243 return env.image_path (args, nargout);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244 }
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246 /*
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
247 %!test
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
248 %! orig_val = IMAGE_PATH ();
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
249 %! old_val = IMAGE_PATH ("X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250 %! assert (orig_val, old_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
251 %! assert (IMAGE_PATH (), "X");
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
252 %! IMAGE_PATH (orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
253 %! assert (IMAGE_PATH (), orig_val);
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
254
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
255 %!error (IMAGE_PATH (1, 2))
69a111259a2c eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256 */