From: Drew Adams <drew.adams@oracle.com>
To: "N. Raghavendra" <nyraghu27132@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: RE: About how misspelled word are displayed
Date: Fri, 12 May 2017 15:08:44 -0700 (PDT) [thread overview]
Message-ID: <262055bc-44b9-4b2b-932a-52b146a5916e@default> (raw)
In-Reply-To: <87efvtzrw5.fsf@gmail.com>
> Evaluating (customize-set-variable option value) uses the :set property
> of OPTION, but doesn't check that VALUE has the type specified in the
> (defcustom option ...) expression.
Correct. Likewise, `custom-set-variables'. They assume that
when used non-interactively the new value is of the right type.
This is perhaps a holdover from their Customize pedigree: if
written by Customize, `custom-set-variables' uses a valid type,
and `customize-set-variable' was probably expected to be used
mostly interactively (and interactively it does provide some
type checking).
Please consider filing an enhancement request that would make
them optionally check the type (e.g. by an optional argument):
`M-x report-emacs-bug'.
This needs to be optional not only for backward compatibility
but also because this checking can slow things down considerably,
and it is not needed at all for a `custom-set-variables' set by
Customize.
While waiting (... ;-)) you can define your own function,
similar to `customize-set-variable' but which does the type
checking. Here is the type-checking code from `set-variable':
(let ((type (get variable 'custom-type)))
(when type ; Match with custom type.
(require 'cus-edit)
(setq type (widget-convert type))
(unless (widget-apply type :match value)
(error "Value `%S' does not match type %S of %S"
value (car type) variable))))
> On the other hand, evaluating (set-variable option value) does
> this type-checking, but ignores the :set property of OPTION.
Correct.
See these threads:
http://lists.gnu.org/archive/html/emacs-devel/2010-10/msg00813.html
http://lists.gnu.org/archive/html/emacs-devel/2006-06/msg00137.html
http://lists.gnu.org/archive/html/emacs-devel/2011-03/msg00106.html
http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01481.html
Emacs Dev has several times discussed removing `set-variable' altogether.
I'm in favor of keeping it - at least as long as it does things
that `customize-set-variable' does not do.
> So, is there a recommended way of setting an
> option using Emacs Lisp directly (without going through customization
> buffers), which ensures that the :set, :type, :initialize, and other
> specifications of the option are respected?
Not that I know of - not ready-made. See above.
next prev parent reply other threads:[~2017-05-12 22:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-12 9:49 About how misspelled word are displayed Angelo Graziosi
2017-05-12 13:09 ` Kaushal Modi
2017-05-12 14:07 ` Angelo Graziosi
2017-05-12 14:14 ` tomas
2017-05-12 14:27 ` Emanuel Berg
2017-05-12 15:16 ` Drew Adams
2017-05-12 16:27 ` Emanuel Berg
2017-05-12 17:32 ` Drew Adams
2017-05-12 18:00 ` Emanuel Berg
2017-05-12 21:15 ` tomas
2017-05-12 21:28 ` N. Raghavendra
2017-05-12 22:08 ` Drew Adams [this message]
2017-05-13 14:15 ` N. Raghavendra
2017-05-13 14:59 ` Emanuel Berg
2017-05-13 15:07 ` Emanuel Berg
2017-05-13 15:22 ` Emanuel Berg
2017-05-13 15:34 ` N. Raghavendra
2017-05-13 15:54 ` Emanuel Berg
2017-05-13 17:59 ` Drew Adams
2017-05-14 13:07 ` N. Raghavendra
2017-05-12 19:30 ` Angelo Graziosi
2017-05-12 20:34 ` Drew Adams
2017-05-12 20:41 ` Drew Adams
2017-05-12 22:14 ` Angelo Graziosi
2017-05-12 23:42 ` Emanuel Berg
2017-05-13 0:22 ` John Mastro
2017-05-13 9:53 ` Emanuel Berg
2017-05-12 21:07 ` Emanuel Berg
2017-05-12 19:57 ` Angelo Graziosi
2017-05-12 20:56 ` Emanuel Berg
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=262055bc-44b9-4b2b-932a-52b146a5916e@default \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=nyraghu27132@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).