/* editmeta.aml /* Edit INFO metacontent table by extracting it to a text file, /* editing it, then putting it back into the info file. /* /* Requires: /* user is in an existing, writable workspace /* user is in UNIX /* requires meta2text.aml and text2meta.aml /* History: /* 27-may-2000 tglover Created. &args infotab &if [null %infotab%] &then &do &return &warning Usage: &run editmeta &end /* Check that INFO table is named .meta &sv dotloc = [length %infotab%] - 4 /* where in infotab '.meta' ought to start &if %dotloc% < 2 or [upcase [substr %infotab% %dotloc%]] ne .META &then &do &return &error Name of INFO metacontent table must end in '.meta' &end /* Does the info table exist? &if not [exist %infotab% -INFO] &then &do /* Does not (yet) exist. Ask user if they want to proceed. &sv s = [quote INFO table %infotab% does not exist. Create it (y/n)] &if not [query %s% .TRUE.] &then &do &return &warning Not proceeding &end &end /* Extract the metacontent using meta2text &sv tmptext = tmpmeta.meta &r meta2text %infotab% %tmptext% force /* Edit the table. Which editor? &if [variable .metaeditor] &then &do /* .metaeditor is what the user used last time &sv default = %.metaeditor% &end &else &if [exists /usr/local/bin/gvim -FILE] ~ and not [null [value DISPLAY]] &then &do /* Looks like user is using X, and gvim is installed &sv default = gvim &end &else &if [exists /usr/local/bin/vim -FILE] &then &do /* vim is installed &sv default = vim &end &else &if not [null [value EDITOR]] &then &do /* User's EDITOR variable from UNIX &sv default = %EDITOR% &end &else &do /* Nothing else to go on, offer vi as a default &sv default = vi &end /* Ask user what editor to use, get result into .metaeditor &sv s = [quote Use what editor to edit metacontent text file <%default%>] &sv .metaeditor = [response %s% %default%] /* Start the editor with the temp meta file &ty Starting %.metaeditor% to edit metacontent text file %tmptext% &sys %.metaeditor% %tmptext% &sv s = 'When you have finished editing, press to continue' &sv junk = [response %s%] /* Prompt user for confirmation before loading &sv s = [quote Load edited metacontent into INFO table %infotab% (y/n)] &if not [query %s% .FALSE] &then &do &return &warning NOT loading metacontent into %infotab% &end /* Copy it in &r text2meta %tmptext% %infotab% force &return