* keywordp & :killing-the-cat
@ 2009-09-05 20:37 MON KEY
2009-09-05 21:14 ` Drew Adams
0 siblings, 1 reply; 2+ messages in thread
From: MON KEY @ 2009-09-05 20:37 UTC (permalink / raw
To: emacs-devel
How does one test whether a symbol is a keyword?
(keywordp :killing-the-cat-with-epr) ;=> t
(unintern :killing-the-cat-with-epr) ;=> t
(mapatoms (lambda (x)
(when (eq x :killing-the-cat-with-epr)
(prin1 `(found ,x))))
obarray)
;=>(found :killing-the-cat-with-epr)
Is this because keywords are self quoting?
And if so, how does one use keywordp to test if a (possibly
non-existent) keyword is interned without interning it?
i.e. (makunbound :killing-the-cat-with-epr) ;-> Lisp error:
(setting-constant :killing-the-cat-with-epr)
s_P
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: keywordp & :killing-the-cat
2009-09-05 20:37 keywordp & :killing-the-cat MON KEY
@ 2009-09-05 21:14 ` Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2009-09-05 21:14 UTC (permalink / raw
To: 'MON KEY', emacs-devel
> (keywordp :killing-the-cat-with-epr) ;=> t
> (unintern :killing-the-cat-with-epr) ;=> t
>
> (mapatoms (lambda (x)
> (when (eq x :killing-the-cat-with-epr)
> (prin1 `(found ,x))))
> obarray)
Evaluating (actually, Lisp reading) that sexp creates and interns a symbol
`:killing-the-cat-with-epr'.
Try this instead:
(mapatoms (lambda (x)
(when (string= (symbol-name x)
":killing-the-cat-with-epr")
(prin1 `(found ,x))))
obarray)
Replace ":killing-the-cat-with-epr" by the name of an existing symbol, e.g.
"forward-char", to see the difference.
> how does one use keywordp to test if a (possibly
> non-existent) keyword is interned without interning it?
You don't use keywordp for that. keywordp:
Return t if OBJECT is a keyword.
This means that it is a symbol with a print name beginning with `:'
interned in the initial obarray.
IOW, keywordp returns non-nil only for an interned symbol (whose print name
starts with `:').
If you want to check whether a symbol is interned, use `intern-soft':
(intern-soft ":killing-the-cat-with-epr") -> nil
(intern-soft "forward-char") -> forward-char
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-05 21:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-05 20:37 keywordp & :killing-the-cat MON KEY
2009-09-05 21:14 ` Drew Adams
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.