help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to see that a variable holds t


From: Cecil Westerhof
Subject: Re: How to see that a variable holds t
Date: Mon, 04 Jan 2010 10:29:23 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

pjb@informatimago.com (Pascal J. Bourguignon) writes:

>> What I really would like is;
>>     (defun switch-gnus-idle-daemon-do-log ()
>>       (interactive)
>>       (setq gnus-idle-daemon-do-log
>>             (case gnus-idle-daemon-do-log
>>               (t         10)
>>               (otherwise t)))
>>       (message "gnus-idle-daemon-do-log: %s" gnus-idle-daemon-do-log))
>>
>> Because I would like the default to be t and not 10. (For when the value
>> is not one of the defined values.) But when I do this, it is always set
>> to 10, because the case does not make a difference between t and 10. How
>> do I solve this?
>
> The first clause is always selected because in emacs lisp, t and
> otherwise are equivalent in case.
>
> I don't understand you people!  How fucking difficult is it to type
> C-h f case RET and READ the documentation?

I had looked up case, but not in Emacs itself. In the definition I found
it was not mentioned that t is the same as otherwise.


> Write it as:
>
>      (defun switch-gnus-idle-daemon-do-log ()
>        (interactive)
>        (setq gnus-idle-daemon-do-log
>              (case gnus-idle-daemon-do-log
>                ((t)       10)
>                (otherwise t)))
>        (message "gnus-idle-daemon-do-log: %s" gnus-idle-daemon-do-log))
>
> (switch-gnus-idle-daemon-do-log)
> "gnus-idle-daemon-do-log: t"
> (switch-gnus-idle-daemon-do-log)
> "gnus-idle-daemon-do-log: 10"
> (switch-gnus-idle-daemon-do-log)
> "gnus-idle-daemon-do-log: t"

Works like a charm. Thanks.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


reply via email to

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