unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stephen J. Turnbull'" <stephen@xemacs.org>
Cc: 'Emacs-Devel devel' <emacs-devel@gnu.org>, 'Miles Bader' <miles@gnu.org>
Subject: RE: `set-variable' should use :set
Date: Thu, 21 Oct 2010 21:34:32 -0700	[thread overview]
Message-ID: <823F3463F14A490A90A6075368296AC2@us.oracle.com> (raw)
In-Reply-To: <87bp6nklx2.fsf@uwakimon.sk.tsukuba.ac.jp>

>  > However, I disagree that [set-variable] is not that much more
>  > convenient than setq.  For one thing, it respects the defcustom
>  > :type spec.  For another, it uses a proper interactive spec.  The
>  > type-checking in particular is a win, IMO.
> 
> I don't find either of those noticable.

1. Type-checking is noticeable in that you cannot enter a value whose type
conflicts with the defcustom type.  With `setq' you can.  (The type mismatch
error message should be more helpful, however, instead of just saying "Value
`VAL' does not match type choice of OPTION".)

But I'm not trying to convince anyone to use `set-variable'.
It's fine if you don't find it useful.


2. The interactive reading of a value by `set-variable' depends on the variable
having a `variable-interactive' property.  I use that property in my own code,
but vanilla Emacs does not anymore.  (There are exactly 3 variables left in all
of the vanilla Lisp sources that have this property: `tags-file-name',
`sgml-transformation-function', and `skeleton-transformation-function'.)  So I'm
not surprised that you don't find it noticeable. ;-)

Try, for instance, `M-x set-variable tags-file-name' and compare the behavior
with that of `M-x set-variable custom-file'.  The former gives you file-name
completion.  The latter gives you nada.  That's a noticeable difference.

So yes, I would also BTW suggest that we use property `variable-interactive'
more.  Or better yet make Customize automatically DTRT, at least in the simple
cases (e.g. automatically set that property, or provide the behavior in some
other way), so that `set-variable' is helpful with the values of most user
options (not just 3!).

Even many defcustom `choice' types could be made accessible using completion.
Obviously `const' choices could, and even a type like `function' could, allowing
completion against known function names.  (The completion would be non-strict,
letting you enter a lambda form etc.)  `set-variable' could at least be made to
offer the degree of interactive help (e.g. completion) that is provided for
value-editing in Customize.

I never understood why this feature was abandoned.  The doc (`(elisp) Defining
Variables') says:

"If a user option variable has a `variable-interactive' property, the
`set-variable' command uses that value to control reading the new value
for the variable.  The property's value is used as if it were specified
in `interactive' (*note Using Interactive::).  However, this feature is
largely obsoleted by `defcustom' (*note Customization::)."

That last part is a bit presumptuous, IMHO.  Perhaps it means to say only that
`set-variable' is largely obsolete (although I don't see why it would be - it is
quick; Customize is not).  ("Obsolete" is not a verb BTW (e.g. "obsoleted"),
although it is true that you can verb any noun.)

But it seems to also be suggesting that Customize replaces `set-variable's
reading of a value according to an `interactive' spec, which it does not.

Customize sometimes lets you use completion when editing an option value,
granted.  But if you have to enter the jungle of Customize and survive to come
out the other side in order to get the benefit of an `interactive' spec (editing
the value) then I'd say that some of that benefit has been lost.  Just an
opinion.  One person's loss is another person's obsolete. ;-)

(Tomorrow morning some earnest soul will no doubt remove those 3 vestigial
`variable-interactive' properties in a cleanup sweep to purge the code once and
for all...)

>  > (FWIW, I use it often.)
> 
> I'm curious, what are your use cases?

As I said before, more or less the same use cases as using Customize to set a
value (without saving it):

 `M-x customize-option'
 Edit value or choose value using menu.
 Click `Set for this session'.
 `q'

When might one use Customize instead of setq?  I do it when I want to test
things that involve various option menu values, or when the option value is
somewhat complex.  Sometimes I'll keep a particular Customize buffer open in a
separate frame and make various value changes while testing things.

And setting a value using Customize instead of setq can help when I don't recall
the exact structure of the value (the custom :type).

`set-variable' is quicker for this than Customize.  It offers some of what
Customize offers but is as quick as setq.  However, it helps with the value
reading only if propery `variable-interactive' is set.  And again, it would help
more with the type if the mismatch error were more informative.

Let me be clear: by "often" I don't mean that I use `set-variable' every 3
minutes.  But I do use it fairly often instead of entering Customize or using
setq.

I also use other, non-vanilla commands to increment a numerical option, toggle
any binary option (not just custom-type `boolean'), and so on.

I use this kind of thing more than some people perhaps because I use Emacs to
develop and test Emacs-Lisp code more than I use Emacs for other things.  (The
only thing Emacs is good for is Emacs...but that's a lot.)

Also, I don't necessarily treat user options as things to be set once in a blue
moon and persist.  I don't mind commands that change option values, even
incrementally/dynamically.  Even if an option were never persisted its typing
would still be a useful feature.  I take advantage of both the typing and the
persistence of Emacs options without always treating them as statically as
others do.

I even proposed that Emacs allow for (i.e., optionally) typing non-option vars.
That suggestion was summarily dismissed by you - the sole responder, with the
single word "YAGNI".
http://lists.gnu.org/archive/html/emacs-devel/2009-10/msg00668.html

We have different views of Emacs and its features.  That's OK.  YAGNI.  But IUI.
 




  reply	other threads:[~2010-10-22  4:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 17:25 `set-variable' should use :set Drew Adams
2010-10-22  0:34 ` Miles Bader
2010-10-22  0:48   ` Miles Bader
2010-10-22  1:11     ` Drew Adams
2010-10-22  2:20       ` Stephen J. Turnbull
2010-10-22  4:34         ` Drew Adams [this message]
2010-10-22  7:17           ` Stephen J. Turnbull
2010-10-22  8:29             ` David Kastrup
2010-10-22 10:43           ` Juanma Barranquero
2010-10-22 13:40             ` Drew Adams
2010-10-22 14:02               ` David Kastrup
2010-10-22 22:42               ` Juanma Barranquero
2010-10-23  4:48                 ` Stephen J. Turnbull
2010-10-23 16:13                   ` Drew Adams
2010-10-23 17:47                     ` Juanma Barranquero
2010-10-23 18:44                       ` Glenn Morris
2010-10-23 19:01                       ` Jambunathan K
2010-10-24 16:15                       ` Chong Yidong
2010-10-22 14:01           ` Stefan Monnier
2010-10-22 16:03             ` Drew Adams
2010-10-22  7:42         ` Eli Zaretskii
2010-10-22  7:39       ` Eli Zaretskii
2010-10-22  8:16         ` Stephen J. Turnbull
2010-10-22  9:46           ` Eli Zaretskii

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=823F3463F14A490A90A6075368296AC2@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    --cc=stephen@xemacs.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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