From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Andrus Subject: Re: Use default value if a variable is not defined Date: Fri, 12 Oct 2012 17:52:31 +0200 Message-ID: <0010E925-4776-44F0-AB92-A6AAEEAAE894@gmail.com> References: Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMhXS-00071s-EQ for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 11:52:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMhXO-0000jc-BV for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 11:52:38 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:51857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMhXO-0000jM-58 for emacs-orgmode@gnu.org; Fri, 12 Oct 2012 11:52:34 -0400 Received: by mail-ee0-f41.google.com with SMTP id c4so2255598eek.0 for ; Fri, 12 Oct 2012 08:52:33 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nathan Neff Cc: emacs-orgmode 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