From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: obsolete comment in tool-bar.el Date: Fri, 8 Jul 2005 21:35:14 -0500 (CDT) Message-ID: <200507090235.j692ZER04883@raven.dms.auburn.edu> References: <200507071915.j67JFZT29961@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1120877845 17054 80.91.229.2 (9 Jul 2005 02:57:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 9 Jul 2005 02:57:25 +0000 (UTC) Cc: brakjoller@gmail.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 09 04:57:23 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dr5Wj-0006Kb-Ln for ged-emacs-devel@m.gmane.org; Sat, 09 Jul 2005 04:57:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dr5YB-0003Ek-78 for ged-emacs-devel@m.gmane.org; Fri, 08 Jul 2005 22:58:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dr5Wi-0002qE-7J for emacs-devel@gnu.org; Fri, 08 Jul 2005 22:57:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dr5WX-0002kn-Py for emacs-devel@gnu.org; Fri, 08 Jul 2005 22:57:08 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dr5WW-0002fn-0F for emacs-devel@gnu.org; Fri, 08 Jul 2005 22:57:00 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Dr5KR-0008Ej-Ks; Fri, 08 Jul 2005 22:44:31 -0400 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 j692bRCK017167; Fri, 8 Jul 2005 21:37:27 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j692ZER04883; Fri, 8 Jul 2005 21:35:14 -0500 (CDT) 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: (rms@gnu.org) 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 Xref: news.gmane.org gmane.emacs.devel:40669 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40669 Doing this work is the only way to get the benefit, so let's do it. If the solution below looks OK I will document it in the Elisp manual. Other people will need to help with this, since I do not fancy handling all 20-30 options, some of which I know nothing about, all by myself. I actually used two new predefined :initialize keywords. I thought it might be better not to automatically set the option to nil if not previously defined, since it could confuse somebody who changes the defcustom, then unbinds the option and reloads the file to try his revised code out. So the new :initialize functions act normally, except on error where they set the option to nil. That is, I automated the `condition-case' solution, rather than my own solution. Unlike the original described condition-case solution, the automated version does not unnecessarily clutter the expression the user sees when selecting "Show initial Lisp expression". I tested it out on two actual examples and it seems to work perfectly. The patches below actually simplify the tooltip-defcustom implementation by eliminating code duplication. I can install if desired. ===File ~/custom.el-diff==================================== *** custom.el 04 Jul 2005 19:45:29 -0500 1.87 --- custom.el 08 Jul 2005 20:49:11 -0500 *************** *** 76,81 **** --- 76,103 ---- (eval (car (get symbol 'saved-value))) (eval value))))) + (defun custom-initialize-safe-set (symbol value) + "Like `custom-initialize-set', but catches errors. + If an error occurs during evaluation of VALUE, SYMBOL is set to nil + and no error is signaled. This is meant for use in pre-loaded files + where some variables used to compute VALUE are not yet defined. + You can then re-evaluate VALUE in startup.el, for instance using + `custom-reevaluate-setting'." + (condition-case nil + (custom-initialize-set symbol value) + (error (set-default symbol nil)))) + + (defun custom-initialize-safe-default (symbol value) + "Like `custom-initialize-default', but catches errors. + If an error occurs during evaluation of VALUE, SYMBOL is set to nil + and no error is signaled. This is meant for use in pre-loaded files + where some variables used to compute VALUE are not yet defined. + You can then re-evaluate VALUE in startup.el, for instance using + `custom-reevaluate-setting'." + (condition-case nil + (custom-initialize-default symbol value) + (error (set-default symbol nil)))) + (defun custom-initialize-reset (symbol value) "Initialize SYMBOL based on VALUE. Set the symbol, using its `:set' function (or `set-default' if it has none). ============================================================ ===File ~/frame.el-diff===================================== *** frame.el 04 Jul 2005 19:47:20 -0500 1.223 --- frame.el 08 Jul 2005 19:39:25 -0500 *************** *** 1270,1278 **** displays through a window system, because then Emacs does its own cursor display. On a text-only terminal, this is not implemented." :init-value (not (or noninteractive ! (if (boundp 'no-blinking-cursor) no-blinking-cursor) (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)) --- 1270,1279 ---- displays through a window system, because then Emacs does its own cursor display. On a text-only terminal, this is not implemented." :init-value (not (or noninteractive ! no-blinking-cursor (eq system-type 'ms-dos) (not (memq window-system '(x w32))))) + :initialize 'custom-initialize-safe-default :group 'cursor :global t (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) ============================================================ ===File ~/tooltip.el-diff=================================== *** tooltip.el 04 Jul 2005 19:51:10 -0500 1.60 --- tooltip.el 08 Jul 2005 20:03:20 -0500 *************** *** 162,171 **** ;; If you change the :init-value below, you also need to change the ;; corresponding code in startup.el. :init-value (not (or noninteractive ! (and (boundp 'emacs-quick-startup) emacs-quick-startup) (not (and (fboundp 'display-graphic-p) (display-graphic-p))) (not (fboundp 'x-show-tip)))) :group 'tooltip (unless (or (null tooltip-mode) (fboundp 'x-show-tip)) (error "Sorry, tooltips are not yet available on this system")) --- 162,172 ---- ;; If you change the :init-value below, you also need to change the ;; corresponding code in startup.el. :init-value (not (or noninteractive ! emacs-quick-startup (not (and (fboundp 'display-graphic-p) (display-graphic-p))) (not (fboundp 'x-show-tip)))) + :initialize 'custom-initialize-safe-default :group 'tooltip (unless (or (null tooltip-mode) (fboundp 'x-show-tip)) (error "Sorry, tooltips are not yet available on this system")) ============================================================ ===File ~/startup.el-diff=================================== *** startup.el 04 Jul 2005 19:50:36 -0500 1.363 --- startup.el 08 Jul 2005 20:04:28 -0500 *************** *** 752,766 **** ;; are not set. (custom-reevaluate-setting 'blink-cursor-mode) (custom-reevaluate-setting 'normal-erase-is-backspace) ! ! ;; If you change the code below, you need to also change the ! ;; corresponding code in the tooltip-mode defcustom. The two need ! ;; to be equivalent under all conditions, or Custom will get confused. ! (unless (or noninteractive ! emacs-basic-display ! (not (display-graphic-p)) ! (not (fboundp 'x-show-tip))) ! (tooltip-mode 1)) ;; Register default TTY colors for the case the terminal hasn't a ;; terminal init file. --- 752,758 ---- ;; are not set. (custom-reevaluate-setting 'blink-cursor-mode) (custom-reevaluate-setting 'normal-erase-is-backspace) ! (custom-reevaluate-setting 'tooltip-mode) ;; Register default TTY colors for the case the terminal hasn't a ;; terminal init file. ============================================================