all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org
Subject: Re: More about blink-cursor-mode
Date: Tue, 22 Feb 2005 20:53:01 -0600 (CST)	[thread overview]
Message-ID: <200502230253.j1N2r1v28426@raven.dms.auburn.edu> (raw)
In-Reply-To: <877jl0909p.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Tue, 22 Feb 2005 08:52:29 -0500)

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)
============================================================

  reply	other threads:[~2005-02-23  2:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-20  1:55 More about blink-cursor-mode Luc Teirlinck
2005-02-20 21:38 ` Stefan
2005-02-21  3:27   ` Luc Teirlinck
2005-02-22  1:24   ` Luc Teirlinck
2005-02-22 13:52     ` Stefan Monnier
2005-02-23  2:53       ` Luc Teirlinck [this message]
2005-02-23  4:23         ` Stefan Monnier
2005-02-22  1:37   ` Luc Teirlinck
2005-02-22 13:54     ` Stefan Monnier
2005-02-22  8:42   ` Richard Stallman
2005-02-21 10:21 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200502230253.j1N2r1v28426@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.