Subject: bug#18189: customized value of 'vc-annotate-background-mode' is applied only after restarting Emacs

From: Juri Linkov <[email-masked]>
Date: Sat, 09 Aug 2014 02:31:50 +0300

>> +(put 'vc-annotate-background-mode 'custom-set
>> +     (lambda (symbol value)
>> +       (set-default symbol value)
>> +       (ignore-errors
>> +	 (custom-reevaluate-setting 'vc-annotate-color-map))))
>
> Why not provide it directly in the `defcustom'?

`vc-annotate-background-mode' is defined before `vc-annotate-color-map'
in the source file vc-annotate.el, so there is a cyclic dependency
in these variables.  When I tried to provide it directly in the `defcustom'

  :set (lambda (symbol value)
	 (set-default symbol value)
	 (ignore-errors
	   (custom-reevaluate-setting 'vc-annotate-color-map)))

then loading the file failed with the error:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  #[257 "\211\300_\301\302\303\"\304\305E\306\307\310\311\312E&\207" [nil vector format "Span %.1f days" vc-annotate-display-select nil :style toggle :selected eql vc-annotate-display-mode] 11 "\n\n(fn ELEMENT)"](2)
  mapcar(#[257 "\211\300_\301\302\303\"\304\305E\306\307\310\311\312E&\207" [nil vector format "Span %.1f days" vc-annotate-display-select nil :style toggle :selected eql vc-annotate-display-mode] 11 "\n\n(fn ELEMENT)"] (2 0.5 0.1 0.01))
  byte-code("\304\305\306\307\310\311\312!\313\314\315\316\317\320!\321\"\322\323%\n\"\262\324\325\326\327\325\330\331\332\333\334\335\325\336\337\340\320\341\342\343\344\345\346\347BBE\350BBBB\"\351BBBBBBBBBBBBBBB\"BB$\207" [vc-annotate-mode-map vc-annotate-color-map vc-annotate-menu-elements vc-annotate-backend easy-menu-do-define vc-annotate-mode-menu "VC Annotate Display Menu" "VC-Annotate" ["By Color Map Range" (unless (null vc-annotate-display-mode) (setq vc-annotate-display-mode nil) (vc-annotate-display-select)) :style toggle :selected (null vc-annotate-display-mode)] append vc-annotate-oldest-in-map mapcar make-byte-code 257 "\211\300_\301\302\303\"\304\305E\306\307\310\311\312E&\207" vconcat vector [vector format "Span %.1f days" vc-annotate-display-select nil :style toggle :selected eql vc-annotate-display-mode] 11 "\n\n(fn ELEMENT)" ["Span ..." (vc-annotate-display-select nil (float (string-to-number (read-string "Span how many days? "))))] "--" ["Span to Oldest" (unless (eq vc-annotate-display-mode (quote scale)) (vc-annotate-display-select nil (quote scale))) :help "Use an autoscaled color map from the oldest annotation to the current time" :style toggle :selected (eq vc-annotate-display-mode (quote scale))] ["Span Oldest->Newest" (unless (eq vc-annotate-display-mode (quote fullscale)) (vc-annotate-display-select nil (quote fullscale))) :help "Use an autoscaled color map from the oldest to the newest annotation" :style toggle :selected (eq vc-annotate-display-mode (quote fullscale))] ["Toggle annotation visibility" vc-annotate-toggle-annotation-visibility :help "Toggle whether the annotation is visible or not"] ["Annotate previous revision" vc-annotate-prev-revision :help "Visit the annotation of the revision previous to this one"] ["Annotate next revision" vc-annotate-next-revision :help "Visit the annotation of the revision after this one"] ["Annotate revision at line" vc-annotate-revision-at-line :help "Visit the annotation of the revision identified in the current line"] ["Annotate revision previous to line" vc-annotate-revision-previous-to-line :help "Visit the annotation of the revision before the revision at line"] ["Annotate latest revision" vc-annotate-working-revision :help "Visit the annotation of the working revision of this file"] ["Show log of revision at line" vc-annotate-show-log-revision-at-line :help "Visit the log of the revision at line"] ["Show diff of revision at line" vc-annotate-show-diff-revision-at-line :help "Visit the diff of the revision at line from its previous revision"] apply "Show changeset diff of revision at line" vc-annotate-show-changeset-diff-revision-at-line :enable eq (quote repository) vc-call-backend ((quote revision-granularity)) (:help "Visit the diff of the revision at line from its previous revision") (["Visit revision at line" vc-annotate-find-revision-at-line :help "Visit the revision identified in the current line"])] 32)
  autoload-do-load((autoload "vc-annotate" 1541696 t nil) vc-annotate)
  command-execute(vc-annotate)