Stefan Monnier wrote: E.g. why (defvar cursor-blink-mode)? It seems 100% useless since it's only a byte-compiler directive and only has the effect of declaring the variable 2 lines earlier, but since the variable is not *used* in those two lines, it shouldn't matter. Why not wrap the expression in condition-case instead? Or place `boundp' checks instead? That's what I mean by "lack of explanation".
Well the variable _is_ used: (unless (default-boundp 'blink-cursor-mode) (setq-default blink-cursor-mode nil)) I do not _exactly_ know _what_ prevents a compiler warning. (Does unless work just as well as if, does default-boundp work just as well as boundp?) I guess that one way or the other the line above can be rewritten in such a way that it avoids the need for the defvar. But the real question is whether the code is easier to understand for somebody who reads it, without prior knowledge of the problems involved, with making sure that the :init-form is never evaluated by setting the default-value before the defcustom if not yet set (which indeed can be done with just one line of code) or with actually evaluating the :init-form, wrapped into a condition-case if necessary. In the current situation, I believe that we need a comment making clear that the temporary evaluated value should not be relied upon even during the time it is in effect (to be robust against code changes), that the `noninteractive' better be kept the first form in the `or' to prevent the need for the condition-case, and that any change in the :init-form should be mimicked in startup.el. The comment in startup.el should also be changed, since now we _do_ execute the form in the defcustom, it just gives an incorrect value. I propose: ===File ~/frame.el-diff===================================== *** frame.el 21 Feb 2005 14:18:13 -0600 1.217 --- frame.el 22 Feb 2005 20:09:14 -0600 *************** *** 1256,1265 **** This timer calls `blink-cursor-timer-function' every `blink-cursor-interval' seconds.") ! ;; We do not know the standard _evaluated_ value yet, because the standard ! ;; expression uses values that are not yet set. The correct evaluated ! ;; standard value will be installed in startup.el using exactly the same ! ;; expression as in the defcustom. (define-minor-mode blink-cursor-mode "Toggle blinking cursor mode. With a numeric argument, turn blinking cursor mode on iff ARG is positive. --- 1256,1272 ---- This timer calls `blink-cursor-timer-function' every `blink-cursor-interval' seconds.") ! ;; The :init-value below is evaluated at startup, before startup.el is ! ;; loaded. At that time, the variables it uses do not yet have their ! ;; correct values, or are not yet defined. Because noninteractive is ! ;; t at the time, the :init-value evaluates to nil. However, the only ! ;; relevant fact is that it does not throw an error. The actual ! ;; temporary value is irrelevant and should not be relied upon. The ! ;; code in the :init-value will be evaluated again in startup.el, at ! ;; which time all values will be correct. If you change the ! ;; :init-value below, you should also change the expression used in ! ;; startup.el. The two expressions need to be identical or Custom ! ;; will get very confused. (define-minor-mode blink-cursor-mode "Toggle blinking cursor mode. With a numeric argument, turn blinking cursor mode on iff ARG is positive. *************** *** 1273,1278 **** --- 1280,1286 ---- emacs-quick-startup (eq system-type 'ms-dos) (not (memq window-system '(x w32))))) + :group 'cursor :global t (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) (if blink-cursor-timer (cancel-timer blink-cursor-timer)) ============================================================ ===File ~/startup.el-diff=================================== *** startup.el 10 Feb 2005 17:18:09 -0600 1.338 --- startup.el 22 Feb 2005 16:21:58 -0600 *************** *** 735,744 **** (<= (frame-parameter nil 'tool-bar-lines) 0)) (tool-bar-mode 1)) ! ;; Can't do this init in defcustom because the relevant variables ! ;; are not set. If you make any changes to the `or' form below, ! ;; you should also change the corresponding expression in the ! ;; defcustom in frame.el, or Custom will be badly confused. (unless (or noninteractive emacs-quick-startup (eq system-type 'ms-dos) --- 735,745 ---- (<= (frame-parameter nil 'tool-bar-lines) 0)) (tool-bar-mode 1)) ! ;; Can't do this init correctly in defcustom because the relevant ! ;; variables have wrong values or are not yet set. If you make any ! ;; changes to the `or' form below, you should also change the ! ;; corresponding expression in the defcustom in frame.el, or Custom ! ;; will be badly confused. (unless (or noninteractive emacs-quick-startup (eq system-type 'ms-dos) ============================================================ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel