Node: General aspects, Next: , Previous: Customizing, Up: Customizing



General aspects for customizing ECB

The best way to customize all the options of ECB is via the customize-feature of (X)Emacs, i.e. means calling the commands customize-option or customize-group etc. This is also the strongly recommended way!

But of course you can also use setq or some Elisp-code to change the values of many but not all of the options. The values of the following options MUST NOT be changed via setq or Elisp-code but only with the customize-feature!

IMPORTANT: If you are the administrator for an Emacs-site, means you are responsible for the basic customization of a lot of Emacs users, then you maybe need a way to customize Emacs and ECB without changing everyones .emacs-file and normally you will do this with the file site-start.el. You can customize all options of ECB in a central site-start.el (even the options mentioned above!) but you MUST NOT do this via setq but you have to use a mechanism like the following1! Here is a short example how this can be done:

First two helper functions are needed, namely customize-option-get-value and customize-save-variable-save whereas the latter one sets the value for an option via the customize-mechanism (and is therefore allowed for the setq-forbidden options!) but only if the option has no saved value until now (i.e. the user has not saved this option for future sessions until now)

   (defun customize-option-get-value (option type)
     "Return the value of a customizable option OPTION with TYPE, where TYPE
   can either be 'standard-value \(the default-value of the defcustom) or
   'saved-value \(the value stored durable by the user via customize)."
     (let ((val (car (get option type))))
       (cond ((not (listp val)) val)
             ((equal 'quote (car val)) (car (cdr val)))
             (t (car val)))))
   
   (defun customize-save-variable-save (option value &optional override)
     "Calls `customize-save-variable' with OPTION and VALUE if OPTION is a
   custom-type and if OPTION has no saved-value until now.
   If OVERRIDE is a function or lambda-form then it is called with two arguments:
   - OLD-SAVED-VAL: The saved value of OPTION
   - NEW-VALUE: see argument VALUE.
   OVERRIDE is only called if OPTION has already a saved-value. If OVERIDE
   returns not nil then `customize-save-variable' is called for OPTION with VALUE
   even if OPTION has no saved-value until now."
     (and (get option 'custom-type)
          (or (not (get option 'saved-value))
              (and (functionp override)
                   (funcall override
                            (customize-option-get-value option 'saved-value)
                            value)))
          (progn
            (message "Overriding saved value for option %s with %s" option value)
            (customize-save-variable option value))))
   

With customize-save-variable-save all ECB-options can be site-wide pre-customized like follows:

   (customize-save-variable-save 'ecb-show-tags
                                 '((include collapsed nil)
                                   (parent collapsed nil)
                                   (type flattened nil)
                                   (variable collapsed name)
                                   (function flattened name)
                                   (rule flattened name)
                                   (section flattened nil)
                                   (def collapsed name)
                                   (t collapsed name)))
   (customize-save-variable-save 'ecb-font-lock-tags t)
   ;; add here more options of ECB it you want
   

But ensure that you customize the options with the correct lisp format. Read carefully the docstrings of the options you want to customize from within Elisp-code!


Footnotes

  1. At least for the options for which setq is explicitly forbidden, but it is recommended to use always such a mechanism