Mercurial > hg > octave-kai
changeset 5548:5cc01ba4c052
[project @ 2005-11-30 03:04:44 by jwe]
author | jwe |
---|---|
date | Wed, 30 Nov 2005 03:04:45 +0000 |
parents | 8b0b36c2dc0c |
children | 6db3a5df1eab |
files | ChangeLog emacs/octave-mod.el scripts/ChangeLog scripts/miscellaneous/license.m scripts/miscellaneous/ver.m |
diffstat | 5 files changed, 69 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-29 Rafael Laboissiere <rafael@debian.org> + + * emacs/octave-mod.el: Ensure that key bindings for + octave-mark-defun and backward-kill-word work in both XEmacs and + GNU Emacs. + 2005-11-28 John W. Eaton <jwe@octave.org> * configure.in: Check for uname.
--- a/emacs/octave-mod.el +++ b/emacs/octave-mod.el @@ -203,6 +203,9 @@ (defvar inferior-octave-process nil) +(defvar octave-xemacs-p + (string-match "XEmacs\\|Lucid" emacs-version)) + (defvar octave-mode-map nil "Keymap used in Octave mode.") (if octave-mode-map @@ -219,6 +222,8 @@ (define-key map "\M-\C-a" 'octave-beginning-of-defun) (define-key map "\M-\C-e" 'octave-end-of-defun) (define-key map "\M-\C-h" 'octave-mark-defun) + (if octave-xemacs-p + (define-key map [(meta backspace)] 'backward-kill-word)) (define-key map "\M-\C-q" 'octave-indent-defun) (define-key map "\C-c;" 'octave-comment-region) (define-key map "\C-c:" 'octave-uncomment-region) @@ -638,9 +643,6 @@ (delete-horizontal-space) (insert (concat " " octave-continuation-string)))) -(defvar octave-xemacs-p - (string-match "XEmacs\\|Lucid" emacs-version)) - ;;; Comments (defun octave-comment-region (beg end &optional arg) "Comment or uncomment each line in the region as Octave code.
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,15 @@ +2005-11-29 John W. Eaton <jwe@octave.org> + + * miscellaneous/ver.m: Use new uname built-in function instead of + calling system. Only append octave_forge_string if + OCTAVE_FORGE_VERSION exists. Use puts instead of disp. + Call license instead of hard-coding license info here. + + * miscellaneous/license.m: Use persistent instead of global for + __octave_licenses__. Use puts instad of disp. + Use getuid and getpwuid instead of calling unix ("id -un"). + If nargout = 1, return license info instead of printing usage message. + 2005-11-29 William Poetra Yoga Hadisoeseno <williampoetra@gmail.com> * miscellaneous/ver.m: New file.
--- a/scripts/miscellaneous/license.m +++ b/scripts/miscellaneous/license.m @@ -19,38 +19,22 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} license -## @deftypefnx {Function File} {} license ("inuse") -## @deftypefnx {Function File} {@var{retval}} = license ("inuse") -## @deftypefnx {Function File} {@var{retval}} = license ("test", @var{feature}) -## @deftypefnx {Function File} {} license ("test", @var{feature}, @var{toggle}) -## @deftypefnx {Function File} {@var{retval}} = license ("checkout", @var{feature}) ## Display the license of Octave. ## -## @itemize +## @deftypefnx {Function File} {} license ("inuse") +## Display a list of packages currently being used. ## -## @item -## @code{license} displays the license of Octave (GNU GPL v2). -## -## @item -## @code{license ("inuse")} also displays a list of products currently -## being used. +## @deftypefnx {Function File} {@var{retval}} = license ("inuse") +## Return a structure containing the fields @code{feature} and @code{user}. ## -## @item -## @code{@var{retval} = license ("inuse")} returns a structure which has -## two fields: @code{feature} is the product name ("Octave") and -## @code{user} is the current username (only works on Unix systems; on -## Windows systems it contains "octave_user"). +## @deftypefnx {Function File} {@var{retval}} = license ("test", @var{feature}) +## Return 1 if a license exists for the product identified by the string +## @var{feature} and 0 otherwise. The argument @var{feature} is case +## insensitive and only the first 27 characters are checked. ## -## @item -## @code{@var{retval} = license ("test", @var{feature})} returns 1 if a -## license exists for the product identified by the string @var{feature} -## and 0 otherwise. @var{feature} is case insensitive and only the first -## 27 characters are checked. -## -## @item -## @code{license ("test", @var{feature}, @var{toggle})} enables or disables -## license testing for @var{feature}, depending on @var{toggle}, which -## can be one of: +## @deftypefnx {Function File} {} license ("test", @var{feature}, @var{toggle}) +## Enable or disable license testing for @var{feature}, depending on +## @var{toggle}, which may be one of: ## ## @table @samp ## @item "enable" @@ -60,12 +44,11 @@ ## Future tests for the specified license of @var{feature} return 0. ## @end table ## -## @item -## @code{@var{retval} = license ("checkout", @var{feature})} checks out -## a license for @var{feature}, returning 1 on success and 0 on failure. +## @deftypefnx {Function File} {@var{retval}} = license ("checkout", @var{feature}) +## Check out a license for @var{feature}, returning 1 on success and 0 +## on failure. ## -## @end itemize -## +## This function is provided for compatibility with @sc{Matlab}. ## @end deftypefn ## @seealso{ver, version} @@ -73,7 +56,7 @@ function retval = license (varargin) - global __octave_licenses__ + persistent __octave_licenses__; if (isempty (__octave_licenses__)) __octave_licenses__ = cell (); @@ -97,26 +80,24 @@ if (nin == 0) - if (nout == 0) - - found = false; - for p = 1:nr_licenses - if (strcmp (__octave_licenses__{p,1}, "Octave")) - found = true; - break; - endif - endfor + found = false; + for p = 1:nr_licenses + if (strcmp (__octave_licenses__{p,1}, "Octave")) + found = true; + break; + endif + endfor - if (found) - disp (__octave_licenses__{p,2}); - else - disp ("unknown"); - endif + if (found) + result = __octave_licenses__{p,2}; + else + result = "unknown"; + endif + if (nout == 0) + printf ("%s\n", result); else - - usage ("license"); - + retval = result; endif elseif (nin == 1) @@ -128,7 +109,7 @@ endif for p = 1:nr_licenses - disp (__octave_licenses__{p,1}); + printf ("%s\n", __octave_licenses__{p,1}); endfor else @@ -137,15 +118,11 @@ usage ("retval = license (\"inuse\")"); endif - if (isunix) - [t, username] = unix ("id -un"); - if (t == 0) - username = username(1:end-1); - else - username = "octave_user"; - endif + pw = getpwuid (getuid ()); + if (isstruct (pw)) + username = pw.name; else - username = "octave_user"; + username = "octave_user"; endif retval(1:nr_licenses) = struct ("feature", "", "user", "");
--- a/scripts/miscellaneous/ver.m +++ b/scripts/miscellaneous/ver.m @@ -33,19 +33,20 @@ usage ("ver"); endif - octave_license = "GNU General Public License, Version 2"; + octave_license = license (); + + [unm, status] = uname (); - if (isunix) - os_string = system ("uname -srvm")(1:end-1); - elseif (ispc) - os_string = "Microsoft Windows"; + if (status < 0) + os_string = "unknown"; else - os_string = "unknown"; + os_string = sprintf ("%s %s %s %s", unm.sysname, unm.release, + unm.version, unm.machine); endif hbar(1:70) = "-"; ver_line1 = "GNU Octave Version "; - ver_line2 = "GNU Octave License "; + ver_line2 = "GNU Octave License: "; ver_line3 = "Operating System: "; ver_desc = sprintf ("%s\n%s%s\n%s%s\n%s%s\n%s\n", hbar, ver_line1, version, @@ -59,9 +60,9 @@ - length (octave_forge_name) - length (octave_forge_version)), octave_forge_version); + ver_desc = strcat (ver_desc, octave_forge_string); endif - ver_desc = strcat (ver_desc, octave_forge_string); - disp (ver_desc); + puts (ver_desc); endfunction