* Use default value if a variable is not defined
@ 2012-10-11 16:04 Nathan Neff
2012-10-12 15:52 ` Ivan Andrus
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Neff @ 2012-10-11 16:04 UTC (permalink / raw)
To: emacs-orgmode
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)
Thanks,
--Nate
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Use default value if a variable is not defined
2012-10-11 16:04 Use default value if a variable is not defined Nathan Neff
@ 2012-10-12 15:52 ` Ivan Andrus
0 siblings, 0 replies; 2+ messages in thread
From: Ivan Andrus @ 2012-10-12 15:52 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-12 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-11 16:04 Use default value if a variable is not defined Nathan Neff
2012-10-12 15:52 ` Ivan Andrus
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.