From: Gerd Möllmann Date: Tue, 18 Oct 2022 13:07:47 +0000 (+0200) Subject: Add amcros for keyword symbols X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a59cc12daca60db88a0666ed21beac572883a5d;p=emacs.git Add amcros for keyword symbols * src/lisp.h (SYMBOL_KEYWORD_P): Returns true if symbol is a keyword. (LISP_SYMBOL_NAME): Basically the same as Fsymbol_name, a shortcut. * src/data.c (Fsymbol_name): Use SYMBOL_KEYWORD_P. * src/pkg.c (pkg_intern_keyword): Use SYMBOL_KEYWORD_P. --- diff --git a/src/data.c b/src/data.c index 2f6b25805f2..dbf9f029b59 100644 --- a/src/data.c +++ b/src/data.c @@ -768,7 +768,7 @@ DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); - if (EQ (SYMBOL_PACKAGE (symbol), Vkeyword_package)) + if (SYMBOL_KEYWORD_P (symbol)) return concat2 (build_string (":"), SYMBOL_NAME (symbol)); return SYMBOL_NAME (symbol); } diff --git a/src/lisp.h b/src/lisp.h index fa1f48b933b..42f35656232 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2425,6 +2425,20 @@ SYMBOL_EXTERNAL_P (Lisp_Object sym) return XSYMBOL (sym)->u.s.external; } +INLINE bool +SYMBOL_KEYWORD_P (Lisp_Object sym) +{ + return EQ (XSYMBOL (sym)->u.s.package, Vkeyword_package); +} + +INLINE Lisp_Object +LISP_SYMBOL_NAME (Lisp_Object sym) +{ + if (SYMBOL_KEYWORD_P (sym)) + return Fsymbol_name (sym); + return SYMBOL_NAME (sym); +} + /* Value is non-zero if symbol cannot be changed through a simple set, i.e. it's a constant (e.g. nil, t, :keywords), or it has some watching functions. */ diff --git a/src/pkg.c b/src/pkg.c index 0da7aac4a97..3745dd69fb8 100644 --- a/src/pkg.c +++ b/src/pkg.c @@ -530,7 +530,7 @@ pkg_intern_keyword (Lisp_Object name) pkg_add_symbol (keyword, Vkeyword_package); } else - eassert (EQ (SYMBOL_PACKAGE (keyword), Vkeyword_package)); + eassert SYMBOL_KEYWORD_P (keyword); return keyword; }