aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mackenzie2023-09-04 12:51:24 +0000
committerAlan Mackenzie2023-09-04 12:51:24 +0000
commitafcb6d0bc7abcdbca6b18d020deeff24d1ad197f (patch)
tree1561281df0284ced50d19005770c00023e7a617e /src
parent55a0f0e047034b3a458b6fdbe245f33b83fd88b0 (diff)
downloademacs-afcb6d0bc7abcdbca6b18d020deeff24d1ad197f.tar.gz
emacs-afcb6d0bc7abcdbca6b18d020deeff24d1ad197f.zip
Correct the handling of symbols with position in equal
* src/fns.c (internal_equal): Only regard symbols with position as their symbols when symbols-with-pos-enabled is non-nil. * doc/lispref/symbols.texi (Symbols with Position): Expand the description of symbols with position, in particular the way they work with eq and equal. * doc/lispref/objects.texi (Equality Predicates): Describe how eq and equal handle symbols with position. * test/src/fns-tests.el (fns-tests-equal-symbols-with-position): New tests for symbols with position.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/fns.c b/src/fns.c
index ae9969a5432..bd1d63a58c4 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2774,10 +2774,13 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
2774 2774
2775 /* A symbol with position compares the contained symbol, and is 2775 /* A symbol with position compares the contained symbol, and is
2776 `equal' to the corresponding ordinary symbol. */ 2776 `equal' to the corresponding ordinary symbol. */
2777 if (SYMBOL_WITH_POS_P (o1)) 2777 if (symbols_with_pos_enabled)
2778 o1 = SYMBOL_WITH_POS_SYM (o1); 2778 {
2779 if (SYMBOL_WITH_POS_P (o2)) 2779 if (SYMBOL_WITH_POS_P (o1))
2780 o2 = SYMBOL_WITH_POS_SYM (o2); 2780 o1 = SYMBOL_WITH_POS_SYM (o1);
2781 if (SYMBOL_WITH_POS_P (o2))
2782 o2 = SYMBOL_WITH_POS_SYM (o2);
2783 }
2781 2784
2782 if (BASE_EQ (o1, o2)) 2785 if (BASE_EQ (o1, o2))
2783 return true; 2786 return true;
@@ -2825,8 +2828,8 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
2825 if (ASIZE (o2) != size) 2828 if (ASIZE (o2) != size)
2826 return false; 2829 return false;
2827 2830
2828 /* Compare bignums, overlays, markers, and boolvectors 2831 /* Compare bignums, overlays, markers, boolvectors, and
2829 specially, by comparing their values. */ 2832 symbols with position specially, by comparing their values. */
2830 if (BIGNUMP (o1)) 2833 if (BIGNUMP (o1))
2831 return mpz_cmp (*xbignum_val (o1), *xbignum_val (o2)) == 0; 2834 return mpz_cmp (*xbignum_val (o1), *xbignum_val (o2)) == 0;
2832 if (OVERLAYP (o1)) 2835 if (OVERLAYP (o1))
@@ -2858,6 +2861,11 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
2858 if (TS_NODEP (o1)) 2861 if (TS_NODEP (o1))
2859 return treesit_node_eq (o1, o2); 2862 return treesit_node_eq (o1, o2);
2860#endif 2863#endif
2864 if (SYMBOL_WITH_POS_P(o1)) /* symbols_with_pos_enabled is false. */
2865 return (BASE_EQ (XSYMBOL_WITH_POS (o1)->sym,
2866 XSYMBOL_WITH_POS (o2)->sym)
2867 && BASE_EQ (XSYMBOL_WITH_POS (o1)->pos,
2868 XSYMBOL_WITH_POS (o2)->pos));
2861 2869
2862 /* Aside from them, only true vectors, char-tables, compiled 2870 /* Aside from them, only true vectors, char-tables, compiled
2863 functions, and fonts (font-spec, font-entity, font-object) 2871 functions, and fonts (font-spec, font-entity, font-object)