aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c
index 0d3376f0903..b3b157a7f39 100644
--- a/src/data.c
+++ b/src/data.c
@@ -216,6 +216,7 @@ for example, (type-of 1) returns `integer'. */)
216 case PVEC_NORMAL_VECTOR: return Qvector; 216 case PVEC_NORMAL_VECTOR: return Qvector;
217 case PVEC_BIGNUM: return Qinteger; 217 case PVEC_BIGNUM: return Qinteger;
218 case PVEC_MARKER: return Qmarker; 218 case PVEC_MARKER: return Qmarker;
219 case PVEC_SYMBOL_WITH_POS: return Qsymbol_with_pos;
219 case PVEC_OVERLAY: return Qoverlay; 220 case PVEC_OVERLAY: return Qoverlay;
220 case PVEC_FINALIZER: return Qfinalizer; 221 case PVEC_FINALIZER: return Qfinalizer;
221 case PVEC_USER_PTR: return Quser_ptr; 222 case PVEC_USER_PTR: return Quser_ptr;
@@ -316,6 +317,26 @@ DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0,
316 return Qt; 317 return Qt;
317} 318}
318 319
320DEFUN ("bare-symbol-p", Fbare_symbol_p, Sbare_symbol_p, 1, 1, 0,
321 doc: /* Return t if OBJECT is a symbol, but not a symbol together with position. */
322 attributes: const)
323 (Lisp_Object object)
324{
325 if (BARE_SYMBOL_P (object))
326 return Qt;
327 return Qnil;
328}
329
330DEFUN ("symbol-with-pos-p", Fsymbol_with_pos_p, Ssymbol_with_pos_p, 1, 1, 0,
331 doc: /* Return t if OBJECT is a symbol together with position. */
332 attributes: const)
333 (Lisp_Object object)
334{
335 if (SYMBOL_WITH_POS_P (object))
336 return Qt;
337 return Qnil;
338}
339
319DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, 340DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0,
320 doc: /* Return t if OBJECT is a symbol. */ 341 doc: /* Return t if OBJECT is a symbol. */
321 attributes: const) 342 attributes: const)
@@ -753,6 +774,51 @@ DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0,
753 return name; 774 return name;
754} 775}
755 776
777DEFUN ("bare-symbol", Fbare_symbol, Sbare_symbol, 1, 1, 0,
778 doc: /* Extract, if need be, the bare symbol from SYM, a symbol. */)
779 (register Lisp_Object sym)
780{
781 if (BARE_SYMBOL_P (sym))
782 return sym;
783 /* Type checking is done in the following macro. */
784 return SYMBOL_WITH_POS_SYM (sym);
785}
786
787DEFUN ("symbol-with-pos-pos", Fsymbol_with_pos_pos, Ssymbol_with_pos_pos, 1, 1, 0,
788 doc: /* Extract the position from a symbol with position. */)
789 (register Lisp_Object ls)
790{
791 /* Type checking is done in the following macro. */
792 return SYMBOL_WITH_POS_POS (ls);
793}
794
795DEFUN ("position-symbol", Fposition_symbol, Sposition_symbol, 2, 2, 0,
796 doc: /* Create a new symbol with position.
797SYM is a symbol, with or without position, the symbol to position.
798POS, the position, is either a fixnum or a symbol with position from which
799the position will be taken. */)
800 (register Lisp_Object sym, register Lisp_Object pos)
801{
802 Lisp_Object bare;
803 Lisp_Object position;
804
805 if (BARE_SYMBOL_P (sym))
806 bare = sym;
807 else if (SYMBOL_WITH_POS_P (sym))
808 bare = XSYMBOL_WITH_POS (sym)->sym;
809 else
810 wrong_type_argument (Qsymbolp, sym);
811
812 if (FIXNUMP (pos))
813 position = pos;
814 else if (SYMBOL_WITH_POS_P (pos))
815 position = XSYMBOL_WITH_POS (pos)->pos;
816 else
817 wrong_type_argument (Qfixnum_or_symbol_with_pos_p, pos);
818
819 return build_symbol_with_pos (bare, position);
820}
821
756DEFUN ("fset", Ffset, Sfset, 2, 2, 0, 822DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
757 doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. */) 823 doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. */)
758 (register Lisp_Object symbol, Lisp_Object definition) 824 (register Lisp_Object symbol, Lisp_Object definition)
@@ -3929,6 +3995,8 @@ syms_of_data (void)
3929 3995
3930 DEFSYM (Qlistp, "listp"); 3996 DEFSYM (Qlistp, "listp");
3931 DEFSYM (Qconsp, "consp"); 3997 DEFSYM (Qconsp, "consp");
3998 DEFSYM (Qbare_symbol_p, "bare-symbol-p");
3999 DEFSYM (Qsymbol_with_pos_p, "symbol-with-pos-p");
3932 DEFSYM (Qsymbolp, "symbolp"); 4000 DEFSYM (Qsymbolp, "symbolp");
3933 DEFSYM (Qfixnump, "fixnump"); 4001 DEFSYM (Qfixnump, "fixnump");
3934 DEFSYM (Qintegerp, "integerp"); 4002 DEFSYM (Qintegerp, "integerp");
@@ -3954,6 +4022,7 @@ syms_of_data (void)
3954 4022
3955 DEFSYM (Qchar_table_p, "char-table-p"); 4023 DEFSYM (Qchar_table_p, "char-table-p");
3956 DEFSYM (Qvector_or_char_table_p, "vector-or-char-table-p"); 4024 DEFSYM (Qvector_or_char_table_p, "vector-or-char-table-p");
4025 DEFSYM (Qfixnum_or_symbol_with_pos_p, "fixnum-or-symbol-with-pos-p");
3957 4026
3958 DEFSYM (Qsubrp, "subrp"); 4027 DEFSYM (Qsubrp, "subrp");
3959 DEFSYM (Qunevalled, "unevalled"); 4028 DEFSYM (Qunevalled, "unevalled");
@@ -4038,6 +4107,7 @@ syms_of_data (void)
4038 DEFSYM (Qstring, "string"); 4107 DEFSYM (Qstring, "string");
4039 DEFSYM (Qcons, "cons"); 4108 DEFSYM (Qcons, "cons");
4040 DEFSYM (Qmarker, "marker"); 4109 DEFSYM (Qmarker, "marker");
4110 DEFSYM (Qsymbol_with_pos, "symbol-with-pos");
4041 DEFSYM (Qoverlay, "overlay"); 4111 DEFSYM (Qoverlay, "overlay");
4042 DEFSYM (Qfinalizer, "finalizer"); 4112 DEFSYM (Qfinalizer, "finalizer");
4043 DEFSYM (Qmodule_function, "module-function"); 4113 DEFSYM (Qmodule_function, "module-function");
@@ -4089,6 +4159,8 @@ syms_of_data (void)
4089 defsubr (&Snumber_or_marker_p); 4159 defsubr (&Snumber_or_marker_p);
4090 defsubr (&Sfloatp); 4160 defsubr (&Sfloatp);
4091 defsubr (&Snatnump); 4161 defsubr (&Snatnump);
4162 defsubr (&Sbare_symbol_p);
4163 defsubr (&Ssymbol_with_pos_p);
4092 defsubr (&Ssymbolp); 4164 defsubr (&Ssymbolp);
4093 defsubr (&Skeywordp); 4165 defsubr (&Skeywordp);
4094 defsubr (&Sstringp); 4166 defsubr (&Sstringp);
@@ -4119,6 +4191,9 @@ syms_of_data (void)
4119 defsubr (&Sindirect_function); 4191 defsubr (&Sindirect_function);
4120 defsubr (&Ssymbol_plist); 4192 defsubr (&Ssymbol_plist);
4121 defsubr (&Ssymbol_name); 4193 defsubr (&Ssymbol_name);
4194 defsubr (&Sbare_symbol);
4195 defsubr (&Ssymbol_with_pos_pos);
4196 defsubr (&Sposition_symbol);
4122 defsubr (&Smakunbound); 4197 defsubr (&Smakunbound);
4123 defsubr (&Sfmakunbound); 4198 defsubr (&Sfmakunbound);
4124 defsubr (&Sboundp); 4199 defsubr (&Sboundp);
@@ -4201,6 +4276,12 @@ This variable cannot be set; trying to do so will signal an error. */);
4201 Vmost_negative_fixnum = make_fixnum (MOST_NEGATIVE_FIXNUM); 4276 Vmost_negative_fixnum = make_fixnum (MOST_NEGATIVE_FIXNUM);
4202 make_symbol_constant (intern_c_string ("most-negative-fixnum")); 4277 make_symbol_constant (intern_c_string ("most-negative-fixnum"));
4203 4278
4279 DEFSYM (Qsymbols_with_pos_enabled, "symbols-with-pos-enabled");
4280 DEFVAR_BOOL ("symbols-with-pos-enabled", symbols_with_pos_enabled,
4281 doc: /* Non-nil when "symbols with position" can be used as symbols.
4282Bind this to non-nil in applications such as the byte compiler. */);
4283 symbols_with_pos_enabled = false;
4284
4204 DEFSYM (Qwatchers, "watchers"); 4285 DEFSYM (Qwatchers, "watchers");
4205 DEFSYM (Qmakunbound, "makunbound"); 4286 DEFSYM (Qmakunbound, "makunbound");
4206 DEFSYM (Qunlet, "unlet"); 4287 DEFSYM (Qunlet, "unlet");