Adding new backends - ECB - the Emacs Code Browser
Description: ECB - the Emacs Code Browser

Next: Known VC-problems, Previous: Refreshing the VC-state, Up: Version-control support

#### 10.8.5 Necessary steps and informations for adding new backends

There are mainly three necessary steps for adding a new1 backend BE which should be supported by ECB:

1. Adding an identify-backend-function to `ecb-vc-supported-backends` ECB needs a function how to identify the new backend BE for a certain directory. If there exists already a library (other then VC) supporting this backend then this library propably contains already such a function which can be used or can be used at least with a small elisp-wrapper. If no elisp-library for backend BE exists then you have probably write the full identify-backend-function for your self. This function has to be added to `ecb-vc-supported-backends`.
2. Adding an check-state-function to `ecb-vc-supported-backends` Associated to the new identify-backend-function mentioned in step 1 a new check-state-function is needed which can be used by ECB to get the VC-state for a file. See Checking the state for a description about the needed interface of such a function. In combinatio with the identify-backend-function from step 1 this function has to be added to `ecb-vc-supported-backends`.
3. Enabling automatic state-update after checkin/out

   This step is not essential if you do not need the displayed VC-state automatically updated after a checkin/out of a file via the commands available for backend BE (e.g. clearcase.el offers for the backend Clearcase elisp-commands to checkin and checkout a file which then should also update the displayed state in the ECB-tree-buffers. All you need is a way to tell these commands that they should clear the ECB-VC-cache for the file and then restart the ECB-VC-check-mechanism. This should be done after these commands have finished their original job.

   ECB enables this per default for all backends supported by the VC-package with the following code. Maybe this is a good starting point.

               (defvar ecb-checkedin-file nil
                 "Stored the filename of the most recent checked-in file. Is only set by the
               after-advice of `vc-checkin' and `ecb-vc-checkin-hook' \(resets it to nil).
               Evaluated only by `ecb-vc-checkin-hook'.

               This is the communication-channel between `vc-checkin' and
               `ecb-vc-checkin-hook' so this hook-function gets the filename of the
               checked-in file.")

               (defadvice vc-checkin (after ecb)
                 "Simply stores the filename of the checked-in file in `ecb-checkedin-file'
               so it is available in the `vc-checkin-hook'."
                 (setq ecb-checkedin-file (ecb-fix-filename (ad-get-arg 0))))

               (defun ecb-vc-checkin-hook ()
                 "Ensures that the ECB-cache is reset and the entry for the most recent
               checkedin file is cleared. Uses `ecb-checkedin-file' as last checked-in file."
                 (when ecb-checkedin-file
                   (ecb-vc-cache-remove ecb-checkedin-file)
                   (ecb-vc-reset-vc-stealthy-checks)
                   (setq ecb-checkedin-file nil)))

#### Footnotes

[1] i.e. not already supported by the VC-package because all these backends are automatically supported by ECB too!