emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Use default value if a variable is not defined


From: Ivan Andrus
Subject: Re: [O] Use default value if a variable is not defined
Date: Fri, 12 Oct 2012 17:52:31 +0200

On Oct 11, 2012, at 6:04 PM, Nathan Neff wrote:

> Hello,
> 
> I'm trying to create a function that will tell org-capture
> dynamically where to put the captured item.
> 
> I have it almost working -- where I'm getting hung up on is
> with basic Emacs lisp.  I want to basically implement this
> pseudo code:
> 
> IF I have defined a variable called njn/current-q-file then
>        (find-file njn/current-q-file)
> ELSE
>       (find-file ("questions.org")))
> 
> However, if I do not define my njn/current-q-file then
> I get a "Symbol's value as variable is void" error when Emacs starts up.
> 
> How do I test for the existence (and non-nil ness of a variable in Emacs)


You can use boundp.  So 

    (if (boundp 'njn/current-q-file)
        njn/current-q-file
      "questions.org")

can be used wherever you need it.

-Ivan




reply via email to

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