From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: find-file-hook as illustration of Custom problems Date: Wed, 9 Feb 2005 23:12:21 -0600 (CST) Message-ID: <200502100512.j1A5CLJ29641@raven.dms.auburn.edu> References: <200502040036.j140atb03430@raven.dms.auburn.edu> <200502060150.j161oqh15336@raven.dms.auburn.edu> <200502080150.j181oMf07339@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1108014152 13236 80.91.229.2 (10 Feb 2005 05:42:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Feb 2005 05:42:32 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 10 06:42:32 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Cz75w-0000wc-DC for ged-emacs-devel@m.gmane.org; Thu, 10 Feb 2005 06:42:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cz7JT-0001d0-HP for ged-emacs-devel@m.gmane.org; Thu, 10 Feb 2005 00:56:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cz7Is-0001Zf-Kf for emacs-devel@gnu.org; Thu, 10 Feb 2005 00:55:50 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cz7Ii-0001TY-PF for emacs-devel@gnu.org; Thu, 10 Feb 2005 00:55:45 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cz7Ii-0001TP-EZ for emacs-devel@gnu.org; Thu, 10 Feb 2005 00:55:40 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cz6eP-0002JU-2Q; Thu, 10 Feb 2005 00:14:01 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j1A5Ds9N003086; Wed, 9 Feb 2005 23:13:54 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j1A5CLJ29641; Wed, 9 Feb 2005 23:12:21 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Wed, 09 Feb 2005 03:10:46 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:33177 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:33177 Richard Stallman wrote: This is the wrong solution. The right solution for variables such as minibuffer-prompt-properties is to set up a valid expression for its standard value. It may be necessary to store the current default value in a new variable so that the standard value can use that variable. This is easy and simple, it's just that each variable needs to be looked at separately. Would you like to do this for some of the variables? Yes, for some. Here is a try at one. Actually, I started out with my least favorite Emacs feature, `blink-cursor'. Reason for that is that this one had a very intriguing bug. This extra bug is unrelated to the stuff we have been discussing here, but we should fix it anyway. It is confusing and annoying. Description of bug: Do `emacs -q --eval "(blink-cursor-mode 0)" &'. Then: M-x customize-rogue (actually, `C-h v blink-cursor' works too). We now see that blink-cursor is t, even though the cursor does not blink. If we do `M-x load-library RET frame", the cursor _does_ start blinking. (Courtesy of custom-initialize-reset. I looked away as fast as I could and typed `C-x C-c'.) The problem is that the function `blink-cursor-mode' sets the value of the variable blink-cursor-mode, but not of blink-cursor. The patch below does get rid of blink-cursor altogether and uses blink-cursor-mode instead. I know there must have been some reason why that was not done all along, but I guess it must have been related to the fake defcustom stuff, which the patch also gets rid of (that was the original purpose). One problem is that this will mess things up for the (I suppose many) people who have set blink-cursor to nil_in their custom-set-variables form. The patch keeps blink-cursor as an alias for blink-cursor-mode, but Custom does apparently not recognize aliases. (That is probably something we could and should fix still for Emacs 22.) I do not know whether the combination phony-defvar, then defvar-mimicking setq, then makunbound, then non-top-level defcustom in startup.el is acceptable. It seems to do the job. The problem with a temporary variable, as you suggested, seems to be that code should use the same variable during startup and after that, so it did not seem like it would work very well. As a minor detail: `blink-cursor-timer' now seems to call `blink-cursor-timer-function' instead of `blink-cursor'. The patch addresses this too. ===File ~/frame.el-diff===================================== *** frame.el 09 Feb 2005 15:59:13 -0600 1.215 --- frame.el 09 Feb 2005 22:50:04 -0600 *************** *** 1253,1262 **** (defvar blink-cursor-timer nil "Timer started from `blink-cursor-start'. ! This timer calls `blink-cursor' every `blink-cursor-interval' seconds.") ! (defvar blink-cursor-mode nil ! "Non-nil means blinking cursor is active.") (defun blink-cursor-mode (arg) "Toggle blinking cursor mode. --- 1253,1267 ---- (defvar blink-cursor-timer nil "Timer started from `blink-cursor-start'. ! This timer calls `blink-cursor-timer-function' every ! `blink-cursor-interval' seconds.") ! ;; This will be unbound and defcustomed in startup.el. We can not ! ;; defcustom it here because the default depends on the operating system. ! (defvar blink-cursor-mode) ! (defvaralias 'blink-cursor 'blink-cursor-mode) ! (make-obsolete-variable 'blink-cursor 'blink-cursor-mode "22.1") ! (unless (boundp 'blink-cursor-mode) (setq blink-cursor-mode nil)) (defun blink-cursor-mode (arg) "Toggle blinking cursor mode. *************** *** 1289,1306 **** (setq blink-cursor-mode t)) (internal-show-cursor nil t)))) - ;; Note that this is really initialized from startup.el before - ;; the init-file is read. - - (defcustom blink-cursor nil - "*Non-nil means blinking cursor mode is active." - :group 'cursor - :tag "Blinking cursor" - :type 'boolean - :set #'(lambda (symbol value) - (set-default symbol value) - (blink-cursor-mode (or value 0)))) - (defun blink-cursor-start () "Timer function called from the timer `blink-cursor-idle-timer'. This starts the timer `blink-cursor-timer', which makes the cursor blink --- 1294,1299 ---- ============================================================ ===File ~/startup.el-diff=================================== *** startup.el 28 Dec 2004 09:50:38 -0600 1.337 --- startup.el 09 Feb 2005 19:46:22 -0600 *************** *** 735,747 **** (<= (frame-parameter nil 'tool-bar-lines) 0)) (tool-bar-mode 1)) ! ;; Can't do this init in defcustom because window-system isn't set. ! (unless (or noninteractive ! emacs-quick-startup ! (eq system-type 'ms-dos) ! (not (memq window-system '(x w32)))) ! (setq-default blink-cursor t) ! (blink-cursor-mode 1)) (unless noninteractive ;; DOS/Windows systems have a PC-type keyboard which has both --- 735,753 ---- (<= (frame-parameter nil 'tool-bar-lines) 0)) (tool-bar-mode 1)) ! (makunbound 'blink-cursor-mode) ! (defcustom blink-cursor-mode ! (not (or noninteractive ! emacs-quick-startup ! (eq system-type 'ms-dos) ! (not (memq window-system '(x w32))))) ! "*Non-nil means Blinking Cursor mode is active." ! :group 'cursor ! :tag "Blinking cursor" ! :type 'boolean ! :set #'(lambda (symbol value) ! (set-default symbol value) ! (blink-cursor-mode (or value 0)))) (unless noninteractive ;; DOS/Windows systems have a PC-type keyboard which has both ============================================================ LocalWords: defvar