]> Creatis software - CreaPhase.git/blob - octave_packages/m/prefs/rmpref.m
update packages
[CreaPhase.git] / octave_packages / m / prefs / rmpref.m
1 ## Copyright (C) 2012 John W. Eaton
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} rmpref (@var{group}, @var{pref})
21 ## Remove the named preference @var{pref} from the preference group
22 ## @var{group}.
23 ##
24 ## The named preference group must be a character string.
25 ##
26 ## The preference @var{pref} may be a character string or a cell array
27 ## of character strings.
28 ##
29 ## If @var{pref} is not specified, remove the preference group
30 ## @var{group}.
31 ##
32 ## It is an error to remove a nonexistent preference or group.
33 ## @seealso{addpref, ispref, setpref, getpref}
34 ## @end deftypefn
35
36 ## Author: jwe
37
38 function retval = rmpref (group, pref)
39
40   prefs = loadprefs ();
41
42   if (nargin == 1)
43     if (ischar (group))
44       retval = isfield (prefs, group);
45     else
46       error ("expecting group to be a character array");
47     endif
48   elseif (nargin == 2)
49     grp = getpref (group, pref);
50     if (ischar (pref) || iscellstr (pref))
51       retval = isfield (grp, pref);
52     endif
53   else
54     print_usage ();
55   endif
56
57 endfunction
58
59 %% Testing these functions will require some care to avoid wiping out
60 %% existing (or creating unwanted) preferences for the user running the
61 %% tests.