[Top][All Lists]

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

Re: How to see that a variable holds t

From: Pascal J. Bourguignon
Subject: Re: How to see that a variable holds t
Date: Mon, 04 Jan 2010 17:44:16 +0100
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.3 (gnu/linux)

Cecil Westerhof <address@hidden> writes:

> address@hidden (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.

Yes, you have to be careful.  In general operators that are common to
emacs lisp and Common Lisp are rather similar, but there are sometimes
some significant differences, and sometimes more subtle differences.
Always check with the doc.  You could even bind space to automatically
find the doc for you:

(defun space-doc ()
    (backward-sexp) (backward-char)
    (when (looking-at "(")
      (when (thing-at-point 'symbol)
        (let* ((start (point))
               (end (progn (forward-sexp) (point)))
               (symname (buffer-substring start end)))
          (ignore-errors (describe-function (intern symname)))))))
  (insert " "))

(global-set-key (kbd "SPC") 'space-doc)
;; Or use local-set-key in mode hooks where you write emacs lisp code
;; such as emacs-lisp-mode-hook.

__Pascal Bourguignon__           

reply via email to

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