all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ivan Andrus <darthandrus@gmail.com>
To: Nathan Neff <nathan.neff@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Use default value if a variable is not defined
Date: Fri, 12 Oct 2012 17:52:31 +0200	[thread overview]
Message-ID: <0010E925-4776-44F0-AB92-A6AAEEAAE894@gmail.com> (raw)
In-Reply-To: <CAC=HedAr5KshVp2E_h-LZOhZ_1HE927z+8j0_0g-j1T7mwZ-Tw@mail.gmail.com>

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	other threads:[~2012-10-12 15:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11 16:04 Use default value if a variable is not defined Nathan Neff
2012-10-12 15:52 ` Ivan Andrus [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0010E925-4776-44F0-AB92-A6AAEEAAE894@gmail.com \
    --to=darthandrus@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nathan.neff@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.