[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Test for `save-abbrevs' improvement
From: |
Juanma Barranquero |
Subject: |
Re: Test for `save-abbrevs' improvement |
Date: |
Fri, 17 Feb 2006 21:31:48 +0100 |
On 2/17/06, Kevin Rodgers <address@hidden> wrote:
> No, you don't want to match (function silently), only (const silently),
> and then only if it is actually a choice widget:
Yes, of course. If I were writing code for a generally useful package,
I'd do all the tests. This is only for my .emacs, though, so quick &
not-too-dirty is fine.
> > (and (listp (get 'save-abbrevs 'custom-type)) 'silently)
>
> That looks completely wrong to me. What are you trying to express?
Is not wrong. It tries to express: "if the custom type is a list,
return 'silently; otherwise, return nil". Which it does.
> What? I thought your goal was to determine whether or not save-abbrevs
> could be meaningfully set to silently. If it has type boolean, nil is
> the only distinguished value and silently is just another non-nil value.
In Emacs 21.1, save-abbrevs was boolean. In 22.0.50, it is not; t and
nil mean the same thing that back in 21.1, but 'silently means (as
expected) "save quietly".
So, if you put
(setq save-abbrevs 'silently)
on your .emacs and use it with 21.1, it will ask you *every time*
whether you do want to save the abbreviations (because, as you say, it
takes 'silently as non-nil, and hence true). I do not want to be asked
always, so I resort to setting it to 'silently on 22.0 and nil in
21.1. That's what my code does.
My original question could be formulated like this: "How can you know
when a variable accepts new values, other than checking the Emacs
version". Obviously there's no generic answer, so I was making do with
checking the docstring. Your answer, for which I am grateful, is: "if
the variable is a customization var, its custom-type *could* have the
relevant info". Good idea. :)
> Isn't there something like:
>
> (and (fboundp 'function-arity)
> (> (function-arity 'list-faces-display) 0))
No, there isn't a `function-arity'. There's a `subr-arity' for
builtins, the trick I use for compiled functions, and asorted other
tricks for other kinds of functions or function-lookalikes (for
example, `ad-arglist' for advised functions, etc.).
--
/L/e/k/t/u