Mercurial > octave-nkf
annotate scripts/miscellaneous/edit.m @ 7540:3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 28 Feb 2008 02:41:19 -0500 |
parents | 2ce6b4258e96 |
children | eb7bdde776f2 |
rev | line source |
---|---|
7325 | 1 ## Copyright (C) 2001, 2007 Paul Kienzle |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Command} edit @var{name} | |
21 ## @deftypefnx {Command} edit @var{field} @var{value} | |
22 ## @deftypefnx {Command} @var{value} = edit get @var{field} | |
23 ## Edit the named function, or change editor settings. | |
24 ## | |
25 ## If @code{edit} is called with the name of a file or function as | |
26 ## its argument it will be opened in a text editor. | |
27 ## | |
28 ## @itemize @bullet | |
29 ## @item | |
30 ## If the function @var{name} is available in a file on your path and | |
31 ## that file is modifiable, then it will be edited in place. If it | |
32 ## is a system function, then it will first be copied to the directory | |
33 ## @code{HOME} (see further down) and then edited. | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
34 ## If no file is found, then the m-file |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
35 ## variant, ending with ".m", will be considered. If still no file |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
36 ## is found, then variants with a leading "@@" and then with both a |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
37 ## leading "@@" and trailing ".m" will be considered. |
7325 | 38 ## |
39 ## @item | |
40 ## If @var{name} is the name of a function defined in the interpreter but | |
41 ## not in an m-file, then an m-file will be created in @code{HOME} | |
42 ## to contain that function along with its current definition. | |
43 ## | |
44 ## @item | |
45 ## If @code{name.cc} is specified, then it will search for @code{name.cc} | |
46 ## in the path and try to modify it, otherwise it will create a new | |
47 ## @file{.cc} file in @code{HOME}. If @var{name} happens to be an | |
48 ## m-file or interpreter defined function, then the text of that | |
49 ## function will be inserted into the .cc file as a comment. | |
50 ## | |
51 ## @item | |
52 ## If @var{name.ext} is on your path then it will be editted, otherwise | |
53 ## the editor will be started with @file{HOME/name.ext} as the | |
54 ## filename. If @file{name.ext} is not modifiable, it will be copied to | |
55 ## @code{HOME} before editing. | |
56 ## | |
57 ## @strong{WARNING!} You may need to clear name before the new definition | |
58 ## is available. If you are editing a .cc file, you will need | |
59 ## to mkoctfile @file{name.cc} before the definition will be available. | |
60 ## @end itemize | |
61 ## | |
62 ## If @code{edit} is called with @var{field} and @var{value} variables, | |
63 ## the value of the control field @var{field} will be @var{value}. | |
64 ## If an output argument is requested and the first argument is @code{get} | |
65 ## then @code{edit} will return the value of the control field @var{field}. | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
66 ## If the control field does not exist, edit will return a structure |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
67 ## containing all fields and values. Thus, @code{edit get all} returns |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
68 ## a complete control structure. |
7325 | 69 ## The following control fields are used: |
70 ## | |
71 ## @table @samp | |
72 ## @item editor | |
73 ## This is the editor to use to modify the functions. By default it uses | |
74 ## Octave's @code{EDITOR} built-in function, which comes from | |
75 ## @code{getenv("EDITOR")} and defaults to @code{emacs}. Use @code{%s} | |
76 ## In place of the function name. For example, | |
77 ## @table @samp | |
78 ## @item [EDITOR, " %s"] | |
79 ## Use the editor which Octave uses for @code{bug_report}. | |
80 ## @item "xedit %s &" | |
81 ## pop up simple X11 editor in a separate window | |
82 ## @item "gnudoit -q \"(find-file \\\"%s\\\")\"" | |
83 ## Send it to current Emacs; must have @code{(gnuserv-start)} in @file{.emacs}. | |
84 ## @end table | |
85 ## | |
86 ## On cygwin, you will need to convert the cygwin path to a windows | |
87 ## path if you are using a native Windows editor. For example | |
88 ## @example | |
89 ## '"C:/Program Files/Good Editor/Editor.exe" "$(cygpath -wa %s)"' | |
90 ## @end example | |
91 ## | |
92 ## @item home | |
93 ## This is the location of user local m-files. Be be sure it is in your | |
94 ## path. The default is @file{~/octave}. | |
95 ## | |
96 ## @item author | |
97 ## This is the name to put after the "## Author:" field of new functions. | |
98 ## By default it guesses from the @code{gecos} field of password database. | |
99 ## | |
100 ## @item email | |
101 ## This is the e-mail address to list after the name in the author field. | |
102 ## By default it guesses @code{<$LOGNAME@@$HOSTNAME>}, and if @code{$HOSTNAME} | |
103 ## is not defined it uses @code{uname -n}. You probably want to override this. | |
104 ## Be sure to use @code{<user@@host>} as your format. | |
105 ## | |
106 ## @item license | |
107 ## @table @samp | |
108 ## @item gpl | |
109 ## GNU General Public License (default). | |
110 ## @item bsd | |
111 ## BSD-style license without advertising clause. | |
112 ## @item pd | |
113 ## Public domain. | |
114 ## @item "text" | |
115 ## Your own default copyright and license. | |
116 ## @end table | |
117 ## | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
118 ## Unless you specify @samp{pd}, edit will prepend the copyright statement |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
119 ## with "Copyright (C) yyyy Function Author". |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
120 ## |
7325 | 121 ## @item mode |
122 ## This value determines whether the editor should be started in async mode | |
123 ## or sync mode. Set it to "async" to start the editor in async mode. The | |
124 ## default is "sync" (see also "system"). | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
125 ## |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
126 ## @item editinplace |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
127 ## Determines whether files should be edited in place, without regard to |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
128 ## whether they are modifiable or not. The default is @code{false}. |
7325 | 129 ## @end table |
130 ## @end deftypefn | |
131 | |
132 ## Author: Paul Kienzle <pkienzle@users.sf.net> | |
133 | |
134 ## Original version by Paul Kienzle distributed as free software in the | |
135 ## public domain. | |
136 | |
137 ## PKG_ADD: mark_as_command edit | |
138 | |
139 function ret = edit (file, state) | |
140 | |
141 ## Pick up globals or default them. | |
142 | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
143 persistent FUNCTION = struct ("EDITOR", cstrcat (EDITOR (), " %s"), |
7325 | 144 "HOME", fullfile (default_home, "octave"), |
145 "AUTHOR", default_user(1), | |
146 "EMAIL", [], | |
147 "LICENSE", "GPL", | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
148 "MODE", "sync", |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
149 "EDITINPLACE", false); |
7325 | 150 |
151 mlock; # make sure the state variables survive "clear functions" | |
152 | |
153 if (nargin == 2) | |
154 switch (toupper (file)) | |
155 case "EDITOR" | |
156 FUNCTION.EDITOR = state; | |
157 case "HOME" | |
158 if (! isempty (state) && state(1) == "~") | |
159 state = [ default_home, state(2:end) ]; | |
160 endif | |
161 FUNCTION.HOME = state; | |
162 case "AUTHOR" | |
163 FUNCTION.AUTHOR = state; | |
164 case "EMAIL" | |
165 FUNCTION.EMAIL = state; | |
166 case "LICENSE" | |
167 FUNCTION.LICENSE = state; | |
168 case "MODE" | |
169 if (strcmp (state, "sync") || strcmp (state, "async")) | |
170 FUNCTION.MODE = state; | |
171 else | |
172 error('expected "edit MODE sync|async"'); | |
173 endif | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
174 case "EDITINPLACE" |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
175 if (ischar (state)) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
176 if (strcmpi (state, "true")) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
177 state = true; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
178 elseif (strcmpi (state, "false")) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
179 state = false; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
180 else |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
181 state = eval (state); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
182 endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
183 endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
184 FUNCTION.EDITINPLACE = state; |
7325 | 185 case "GET" |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
186 if (isfield (FUNCTION, toupper(state))) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
187 ret = FUNCTION.(toupper (state)); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
188 else |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
189 ret = FUNCTION; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
190 endif |
7325 | 191 otherwise |
192 error ("expected \"edit EDITOR|HOME|AUTHOR|EMAIL|LICENSE|MODE val\""); | |
193 endswitch | |
194 return | |
195 endif | |
196 | |
197 ## Start the editor without a file if no file is given. | |
198 if (nargin < 1) | |
199 if (exist (FUNCTION.HOME, "dir") == 7 && (isunix () || ! ispc ())) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
200 system (cstrcat ("cd \"", FUNCTION.HOME, "\" ; ", |
7325 | 201 sprintf (FUNCTION.EDITOR, "")), |
202 [], FUNCTION.MODE); | |
203 else | |
204 system (sprintf (FUNCTION.EDITOR,""), [], FUNCTION.MODE); | |
205 endif | |
206 return; | |
207 endif | |
208 | |
209 ## Check whether the user is trying to edit a builtin of compiled function. | |
210 switch (exist (file)) | |
211 case {3, 5} | |
212 error ("unable to edit a built-in or compiled function"); | |
213 endswitch | |
214 | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
215 ## Checks for whether the file is |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
216 ## absolute or relative should be handled inside file_in_loadpath. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
217 ## That way, it will be possible to look up files correctly given |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
218 ## partial path information. For example, you should be able to |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
219 ## edit a particular overloaded function by doing any one of |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
220 ## |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
221 ## edit classname/foo |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
222 ## edit classname/foo.m |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
223 ## edit @classname/foo |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
224 ## edit @classname/foo.m |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
225 ## |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
226 ## This functionality is needed for other functions as well (at least |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
227 ## help and type; there may be more). So the place to fix that is in |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
228 ## file_in_loadpath, possibly with some help from the load_path class. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
229 |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
230 ## The code below includes a portion that serves as a place-holder for |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
231 ## the changes suggested above. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
232 |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
233 ## Create list of explicit and implicit file names. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
234 filelist = {file}; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
235 ## If file has no extension, add file.m and file.cc to the list. |
7325 | 236 idx = rindex (file, "."); |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
237 if (idx == 0) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
238 ## Create the list of files to look for |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
239 filelist = {file}; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
240 if (isempty (regexp (file, "\\.m$"))) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
241 ## No ".m" at the end of the file, add to the list. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
242 filelist{end+1} = cat (2, file, ".m"); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
243 endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
244 if (isempty (regexp (file, "\\.cc$"))) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
245 ## No ".cc" at the end of the file, add to the list. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
246 filelist{end+1} = cat (2, file, ".cc"); |
7325 | 247 endif |
248 endif | |
249 | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
250 ## If the file includes a path, it may be an overloaded function. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
251 if (! strcmp (file, "@") && index (file, filesep)) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
252 ## No "@" at the beginning of the file, add to the list. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
253 numfiles = numel(filelist); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
254 for n = 1:numfiles |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
255 filelist{n+numfiles} = cat (2, "@", filelist{n}); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
256 endfor |
7325 | 257 endif |
258 | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
259 ## Search the entire path for the 1st instance of a file in the list. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
260 fileandpath = ""; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
261 for n = 1:numel(filelist) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
262 filetoedit = file_in_path (path, filelist{n}); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
263 if (! isempty (filetoedit)) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
264 ## The path is explicitly included. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
265 fileandpath = filetoedit; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
266 break; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
267 endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
268 endfor |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
269 |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
270 if (! isempty (fileandpath)) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
271 ## If the file exists, then edit it. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
272 if (FUNCTION.EDITINPLACE) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
273 ## Edit in place even if it is protected. |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
274 system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
275 [], FUNCTION.MODE); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
276 return; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
277 else |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
278 ## If the file is modifiable in place then edit it, otherwise make |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
279 ## a copy in HOME and then edit it. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
280 fid = fopen (fileandpath, "r+t"); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
281 if (fid < 0) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
282 from = fileandpath; |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
283 fileandpath = cstrcat (FUNCTION.HOME, from (rindex (from, filesep):end)); |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
284 [status, msg] = copyfile (from, fileandpath, 1); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
285 if (status == 0) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
286 error (msg); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
287 endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
288 else |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
289 fclose (fid); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
290 endif |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
291 system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
292 [], FUNCTION.MODE); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
293 return; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
294 endif |
7325 | 295 endif |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
296 |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
297 ## If editing a new file that is neither a m-file or an oct-file, |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
298 ## just edit it. |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
299 fileandpath = file; |
7325 | 300 idx = rindex (file, "."); |
301 name = file(1:idx-1); | |
302 ext = file(idx+1:end); | |
303 switch (ext) | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
304 case {"cc", "m"} |
7325 | 305 0; |
306 otherwise | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
307 system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), |
7325 | 308 [], FUNCTION.MODE); |
309 return; | |
310 endswitch | |
311 | |
312 ## The file doesn't exist in path so create it, put in the function | |
313 ## template and edit it. | |
314 | |
315 ## Guess the email name if it was not given. | |
316 if (isempty (FUNCTION.EMAIL)) | |
317 host = getenv("HOSTNAME"); | |
318 if (isempty (host) && ispc ()) | |
319 host = getenv ("COMPUTERNAME"); | |
320 endif | |
321 if (isempty (host)) | |
322 [status, host] = system ("uname -n"); | |
323 ## trim newline from end of hostname | |
324 if (! isempty (host)) | |
325 host = host(1:end-1); | |
326 endif | |
327 endif | |
328 if (isempty (host)) | |
329 FUNCTION.EMAIL = " "; | |
330 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
331 FUNCTION.EMAIL = cstrcat ("<", default_user(0), "@", host, ">"); |
7325 | 332 endif |
333 endif | |
334 | |
335 ## Fill in the revision string. | |
336 now = localtime (time); | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
337 revs = cstrcat ("Created: ", strftime ("%Y-%m-%d", now)); |
7325 | 338 |
339 ## Fill in the copyright string. | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
340 copyright = cstrcat (strftime ("Copyright (C) %Y ", now), FUNCTION.AUTHOR); |
7325 | 341 |
342 ## Fill in the author tag field. | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
343 author = cstrcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL); |
7325 | 344 |
345 ## Fill in the header. | |
346 uclicense = toupper (FUNCTION.LICENSE); | |
347 switch (uclicense) | |
348 case "GPL" | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
349 head = cstrcat (copyright, "\n\n", "\ |
7325 | 350 This program is free software; you can redistribute it and/or modify\n\ |
351 it under the terms of the GNU General Public License as published by\n\ | |
352 the Free Software Foundation; either version 2 of the License, or\n\ | |
353 (at your option) any later version.\n\ | |
354 \n\ | |
355 This program is distributed in the hope that it will be useful,\n\ | |
356 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ | |
357 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ | |
358 GNU General Public License for more details.\n\ | |
359 \n\ | |
360 You should have received a copy of the GNU General Public License\n\ | |
7444 | 361 along with Octave; see the file COPYING. If not, see\n\ |
362 <http://www.gnu.org/licenses/>.\ | |
7325 | 363 "); |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
364 tail = cstrcat (author, "\n", revs); |
7325 | 365 |
366 case "BSD" | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
367 head = cstrcat (copyright, "\n\n", "\ |
7325 | 368 This program is free software; redistribution and use in source and\n\ |
369 binary forms, with or without modification, are permitted provided that\n\ | |
370 the following conditions are met:\n\ | |
371 \n\ | |
372 1.Redistributions of source code must retain the above copyright\n\ | |
373 notice, this list of conditions and the following disclaimer.\n\ | |
374 2.Redistributions in binary form must reproduce the above copyright\n\ | |
375 notice, this list of conditions and the following disclaimer in the\n\ | |
376 documentation and/or other materials provided with the distribution.\n\ | |
377 \n\ | |
378 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n\ | |
379 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\ | |
380 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\ | |
381 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n\ | |
382 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\ | |
383 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n\ | |
384 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n\ | |
385 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n\ | |
386 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n\ | |
387 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n\ | |
388 SUCH DAMAGE.\ | |
389 "); | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
390 tail = cstrcat (author, "\n", revs); |
7325 | 391 |
392 case "PD" | |
393 head = ""; | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
394 tail = cstrcat (author, "\n", revs, "\n\n", |
7434 | 395 "This program is granted to the public domain."); |
7325 | 396 |
397 otherwise | |
398 head = ""; | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
399 tail = cstrcat (copyright, "\n\n", FUNCTION.LICENSE, "\n", |
7434 | 400 author, "\n", revs); |
7325 | 401 endswitch |
402 | |
403 ## Generate the function template. | |
404 exists = exist (name); | |
405 switch (ext) | |
406 case {"cc", "C", "cpp"} | |
407 if (isempty (head)) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
408 comment = cstrcat ("/*\n", tail, "\n\n*/\n\n"); |
7325 | 409 else |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
410 comment = cstrcat ("/*\n", head, "\n\n", tail, "\n\n*/\n\n"); |
7325 | 411 endif |
412 ## If we are shadowing an m-file, paste the code for the m-file. | |
413 if (any (exists == [2, 103])) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
414 code = cstrcat ("\\ ", strrep (type (name), "\n", "\n// ")); |
7325 | 415 else |
416 code = " "; | |
417 endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
418 body = cstrcat ("#include <octave/oct.h>\n\n", |
7325 | 419 "DEFUN_DLD(", name, ",args,nargout,\"\\\n", |
420 name, "\\n\\\n\")\n{\n", | |
421 " octave_value_list retval;\n", | |
422 " int nargin = args.length();\n\n", | |
423 code, "\n return retval;\n}\n"); | |
424 | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
425 text = cstrcat (comment, body); |
7325 | 426 case "m" |
427 ## If we are editing a function defined on the fly, paste the | |
428 ## code. | |
429 if (any (exists == [2, 103])) | |
430 body = type (name); | |
431 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
432 body = cstrcat ("function [ ret ] = ", name, " ()\n\nendfunction\n"); |
7325 | 433 endif |
434 if (isempty (head)) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
435 comment = cstrcat ("## ", name, "\n\n", |
7325 | 436 "## ", strrep (tail, "\n", "\n## "), "\n\n"); |
437 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
438 comment = cstrcat ("## ", strrep(head,"\n","\n## "), "\n\n", ... |
7325 | 439 "## ", name, "\n\n", ... |
440 "## ", strrep (tail, "\n", "\n## "), "\n\n"); | |
441 endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
442 text = cstrcat (comment, body); |
7325 | 443 endswitch |
444 | |
445 ## Write the initial file (if there is anything to write) | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
446 fid = fopen (fileandpath, "wt"); |
7325 | 447 if (fid < 0) |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
448 error ("edit: could not create %s", fileandpath); |
7325 | 449 endif |
450 fputs (fid, text); | |
451 fclose (fid); | |
452 | |
453 ## Finally we are ready to edit it! | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7502
diff
changeset
|
454 system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), |
7325 | 455 [], FUNCTION.MODE); |
456 | |
457 endfunction | |
458 | |
459 function ret = default_home () | |
460 | |
461 ret = getenv ("HOME"); | |
462 if (isempty (ret)) | |
463 ret = glob ("~"); | |
464 if (! isempty (ret)) | |
465 ret = ret{1}; | |
466 else | |
467 ret = ""; | |
468 endif | |
469 endif | |
470 | |
471 endfunction | |
472 | |
7434 | 473 ## Return the name associated with the current user ID. |
7325 | 474 ## |
7434 | 475 ## If LONG_FORM is 1, return the full name. This will be the |
476 ## default author. Otherwise return the login name. | |
7325 | 477 ## login@host will be the default email address. |
478 | |
479 function ret = default_user (long_form) | |
480 | |
481 ent = getpwuid (getuid); | |
482 if (! isstruct (ent)) | |
483 ret = getenv ("USER"); | |
7330 | 484 if (isempty (ret)) |
7325 | 485 ret = getenv ("USERNAME"); |
486 endif | |
487 elseif (long_form) | |
488 ret = ent.gecos; | |
7434 | 489 pos = strfind (ret, ","); |
490 if (! isempty (pos)) | |
491 ret = ret(1:pos-1); | |
492 endif | |
7325 | 493 else |
494 ret = ent.name; | |
495 endif | |
496 | |
497 endfunction | |
7502
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
498 |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
499 %!test |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
500 %! s.editor = edit get editor; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
501 %! s.home = edit get home; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
502 %! s.author = edit get author; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
503 %! s.email = edit get email; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
504 %! s.license = edit get license; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
505 %! s.editinplace = edit get editinplace; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
506 %! s.mode = edit get mode; |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
507 %! edit editor none |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
508 %! edit home none |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
509 %! edit author none |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
510 %! edit email none |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
511 %! edit license none |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
512 %! edit ("editinplace", !s.editinplace) |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
513 %! if (s.mode(1) == "a") |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
514 %! edit mode sync |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
515 %! else |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
516 %! edit mode async |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
517 %! endif |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
518 %! edit ("editor", s.editor); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
519 %! edit ("home", s.home); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
520 %! edit ("author", s.author); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
521 %! edit ("email", s.email); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
522 %! edit ("license", s.license); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
523 %! edit ("editinplace", s.editinplace); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
524 %! edit ("mode", s.mode); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
525 %! assert (edit ("get", "editor"), s.editor); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
526 %! assert (edit ("get", "home"), s.home); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
527 %! assert (edit ("get", "author"), s.author); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
528 %! assert (edit ("get", "email"), s.email); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
529 %! assert (edit ("get", "license"), s.license); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
530 %! assert (edit ("get", "editinplace"), s.editinplace); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
531 %! assert (edit ("get", "mode"), s.mode); |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
532 |