Mercurial > octave-antonio
annotate scripts/miscellaneous/edit.m @ 20164:df437a52bcaf stable
doc: Update more docstrings to have one sentence summary as first line.
Reviewed miscellaneous, sparse, strings in scripts directory.
* scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m,
scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m,
scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m,
scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m,
scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m,
scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m,
scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m,
scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m,
scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m,
scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m,
scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m,
scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m,
scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m,
scripts/sparse/treeplot.m, scripts/strings/base2dec.m,
scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m,
scripts/strings/deblank.m, scripts/strings/dec2base.m,
scripts/strings/dec2bin.m, scripts/strings/dec2hex.m,
scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m,
scripts/strings/isletter.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/ostrsplit.m,
scripts/strings/regexptranslate.m, scripts/strings/rindex.m,
scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m,
scripts/strings/strjoin.m, scripts/strings/strjust.m,
scripts/strings/strmatch.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/strings/untabify.m, scripts/time/datenum.m:
Update more docstrings to have one sentence summary as first line.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 May 2015 14:22:02 -0700 |
parents | 002576bbba10 |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
1 ## Copyright (C) 2001-2015 Paul Kienzle |
7325 | 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 -*- | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9153
diff
changeset
|
20 ## @deftypefn {Command} {} edit @var{name} |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9153
diff
changeset
|
21 ## @deftypefnx {Command} {} edit @var{field} @var{value} |
7650 | 22 ## @deftypefnx {Command} {@var{value} =} edit get @var{field} |
7325 | 23 ## Edit the named function, or change editor settings. |
24 ## | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
25 ## If @code{edit} is called with the name of a file or function as its |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
26 ## argument it will be opened in the text editor defined by @env{EDITOR}. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
27 ## |
7325 | 28 ## @itemize @bullet |
29 ## @item | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
30 ## If the function @var{name} is available in a file on your path and that |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
31 ## file is modifiable, then it will be edited in place. If it is a system |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
32 ## function, then it will first be copied to the directory @env{HOME} (see |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
33 ## below) and then edited. If no file is found, then the m-file variant, |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
34 ## ending with @qcode{".m"}, will be considered. If still no file is found, |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
35 ## then variants with a leading @qcode{"@@"} and then with both a leading |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
36 ## @qcode{"@@"} and trailing @qcode{".m"} will be considered. |
7325 | 37 ## |
38 ## @item | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
39 ## If @var{name} is the name of a function defined in the interpreter but not |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
40 ## in an m-file, then an m-file will be created in @env{HOME} to contain that |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
41 ## function along with its current definition. |
7325 | 42 ## |
43 ## @item | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
44 ## If @code{@var{name}.cc} is specified, then it will search for |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
45 ## @code{@var{name}.cc} in the path and try to modify it, otherwise it will |
17753
887df64e54e4
doc: Final grammarcheck of docstrings for 3.8 release.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
46 ## create a new @file{.cc} file in the current directory. If @var{name} happens |
17738
0cfdb818ccb8
* edit.m: update documentation, new files are created in current directory
Torsten <ttl@justmail.de>
parents:
17593
diff
changeset
|
47 ## to be an m-file or interpreter defined function, then the text of that |
7325 | 48 ## function will be inserted into the .cc file as a comment. |
49 ## | |
50 ## @item | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
51 ## If @file{@var{name}.ext} is on your path then it will be edited, otherwise |
17738
0cfdb818ccb8
* edit.m: update documentation, new files are created in current directory
Torsten <ttl@justmail.de>
parents:
17593
diff
changeset
|
52 ## the editor will be started with @file{@var{name}.ext} in the current |
17753
887df64e54e4
doc: Final grammarcheck of docstrings for 3.8 release.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 ## directory as the filename. If @file{@var{name}.ext} is not modifiable, |
17738
0cfdb818ccb8
* edit.m: update documentation, new files are created in current directory
Torsten <ttl@justmail.de>
parents:
17593
diff
changeset
|
54 ## it will be copied to @env{HOME} before editing. |
7325 | 55 ## |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
56 ## @strong{Warning:} You may need to clear @var{name} before the new definition |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
57 ## is available. If you are editing a .cc file, you will need to execute |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
58 ## @code{mkoctfile @file{@var{name}.cc}} before the definition will be |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
59 ## available. |
7325 | 60 ## @end itemize |
61 ## | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
62 ## If @code{edit} is called with @var{field} and @var{value} variables, the |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
63 ## value of the control field @var{field} will be set to @var{value}. If an |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
64 ## output argument is requested and the first input argument is @code{get} |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
65 ## then @code{edit} will return the value of the control field @var{field}. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
66 ## If the control field does not exist, edit will return a structure |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
67 ## containing all fields and values. Thus, @code{edit get all} returns a |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
68 ## complete control structure. |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
69 ## |
7325 | 70 ## The following control fields are used: |
71 ## | |
72 ## @table @samp | |
73 ## @item home | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
74 ## This is the location of user local m-files. Be sure it is in your path. |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
75 ## The default is @file{~/octave}. |
7325 | 76 ## |
77 ## @item author | |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
78 ## This is the name to put after the "## Author:" field of new functions. By |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
79 ## default it guesses from the @code{gecos} field of the password database. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
80 ## |
7325 | 81 ## @item email |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
82 ## This is the e-mail address to list after the name in the author field. By |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
83 ## default it guesses @code{<$LOGNAME@@$HOSTNAME>}, and if @code{$HOSTNAME} |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
84 ## is not defined it uses @code{uname -n}. You probably want to override |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20019
diff
changeset
|
85 ## this. Be sure to use the format @code{@email{user@@host}}. |
7325 | 86 ## |
87 ## @item license | |
14366
b76f0740940e
doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
88 ## |
7325 | 89 ## @table @samp |
90 ## @item gpl | |
91 ## GNU General Public License (default). | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
92 ## |
7325 | 93 ## @item bsd |
94 ## BSD-style license without advertising clause. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
95 ## |
7325 | 96 ## @item pd |
97 ## Public domain. | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
98 ## |
7325 | 99 ## @item "text" |
100 ## Your own default copyright and license. | |
101 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
102 ## |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
103 ## Unless you specify @samp{pd}, edit will prepend the copyright statement |
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
|
104 ## with "Copyright (C) yyyy Function Author". |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
105 ## |
7325 | 106 ## @item mode |
107 ## This value determines whether the editor should be started in async mode | |
8795
bb38a86efa1b
improve documentation for edit.m
Ivan Sutoris <ivan.sutoris@gmail.com>
parents:
8746
diff
changeset
|
108 ## (editor is started in the background and Octave continues) or sync mode |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17245
diff
changeset
|
109 ## (Octave waits until the editor exits). Set it to @qcode{"sync"} to start |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17245
diff
changeset
|
110 ## the editor in sync mode. The default is @qcode{"async"} |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17245
diff
changeset
|
111 ## (@pxref{XREFsystem,,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
|
112 ## |
2ce6b4258e96
Modified for consistency with Matlab. Modified to respect partial paths needed for overloaded functions.
Ben Abbott <bpabbott@mac.com>
parents:
7444
diff
changeset
|
113 ## @item editinplace |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
114 ## Determines whether files should be edited in place, without regard to |
9038
fca0dc2fb042
Cleanup documentation files stmt.texi and func.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
115 ## whether they are modifiable or not. The default is @code{false}. |
7325 | 116 ## @end table |
117 ## @end deftypefn | |
118 | |
119 ## Author: Paul Kienzle <pkienzle@users.sf.net> | |
120 | |
121 ## Original version by Paul Kienzle distributed as free software in the | |
122 ## public domain. | |
123 | |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
124 function ret = edit (varargin) |
7325 | 125 |
126 ## Pick up globals or default them. | |
127 | |
20017
4b7b7ac7af2c
use get_home_directory instead of getenv ("HOME") (bug #44694)
John W. Eaton <jwe@octave.org>
parents:
19833
diff
changeset
|
128 persistent FUNCTION = struct ("HOME", |
4b7b7ac7af2c
use get_home_directory instead of getenv ("HOME") (bug #44694)
John W. Eaton <jwe@octave.org>
parents:
19833
diff
changeset
|
129 fullfile (get_home_directory (), "octave"), |
10549 | 130 "AUTHOR", default_user(1), |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
131 "EMAIL", [], |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
132 "LICENSE", "GPL", |
12207
c37f167a816a
edit.m: As most editors open their own window, change mode to "async".
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
133 "MODE", "async", |
10549 | 134 "EDITINPLACE", false); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
135 ## Make sure the stateval variables survive "clear functions". |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17312
diff
changeset
|
136 mlock; |
7325 | 137 |
17991
22187db555cf
Remove editor option from edit() and use only EDITOR() (bug #40600)
Carnë Draug <carandraug@octave.org>
parents:
17884
diff
changeset
|
138 ## Get default editor every time in case the user has changed it |
22187db555cf
Remove editor option from edit() and use only EDITOR() (bug #40600)
Carnë Draug <carandraug@octave.org>
parents:
17884
diff
changeset
|
139 FUNCTION.EDITOR = [EDITOR() " %s"]; |
22187db555cf
Remove editor option from edit() and use only EDITOR() (bug #40600)
Carnë Draug <carandraug@octave.org>
parents:
17884
diff
changeset
|
140 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
141 if (nargin == 1) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
142 ## User has supplied one arg, this can be a single file name |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
143 ## or a cell array of strings containing multiple files to be opened |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
144 if (iscellstr (varargin{1})) |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18011
diff
changeset
|
145 ## If first arg is a cell array of strings, |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
146 ## it becomes the list of files to be edited |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
147 editfilelist = varargin{1}; |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
148 elseif (ischar (varargin{1})) |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
149 ## If first arg is a string, create a cell array of strings |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
150 ## of length 1 (by copying the input cell array) |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
151 editfilelist = varargin(1); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
152 else |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
153 error ("edit: expected file to be a string or cell array of strings"); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
154 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
155 elseif (nargin == 2) |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
156 ## User has supplied two arguments, these could be two file names, |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
157 ## or a combination of editor state name and new value for that state, |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
158 ## so first check for the various states |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
159 statevar = varargin{1}; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
160 stateval = varargin{2}; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
161 switch (toupper (statevar)) |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
162 case "EDITOR" |
17991
22187db555cf
Remove editor option from edit() and use only EDITOR() (bug #40600)
Carnë Draug <carandraug@octave.org>
parents:
17884
diff
changeset
|
163 error ("Octave:deprecated-function", |
18011
0d6d0a7c0793
edit.m: Use two spaces to mark sentence break in error() message.
Rik <rik@octave.org>
parents:
17991
diff
changeset
|
164 "The EDITOR option of edit has been removed. Use EDITOR() directly.") |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
165 return; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
166 case "HOME" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
167 if (! isempty (stateval) && stateval(1) == "~") |
20017
4b7b7ac7af2c
use get_home_directory instead of getenv ("HOME") (bug #44694)
John W. Eaton <jwe@octave.org>
parents:
19833
diff
changeset
|
168 stateval = [ get_home_directory, stateval(2:end) ]; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
169 endif |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
170 FUNCTION.HOME = stateval; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
171 return; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
172 case "AUTHOR" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
173 FUNCTION.AUTHOR = stateval; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
174 return; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
175 case "EMAIL" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
176 FUNCTION.EMAIL = stateval; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
177 return; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
178 case "LICENSE" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
179 FUNCTION.LICENSE = stateval; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
180 return; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
181 case "MODE" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
182 if (strcmp (stateval, "sync") || strcmp (stateval, "async")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
183 FUNCTION.MODE = stateval; |
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
|
184 else |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
185 error ('edit: expected "edit MODE sync|async"'); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
186 endif |
17312
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
187 return; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
188 case "EDITINPLACE" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
189 if (ischar (stateval)) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
190 if (strcmpi (stateval, "true")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
191 stateval = true; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
192 elseif (strcmpi (stateval, "false")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
193 stateval = false; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
194 else |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
195 stateval = eval (stateval); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
196 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
|
197 endif |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
198 FUNCTION.EDITINPLACE = stateval; |
17312
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
199 return; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
200 case "GET" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
201 if (isfield (FUNCTION, toupper (stateval))) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
202 ret = FUNCTION.(toupper (stateval)); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
203 else |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
204 ret = FUNCTION; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
205 endif |
17312
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
206 return; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
207 otherwise |
17592
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
208 ## If none of the states match, assume both inputs are actually |
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
209 ## file names to be opened. |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17171
diff
changeset
|
210 editfilelist = varargin; |
7325 | 211 endswitch |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
212 elseif (nargin > 2) |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
213 if (iscellstr (varargin)) |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
214 editfilelist = varargin; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
215 else |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
216 error ("edit: if supplying more than one input all inputs must be strings containing field names to open."); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
217 endif |
7325 | 218 endif |
219 | |
220 ## Start the editor without a file if no file is given. | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
221 if (nargin == 0) |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
222 if (exist (FUNCTION.HOME, "dir") == 7) |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
223 curr_dir = pwd (); |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
224 unwind_protect |
19280
98a18bc3208e
Use cd rather than chdir in core Octave code.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
225 cd (FUNCTION.HOME); |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
226 do_edit (FUNCTION.EDITOR, "", FUNCTION.MODE); |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
227 unwind_protect_cleanup |
19280
98a18bc3208e
Use cd rather than chdir in core Octave code.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
228 cd (curr_dir); |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
229 end_unwind_protect |
7325 | 230 else |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
231 do_edit (FUNCTION.EDITOR, "", FUNCTION.MODE); |
7325 | 232 endif |
233 return; | |
234 endif | |
235 | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
236 if (numel (editfilelist) > 1) |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
237 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
238 ## Call edit on each of the files in the list if there are more than 1 |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
239 for i = 1:numel (editfilelist) |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
240 edit (editfilelist{i}); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
241 endfor |
7325 | 242 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
243 else |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18011
diff
changeset
|
244 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
245 ## Only one file name was supplied, get it from the cell array |
17592
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
246 file = tilde_expand (editfilelist{1}); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
247 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
248 ## Check whether the user is trying to edit a builtin or compiled function. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
249 switch (exist (file)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
250 case {3, 5} |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
251 error ("edit: unable to edit a built-in or compiled function"); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
252 endswitch |
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
|
253 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
254 ## Checks for whether the file is |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
255 ## absolute or relative should be handled inside file_in_loadpath. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
256 ## That way, it will be possible to look up files correctly given |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
257 ## partial path information. For example, you should be able to |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
258 ## edit a particular overloaded function by doing any one of |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
259 ## |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
260 ## edit classname/foo |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
261 ## edit classname/foo.m |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
262 ## edit @classname/foo |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
263 ## edit @classname/foo.m |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
264 ## |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
265 ## This functionality is needed for other functions as well (at least |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
266 ## help and type; there may be more). So the place to fix that is in |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
267 ## file_in_loadpath, possibly with some help from the load_path class. |
7325 | 268 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
269 ## The code below includes a portion that serves as a place-holder for |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
270 ## the changes suggested above. |
7325 | 271 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
272 ## Create list of explicit and implicit file names. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
273 filelist = {file}; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
274 ## If file has no extension, add file.m and file.cc to the list. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
275 idx = rindex (file, "."); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
276 if (idx == 0) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
277 if (isempty (regexp (file, '\.m$'))) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
278 ## No ".m" at the end of the file, add to the list. |
17592
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
279 filelist(end+1) = [file ".m"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
280 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
281 if (isempty (regexp (file, '\.cc$'))) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
282 ## No ".cc" at the end of the file, add to the list. |
17592
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
283 filelist(end+1) = [file ".cc"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
284 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
|
285 endif |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
286 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
287 ## If the file includes a path, it may be an overloaded function. |
18061
832ecfda1d3c
edit.m: Respond correctly to either file separator (bug #40726).
Rik <rik@octave.org>
parents:
18011
diff
changeset
|
288 if (! index (file, "@") && strchr (file, '/\')) |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
289 ## No "@" at the beginning of the file, add to the list. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
290 numfiles = numel (filelist); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
291 for n = 1:numfiles |
17592
28eb00d3edf4
edit.m: Work correctly for file names with '~'.
Rik <rik@octave.org>
parents:
17393
diff
changeset
|
292 filelist(n+numfiles) = ["@" filelist{n}]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
293 endfor |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
294 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
|
295 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
296 ## Search the entire path for the 1st instance of a file in the list. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
297 fileandpath = ""; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
298 for n = 1:numel (filelist) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
299 filetoedit = file_in_path (path, filelist{n}); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
300 if (! isempty (filetoedit)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
301 ## The path is explicitly included. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
302 fileandpath = filetoedit; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
303 break; |
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 endif |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
305 endfor |
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
|
306 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
307 if (! isempty (fileandpath)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
308 ## If the file exists, then edit it. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
309 if (FUNCTION.EDITINPLACE) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
310 ## Edit in place even if it is protected. |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
311 do_edit (FUNCTION.EDITOR, fileandpath, FUNCTION.MODE); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
312 return; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
313 else |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
314 ## If the file is modifiable in place then edit it, |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
315 ## otherwise make a copy in HOME and then edit it. |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
316 fid = fopen (fileandpath, "r+t"); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
317 if (fid < 0) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
318 from = fileandpath; |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
319 fileandpath = [FUNCTION.HOME, from(rindex(from, filesep):end)]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
320 [status, msg] = copyfile (from, fileandpath, 1); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
321 if (status == 0) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
322 error (msg); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
323 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
324 else |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
325 fclose (fid); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
326 endif |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
327 do_edit (FUNCTION.EDITOR, fileandpath, FUNCTION.MODE); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
328 return; |
7325 | 329 endif |
330 endif | |
331 | |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
332 ## If editing a new file, prompt for creation if gui is running |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
333 if (isguirunning ()) |
18700
95a1ee1cbdf1
edit.m: add file extension .m to newly created files (bug #41522).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
18061
diff
changeset
|
334 if (! __octave_link_edit_file__ (file, "prompt")); |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
335 return; |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
336 endif |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
337 endif |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
338 |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
339 ## If editing a new file that is neither an m-file nor an oct-file, |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
340 ## just edit it. |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
341 ## If in gui-mode, create it before or editor would prompt again. |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
342 fileandpath = file; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
343 idx = rindex (file, "."); |
18784
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
344 if (idx) |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
345 name = file(1:idx-1); |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
346 ext = file(idx+1:end); |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
347 else |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
348 name = file; |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
349 ext = ""; |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
350 endif |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
351 if (! any (strcmp (ext, {"cc", "m"}))) |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
352 ## Some unknown file. Create and open it or just open it. |
18784
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
353 if (isempty (ext)) |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
354 fileandpath = [fileandpath ".m"]; # Add .m extension per default |
0728f7b6b1a2
edit.m: Don't append default '.m' extension if an extension already exists.
Rik <rik@octave.org>
parents:
18700
diff
changeset
|
355 endif |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
356 if (isguirunning ()) |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
357 ## Write the initial file (if there is anything to write) |
18700
95a1ee1cbdf1
edit.m: add file extension .m to newly created files (bug #41522).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
18061
diff
changeset
|
358 ## Give user the opportunity to change the file extension |
95a1ee1cbdf1
edit.m: add file extension .m to newly created files (bug #41522).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
18061
diff
changeset
|
359 fileandpath = uiputfile (fileandpath); |
17884
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
360 fid = fopen (fileandpath, "wt"); |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
361 if (fid < 0) |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
362 error ("edit: could not create %s", fileandpath); |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
363 endif |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
364 fclose (fid); |
766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents:
17864
diff
changeset
|
365 endif |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
366 do_edit (FUNCTION.EDITOR, fileandpath, FUNCTION.MODE); |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
367 return; |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
368 endif |
7325 | 369 |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
370 ## The file doesn't exist in path so |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
371 ## create it, put in the function template, and edit it. |
7325 | 372 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
373 ## Guess the email name if it was not given. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
374 if (isempty (FUNCTION.EMAIL)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
375 host = getenv ("HOSTNAME"); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
376 if (isempty (host) && ispc ()) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
377 host = getenv ("COMPUTERNAME"); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
378 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
379 if (isempty (host)) |
17393
6437a6815bc6
edit.m: Use '~' to discard unused return value from system().
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
380 [~, host] = system ("uname -n"); |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
381 ## trim newline from end of hostname |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
382 if (! isempty (host)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
383 host = host(1:end-1); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
384 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
385 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
386 if (isempty (host)) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
387 FUNCTION.EMAIL = " "; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
388 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
389 FUNCTION.EMAIL = ["<" default_user(0) "@" host ">"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
390 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
391 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
392 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
393 ## Fill in the revision string. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
394 now = localtime (time); |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
395 revs = ["Created: " strftime("%Y-%m-%d",now)]; |
7325 | 396 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
397 ## Fill in the copyright string. |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
398 copyright = [strftime("Copyright (C) %Y ",now) FUNCTION.AUTHOR]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
399 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
400 ## Fill in the author tag field. |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
401 author = ["Author: " FUNCTION.AUTHOR " " FUNCTION.EMAIL]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
402 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
403 ## Fill in the header. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
404 uclicense = toupper (FUNCTION.LICENSE); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
405 switch (uclicense) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
406 case "GPL" |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
407 head = cstrcat (copyright, "\n\n", "\ |
17863
0676fae19b8b
edit.m: Change default GPL license to refer to "this program" rather than "Octave".
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
408 This program is free software; you can redistribute it and/or modify it\n\ |
0676fae19b8b
edit.m: Change default GPL license to refer to "this program" rather than "Octave".
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
409 under the terms of the GNU General Public License as published by\n\ |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
410 the Free Software Foundation; either version 3 of the License, or\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
411 (at your option) any later version.\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
412 \n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
413 This program is distributed in the hope that it will be useful,\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
414 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
415 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
416 GNU General Public License for more details.\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
417 \n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
418 You should have received a copy of the GNU General Public License\n\ |
17864
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
419 along with this program. If not, see <http://www.gnu.org/licenses/>.\ |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
420 "); |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
421 tail = [author, "\n", revs]; |
7325 | 422 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
423 case "BSD" |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
424 head = cstrcat (copyright, "\n\n", "\ |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
425 This program is free software; redistribution and use in source and\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
426 binary forms, with or without modification, are permitted provided that\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
427 the following conditions are met:\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
428 \n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
429 1.Redistributions of source code must retain the above copyright\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
430 notice, this list of conditions and the following disclaimer.\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
431 2.Redistributions in binary form must reproduce the above copyright\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
432 notice, this list of conditions and the following disclaimer in the\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
433 documentation and/or other materials provided with the distribution.\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
434 \n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
435 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
436 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
437 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
438 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
439 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
440 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
441 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
442 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
443 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
444 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
445 SUCH DAMAGE.\ |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
446 "); |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
447 tail = [author, "\n", revs]; |
7325 | 448 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
449 case "PD" |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
450 head = ""; |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
451 tail = [author, "\n", revs, "\n\n", ... |
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
452 "This program is granted to the public domain."]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
453 |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
454 otherwise |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
455 head = ""; |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
456 tail = [copyright, "\n\n", FUNCTION.LICENSE, "\n", author, "\n", revs]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
457 endswitch |
7325 | 458 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
459 ## Generate the function template. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
460 exists = exist (name); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
461 switch (ext) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
462 case {"cc", "C", "cpp"} |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
463 if (isempty (head)) |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
464 comment = ["/*\n\n", tail, "\n\n*/\n\n"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
465 else |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
466 comment = ["/*\n\n", head, "\n\n", tail, "\n\n*/\n\n"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
467 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
468 ## If we are shadowing an m-file, paste the code for the m-file. |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
469 if (any (exists == [2, 103])) |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
470 code = ['\ ', strrep(type(name){1}, "\n", "\n// ")]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
471 else |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
472 code = " "; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
473 endif |
17245
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
474 body = ["#include <octave/oct.h>\n\n", ... |
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
475 "DEFUN_DLD(" name ", args, nargout, \"\\\n", ... |
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
476 name, "\\n\\\n\")\n{\n", ... |
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
477 " octave_value_list retval;\n", ... |
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
478 " int nargin = args.length ();\n\n", ... |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
479 code, "\n return retval;\n}\n"]; |
7325 | 480 |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
481 text = [comment, body]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
482 case "m" |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
483 ## If we are editing a function defined on the fly, paste the code. |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
484 if (any (exists == [2, 103])) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
485 body = type (name){1}; |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
486 else |
17864
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
487 body = ["function [retval] = " name " (input1, input2)\n\n" ... |
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
488 "endfunction\n"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
489 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
490 if (isempty (head)) |
17245
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
491 comment = ["## -*- texinfo -*- \n## @deftypefn {Function File} " ... |
17864
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
492 "{@var{retval} =} " name ... |
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
493 " (@var{input1}, @var{input2})\n##\n" ... |
17245
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
494 "## @seealso{}\n## @end deftypefn\n\n" ... |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
495 "## " strrep(tail, "\n", "\n## ") "\n\n"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
496 else |
17245
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
497 comment = ["## " strrep(head,"\n","\n## ") "\n\n" ... |
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
498 "## -*- texinfo -*- \n## @deftypefn {Function File} " ... |
17864
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
499 "{@var{retval} =} " name ... |
674e5eb2c709
edit.m: Use more meaningful variable names in default function body.
Rik <rik@octave.org>
parents:
17863
diff
changeset
|
500 " (@var{input1}, @var{input2})\n##\n" ... |
17245
7babcdb9bc13
Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents:
17174
diff
changeset
|
501 "## @seealso{}\n## @end deftypefn\n\n" ... |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
502 "## " strrep(tail, "\n", "\n## ") "\n\n"]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
503 endif |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
504 text = [comment, body]; |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
505 endswitch |
7325 | 506 |
15526
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
507 ## Write the initial file (if there is anything to write) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
508 fid = fopen (fileandpath, "wt"); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
509 if (fid < 0) |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
510 error ("edit: could not create %s", fileandpath); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
511 endif |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
512 fputs (fid, text); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
513 fclose (fid); |
1353ca03266f
add ability to edit multiple files (bug #37573)
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
14868
diff
changeset
|
514 |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
515 do_edit (FUNCTION.EDITOR, fileandpath, FUNCTION.MODE); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18011
diff
changeset
|
516 |
7325 | 517 endif |
518 | |
519 endfunction | |
520 | |
7434 | 521 ## Return the name associated with the current user ID. |
7325 | 522 ## |
7434 | 523 ## If LONG_FORM is 1, return the full name. This will be the |
524 ## default author. Otherwise return the login name. | |
7325 | 525 ## login@host will be the default email address. |
526 | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
527 function retval = default_user (long_form) |
7325 | 528 |
529 ent = getpwuid (getuid); | |
530 if (! isstruct (ent)) | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
531 retval = getenv ("USER"); |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
532 if (isempty (retval)) |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
533 retval = getenv ("USERNAME"); |
7325 | 534 endif |
535 elseif (long_form) | |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
536 retval = ent.gecos; |
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
537 pos = strfind (retval, ","); |
7434 | 538 if (! isempty (pos)) |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
539 retval = retval(1:pos-1); |
7434 | 540 endif |
7325 | 541 else |
16998
5069b6c6c062
edit.m: Redo default templates. Improve docstring. Use Octave coding conventions.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
542 retval = ent.name; |
7325 | 543 endif |
544 | |
545 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
|
546 |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
547 function do_edit (editor, file, mode) |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
548 |
20019
002576bbba10
Fix edit() not opening an editor when cmdline arg --no-gui given (bug #44695).
Rik <rik@octave.org>
parents:
20017
diff
changeset
|
549 if (isguirunning ()) |
002576bbba10
Fix edit() not opening an editor when cmdline arg --no-gui given (bug #44695).
Rik <rik@octave.org>
parents:
20017
diff
changeset
|
550 __octave_link_edit_file__ (file); |
002576bbba10
Fix edit() not opening an editor when cmdline arg --no-gui given (bug #44695).
Rik <rik@octave.org>
parents:
20017
diff
changeset
|
551 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16420
diff
changeset
|
552 system (sprintf (undo_string_escapes (editor), ['"' file '"']), [], mode); |
16399
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
553 endif |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
554 |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
555 endfunction |
f9a737fd8829
allow command-line edit function to use GUI editor
John W. Eaton <jwe@octave.org>
parents:
16045
diff
changeset
|
556 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
557 |
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
|
558 %!test |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
559 %! s.home = edit ("get", "home"); |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
560 %! s.author = edit ("get", "author"); |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
561 %! s.email = edit ("get", "email"); |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
562 %! s.license = edit ("get", "license"); |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
563 %! s.editinplace = edit ("get", "editinplace"); |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
564 %! s.mode = edit ("get", "mode"); |
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
|
565 %! 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
|
566 %! 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
|
567 %! 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
|
568 %! edit license none |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
569 %! edit ("editinplace", ! s.editinplace) |
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
|
570 %! 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
|
571 %! 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
|
572 %! 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
|
573 %! 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
|
574 %! 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
|
575 %! 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
|
576 %! 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
|
577 %! 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
|
578 %! 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
|
579 %! 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
|
580 %! 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
|
581 %! 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
|
582 %! 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
|
583 %! 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
|
584 %! 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
|
585 %! 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
|
586 %! 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
|
587 |