Hi all,

I tried bzr for the first time today and noticed that `C-x T i' still
tries to load tla-inventory, so I guessed there's no unified inventory
code yet?

I've spent a few hours toying around with some ideas in the hope of
figuring out an inventory mode that's generic enough to be useful.  I've
come up with something that mostly works, so I thought I'd get
impressions on the general approach.

By way of example, here's a little inventory mode I wrote for bzr using
the new code:

  (defun bzr-inventory (directory)
    (interactive)
    (cd directory)
    (dvc-run-dvc-sync
     'bzr `("status" "--all" ,directory)
     :finished (lambda (output error status arguments)
                 (let ((inventory (dvc-inventory-make
                                   directory
                                   '(("M" (remove))
                                     ("A" (remove))
                                     ("?" (add))
                                     ("" (remove)))))
                       (files (bzr-parse-inventory
                               (with-current-buffer output
                                 (buffer-string)))))
                   (maphash (lambda (tag files)
                              (mapc (lambda (file)
                                      (dvc-inventory-add-entry
                                       inventory tag file))
                                    files))
                            files)
                   (dvc-inventory-display inventory)))))

Basically, an inventory object consists of:

  * A directory (the inventory's root directory)
  * A bunch of rules of the form (tag (op1 op2 ...)).  The idea behind
    this is that when the user is in the inventory buffer and says
    "remove the file at point", dvc-inventory-mode can make sure that
    the file's tag supports being removed.  In the above, I'm allowing
    modified files ("M"), added files ("A") and unchanged files ("") to
    be removed, but not unknown files ("?").

So, you pass that information to `dvc-inventory-make' to get a new
inventory object.  Then you call `dvc-inventory-add-entry' for each file
you want to add to the inventory list (providing a tag type and filename
for each).  Once you've filled up your inventory object, you call the
generic `dvc-inventory-display' to display the inventory buffer.  The
display code is pretty basic at the moment, but includes key bindings
for adding/removing files, and colourises entries based on their tag.

Are my ramblings making any sense?  Does this seem like a useful thing
to have around?  If so, I'll clean up the code and write a more complete
implementation for bzr to serve as an example.

Thanks,

Mark

-- 
Mark Triggs
<[EMAIL PROTECTED]>

_______________________________________________
Xtla-el-dev mailing list
[email protected]
https://mail.gna.org/listinfo/xtla-el-dev

Reply via email to