From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: brakjoller@gmail.com, emacs-devel@gnu.org
Subject: Re: obsolete comment in tool-bar.el
Date: Fri, 8 Jul 2005 21:35:14 -0500 (CDT) [thread overview]
Message-ID: <200507090235.j692ZER04883@raven.dms.auburn.edu> (raw)
In-Reply-To: <E1Dqwpd-0006pY-7q@fencepost.gnu.org> (rms@gnu.org)
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.
============================================================
next prev parent reply other threads:[~2005-07-09 2:35 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-07 12:40 obsolete comment in tool-bar.el Mathias Dahl
2005-07-07 19:15 ` Luc Teirlinck
2005-07-08 6:40 ` Mathias Dahl
2005-07-08 15:29 ` Luc Teirlinck
2005-07-08 17:40 ` Richard M. Stallman
2005-07-08 18:53 ` Drew Adams
2005-07-09 1:53 ` Luc Teirlinck
2005-07-09 4:20 ` Richard M. Stallman
2005-07-09 2:35 ` Luc Teirlinck [this message]
2005-07-10 5:19 ` Richard M. Stallman
2005-07-11 3:21 ` Luc Teirlinck
2005-07-11 16:53 ` Richard M. Stallman
2005-07-11 17:56 ` David Kastrup
2005-07-11 20:28 ` Luc Teirlinck
2005-07-12 3:20 ` Richard M. Stallman
2005-07-13 3:02 ` Luc Teirlinck
2005-07-13 16:52 ` Richard M. Stallman
2005-07-14 2:08 ` Luc Teirlinck
2005-07-14 8:14 ` YAMAMOTO Mitsuharu
2005-07-14 16:50 ` Luc Teirlinck
2005-07-14 18:30 ` Luc Teirlinck
2005-07-15 4:35 ` Stefan Monnier
2005-07-15 13:53 ` Luc Teirlinck
2005-07-15 20:44 ` Stefan Monnier
2005-07-15 22:05 ` Luc Teirlinck
2005-07-15 22:46 ` Luc Teirlinck
2005-07-16 1:47 ` Luc Teirlinck
2005-07-16 2:04 ` Luc Teirlinck
2005-07-19 2:59 ` Luc Teirlinck
2005-07-19 14:41 ` Stefan Monnier
2005-07-20 4:05 ` Luc Teirlinck
2005-07-21 5:40 ` Stefan Monnier
2005-07-20 8:34 ` Richard M. Stallman
[not found] ` <E1Dt8bd-0001fH-Eu@fencepost.gnu.org>
2005-07-14 22:05 ` Luc Teirlinck
2005-07-15 3:24 ` Luc Teirlinck
2005-07-15 18:10 ` Richard M. Stallman
2005-07-16 2:32 ` Luc Teirlinck
2005-07-13 3:20 ` Luc Teirlinck
2005-07-09 3:57 ` Luc Teirlinck
2005-07-09 7:55 ` Eli Zaretskii
2005-07-09 13:57 ` Luc Teirlinck
2005-07-12 4:13 ` YAMAMOTO Mitsuharu
2005-07-12 12:20 ` YAMAMOTO Mitsuharu
2005-07-12 18:25 ` Luc Teirlinck
2005-07-12 23:58 ` Luc Teirlinck
2005-07-13 16:52 ` Richard M. Stallman
2005-07-12 20:19 ` Luc Teirlinck
2005-07-13 1:53 ` Luc Teirlinck
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=200507090235.j692ZER04883@raven.dms.auburn.edu \
--to=teirllm@dms.auburn.edu \
--cc=brakjoller@gmail.com \
--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.