[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More about blink-cursor-mode

From: Luc Teirlinck
Subject: Re: More about blink-cursor-mode
Date: Mon, 21 Feb 2005 19:24:32 -0600 (CST)

Stefan Monnier wrote:

   Any objection?

Well, you already installed it, but there are some problems.  I
replied earlier that I would look at it today.

You removed:

(defvar blink-cursor-mode)
(unless (boundp 'blink-cursor-mode) (setq blink-cursor-mode nil))

which ensured that the value when evaluated before startup.el was
loaded would be nil.

Now it turns out that removing this actually works, unlike the person
who wrote the initial code, and later me, thought.  There are several
variables in the form that are not yet defined.  However, at the time
the code is executed, noninteractive appears to be always t.  Because
this is the first expression in the `or' form, the `or' evalutes to t,
without evaluating the other, not yet defined, variables in the `or'
form, thereby avoiding the error.  Because the `or' is preceded by
not, the temporary value that `blink-cursor-mode' gets is nil, as it
should be.  All of this is not necessarily less tricky than the two
lines of code above.  We must make sure that anybody trying to change
the expression knows about the importance of the noniteractive trick
and about the fact that he should also change the identical expression
in startup.el, where noninteractive may be nil (unless running in
batch mode) and the real value is established.

Also, after your change, the user options `blink-cursor-mode' and
`blink-cursor-mode-hook' wind up in a special group, blink-cursor,
which has no parent group and which browsing Custom will hence never
find.  They should be in the cursor group, together with other options
related to cursor blinking.

   In any case all this round-about hack seems completely unnecessary

It will be necessary for other options that still need to be given a
correct Custom standard expression and for which the noninteractive
coincidence will not happen.

   and if really the standard expression signals an error if it is
   evaluated too early, then we can just wrap it with a
   (condition-case nil ... (error nil)) or some such.

One _definitely_ does not want to rap a Custom standard expression in
a condition-case.

   Seems like a much better option than this nasty unexplained stuff
   we have now.

The comment tried to explain it.

The comment left after your change does not make a lot of sense any

Maybe it is better to put the:

(defvar blink-cursor-mode)
(unless (default-boundp 'blink-cursor-mode)
   (setq-default blink-cursor-mode nil))

with something like the original comment back in, to protect against
future code changes, that might undo the current lucky coincidence.

If not, I believe that the comment in the patch below should be added.
The :group _definitely_ should be changed back to 'cursor, as the
patch below does.

===File ~/frame.el-newdiff==================================
*** frame.el    21 Feb 2005 14:18:13 -0600      1.217
--- frame.el    21 Feb 2005 18:35:09 -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,1271 ----
  This timer calls `blink-cursor-timer-function' every
  `blink-cursor-interval' seconds.")
! ;; The :init-value given below is evaluated at startup, before
! ;; startup.el is loaded.  At that time, the variables it uses do not
! ;; yet have their correct values.  Because noninteractive is t at the
! ;; time, the :init-value evaluates to nil.  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 be very confused.
! ;; You should also make sure that the new expression still evaluates
! ;; to nil before startup.el is loaded.
  (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 ****
--- 1279,1285 ----
                       (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))
 LocalWords:  noninteractive evalutes noniteractive newdiff

reply via email to

[Prev in Thread] Current Thread [Next in Thread]