unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: Jean Louis <bugs@gnu.support>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to test if symbol from string exists?
Date: Fri, 16 Apr 2021 09:20:13 +0000	[thread overview]
Message-ID: <7dee3f42358324b05f83@heytings.org> (raw)
In-Reply-To: <courier.0000000060795452.00006B1D@stw1.rcdrun.com>


>
> I would like to test if symbol exists. So I am trying this:
>
> (bound-and-true-p (intern "rcd-db-people-mode-map"))
>
> and I get error:
>
> Wrong type argument: symbolp, (intern "rcd-db-people-mode-map")
>

That's because bound-and-true-p quotes its argument.  You can use another 
macro for that:

(defmacro bound-and-true-symbol-p (name)
   "Return the value of symbol with name NAME if it is bound, else nil."
   `(and (boundp (intern ,name)) (symbol-value (intern ,name))))



  reply	other threads:[~2021-04-16  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16  9:09 How to test if symbol from string exists? Jean Louis
2021-04-16  9:20 ` Gregory Heytings [this message]
2021-04-16  9:22 ` Philip Kaludercic
2021-04-16 10:04   ` Jean Louis

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=7dee3f42358324b05f83@heytings.org \
    --to=gregory@heytings.org \
    --cc=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).