onEditingACollection

Table of Contents

The other papers

1 On editing a collection

Not too often, but just enough to take notice, you will need to edit a collection of functions. You may not know where they are stored, but you know there is a common facet a group of functions will want/need to change. Here's the challenge.

>/Remove any list-making from smart files/

For the moment, we can skip the features of smart files, other than note they are identified by a function. It turns out, after five or six months of adding smart files to a list of such, I've found little use for that list; there are other means to gather the names. In truth, the list of smartfiles is only a list in the sense they share that property, but little about them suggests any other means to collect them.

So, what steps do I go through to remove that feature?

Here is a selection from the command history to deal with the challenge:

801  sfuse list
802  sfuse list | field 1 | sort -u | grep -v '^list'
805  ffun $(sfuse list | field 1 | sort -u | grep -v '^list')
814  foreach do_whf $(sfuse list | field 1 | sort -u | grep -v '^list') | field 2 | sort -u
826  foreach do_whf $(sfuse list | field 1 | sort -u | grep -v '^list') | field 2 | sort -u
827  bkp funlib
828  group fix funlib
829  group fix funlib wc
830  group fix funlib mv
831  bkp funlib
832  th
833  foreach do_whf $(sfuse list | field 1 | sort -u | grep -v '^list') | field 2 | sort -u
834  set -- grouplib programlib smartflib
835  bkp $1
836  group fix $1
837  group fix $1 wc
838  group fix $1 mv
839  bkp $1
840  shift
842  bkp $1; group fix $1 wc
843  th
844  group fix $1 mv; bkp $1
845  shift
...
851  cx *lib
852  th
854  ea
855  llrt
858  th 48 | emptyy

By the line numbers:

  • 801,2 – sfuse shows the functions which use the argument, the second line listing just those functions which are not list functions themselves
  • 805 – ffun Fies the FUNctions, calling the users EDITOR with the list of funcitons returned by the $( ... ) operation
  • 814 – dowhf returns WHich File is the function defined in
  • 826, – after some inspection of the results, repeat the operation to fix the library names in your mind.
  • 827-831, bkp (backup) the funlib one of the changed libraries, where the group\fix function, with the optional third argument
* retains only the latest function definition, 
* performs a **wc** comparison of the current and expected contents
* overwrites the current contents with the changed by **mv**ing the new over the current,

followed by a subsequent backup

  • 832 – th Tails the History
  • 833,834 – review the list, and set the positional parameters to the remaining library name
  • 835-839 – repeat lines 827 thru 831 for the first argument; the history is now resuable for each library, since
  • 840 – shift out the first name from the list of positional parameters and repeat until the arguments are all used.
  • 842-845 – it's possible to collapse some history. e.g. 842 was really: $ !835; !837, etc
  • 851-855 – cx makes the libs executable, th reviews the history, ea, my sole alias list the count and positional parameters, and llrt lists the directory, Long Reverse Time.
  • 858 – the emptyy function collects its standard input to paste into a document such as this one.

Whew. Here are the functions i've identified in this process:

sfuse       () { set | fuse $1; }
ffun                () { gff fbdy $*; }
do_whf      () { echo $1 $(whf $1); }
bkp () 
{ 
    function _mkbkup () 
    { 
        trace_call $*;
        set -- $1 $(commentType $1);
        [[ $# -lt 2 ]] && { 
            comment WARNING: File $1 has unknown Comment Type;
            cat $1;
            return
        };
        bkp_labl $1
    };
    function dotrack () 
    { 
        ...
    };
    function _xmkbkup () 
    { 
        _mkbkup $1 > $2
    };
    function _thisbk () 
    { 
        ...
    };
    function track_me () 
    { 
        echo TRACK $(ls -l $BKP_TRACKME) 1>&2
    };
    function _f_fbk () 
    { 
        [[ -f $1 ]] || { 
            comment WARNING -- no FILE $1;
            return
        };

        _thisbk $1 $(bkp_base)/$1 
    };
    foreach _f_fbk $*
}
th  () { history | tail -${1:-24}; }
cx  () { chmod +x ${*:-/dev/null}; }
emptyy      () { fourspaces | fourspaces | tee ~/tmp/.y; }
grabfunames () { grep '^* 8' onEditingACollection.txt | sed 's/\*\* .*$//; s/.*--//; s/.*\*//' | grep -v '^ 

Here the bkp function is too long to be displayed in full. Consult any reference [[][onBackup]]

1.1 In summary

So, what's happened?

  • A handful of libraries, some identifed on line 834, had functions which used the list-making

properties.

  • I edited (some of) those functions on line 805
  • I first identifed the affected libraries on line 814. It's important to note that I really don't know precisely which libraries were arrected, since I'm backing them up before and after the repairs.
  • I manually updated one of the libraries in lines 827 thru 831, and
  • concluded by repeating the process by using positional parameters on lines 835 thru 845, and
  • inspecting the results on the remainder

1.2 References

Author: Marty

Created: 2016-02-20 Sat 15:50

Emacs 24.4.1 (Org mode 8.2.10)

Validate