[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Having pkg("list") mark which pakages are loaded
From: |
David Bateman |
Subject: |
Having pkg("list") mark which pakages are loaded |
Date: |
Mon, 14 May 2007 12:44:15 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
The attached patch allows pkg to mark in the packages structure returned
by pkg("list") whether a package is loaded. It also allows pkg("list")
called with no output arguments to printed a "*" next to loaded packages...
Regards
David
*** ./scripts/pkg/pkg.m.orig33 2007-05-11 23:51:06.000000000 +0200
--- ./scripts/pkg/pkg.m 2007-05-14 12:07:42.988762546 +0200
***************
*** 1238,1243 ****
--- 1238,1253 ----
installed_packages(dup) = [];
endif
+ ## Now check if the package is loaded
+ tmppath = path();
+ for i = 1:length (installed_packages)
+ if (regexp (tmppath, installed_packages{i}.dir))
+ installed_packages{i}.loaded = true;
+ else
+ installed_packages{i}.loaded = false;
+ endif
+ endfor
+
## Should we return something?
if (nargout == 2)
out1 = local_packages;
***************
*** 1269,1275 ****
length (installed_packages{i}.version));
names{i} = installed_packages{i}.name;
endfor
! h1 = postpad (h1, max_name_length, " ");
h2 = postpad (h2, max_version_length, " ");;
## Print a header
--- 1279,1285 ----
length (installed_packages{i}.version));
names{i} = installed_packages{i}.name;
endfor
! h1 = postpad (h1, max_name_length + 1, " ");
h2 = postpad (h2, max_version_length, " ");;
## Print a header
***************
*** 1281,1294 ****
printf ("%s\n", tmp);
## Print the packages
! format = sprintf ("%%%ds | %%%ds | %%s\n", max_name_length,
max_version_length);
[dummy, idx] = sort (names);
for i = 1:num_packages
cur_name = installed_packages{idx(i)}.name;
cur_version = installed_packages{idx(i)}.version;
cur_dir = installed_packages{idx(i)}.dir;
! printf (format, cur_name, cur_version, cur_dir);
endfor
endfunction
--- 1291,1309 ----
printf ("%s\n", tmp);
## Print the packages
! format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", max_name_length,
max_version_length);
[dummy, idx] = sort (names);
for i = 1:num_packages
cur_name = installed_packages{idx(i)}.name;
cur_version = installed_packages{idx(i)}.version;
cur_dir = installed_packages{idx(i)}.dir;
! if (installed_packages{idx(i)}.loaded)
! cur_loaded = "*";
! else
! cur_loaded = " ";
! endif
! printf (format, cur_name, cur_loaded, cur_version, cur_dir);
endfor
endfunction
- Having pkg("list") mark which pakages are loaded,
David Bateman <=