emacs-devel
[Top][All Lists]
Advanced

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

Re: obsolete comment in tool-bar.el


From: Luc Teirlinck
Subject: Re: obsolete comment in tool-bar.el
Date: Fri, 8 Jul 2005 21:35:14 -0500 (CDT)

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




reply via email to

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