aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert2024-03-11 00:03:39 -0700
committerPaul Eggert2024-03-11 00:34:27 -0700
commit2d61ebb505977af4f9fd90f92a776599a73f8501 (patch)
tree3ac892ed33305f86f65444caed2dd56e3a41c298 /src/data.c
parentbbc53e0bcf3fe18e7c1cd51fb8719cf62b9f6c71 (diff)
downloademacs-2d61ebb505977af4f9fd90f92a776599a73f8501.tar.gz
emacs-2d61ebb505977af4f9fd90f92a776599a73f8501.zip
Change bare-symbol back to match intent
Also, attempt to document the intent better. Problem reported by Alan Mackenzie (Bug#69684). * src/data.c (Fbare_symbol): Do not signal if the SYM is a symbol with position and symbols-with-pos-enabled is nil. Instead, ignore symbols-with-pos-enabled, as that was the intent. * test/src/data-tests.el (data-tests-bare-symbol): New test, to help prevent this bug from reoccurring.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/data.c b/src/data.c
index df08eaf8102..35f4c82c68f 100644
--- a/src/data.c
+++ b/src/data.c
@@ -339,7 +339,8 @@ DEFUN ("bare-symbol-p", Fbare_symbol_p, Sbare_symbol_p, 1, 1, 0,
339} 339}
340 340
341DEFUN ("symbol-with-pos-p", Fsymbol_with_pos_p, Ssymbol_with_pos_p, 1, 1, 0, 341DEFUN ("symbol-with-pos-p", Fsymbol_with_pos_p, Ssymbol_with_pos_p, 1, 1, 0,
342 doc: /* Return t if OBJECT is a symbol together with position. */ 342 doc: /* Return t if OBJECT is a symbol together with position.
343Ignore `symbols-with-pos-enabled'. */
343 attributes: const) 344 attributes: const)
344 (Lisp_Object object) 345 (Lisp_Object object)
345{ 346{
@@ -789,25 +790,32 @@ Doing that might make Emacs dysfunctional, and might even crash Emacs. */)
789} 790}
790 791
791DEFUN ("bare-symbol", Fbare_symbol, Sbare_symbol, 1, 1, 0, 792DEFUN ("bare-symbol", Fbare_symbol, Sbare_symbol, 1, 1, 0,
792 doc: /* Extract, if need be, the bare symbol from SYM, a symbol. */) 793 doc: /* Extract, if need be, the bare symbol from SYM.
794SYM is either a symbol or a symbol with position.
795Ignore `symbols-with-pos-enabled'. */)
793 (register Lisp_Object sym) 796 (register Lisp_Object sym)
794{ 797{
795 CHECK_SYMBOL (sym); 798 if (BARE_SYMBOL_P (sym))
796 return BARE_SYMBOL_P (sym) ? sym : XSYMBOL_WITH_POS_SYM (sym); 799 return sym;
800 if (SYMBOL_WITH_POS_P (sym))
801 return XSYMBOL_WITH_POS_SYM (sym);
802 xsignal2 (Qwrong_type_argument, list2 (Qsymbolp, Qsymbol_with_pos_p), sym);
797} 803}
798 804
799DEFUN ("symbol-with-pos-pos", Fsymbol_with_pos_pos, Ssymbol_with_pos_pos, 1, 1, 0, 805DEFUN ("symbol-with-pos-pos", Fsymbol_with_pos_pos, Ssymbol_with_pos_pos, 1, 1, 0,
800 doc: /* Extract the position from a symbol with position. */) 806 doc: /* Extract the position from the symbol with position SYMPOS.
801 (register Lisp_Object ls) 807Ignore `symbols-with-pos-enabled'. */)
808 (register Lisp_Object sympos)
802{ 809{
803 CHECK_TYPE (SYMBOL_WITH_POS_P (ls), Qsymbol_with_pos_p, ls); 810 CHECK_TYPE (SYMBOL_WITH_POS_P (sympos), Qsymbol_with_pos_p, sympos);
804 return XSYMBOL_WITH_POS_POS (ls); 811 return XSYMBOL_WITH_POS_POS (sympos);
805} 812}
806 813
807DEFUN ("remove-pos-from-symbol", Fremove_pos_from_symbol, 814DEFUN ("remove-pos-from-symbol", Fremove_pos_from_symbol,
808 Sremove_pos_from_symbol, 1, 1, 0, 815 Sremove_pos_from_symbol, 1, 1, 0,
809 doc: /* If ARG is a symbol with position, return it without the position. 816 doc: /* If ARG is a symbol with position, return it without the position.
810Otherwise, return ARG unchanged. Compare with `bare-symbol'. */) 817Otherwise, return ARG unchanged. Ignore `symbols-with-pos-enabled'.
818Compare with `bare-symbol'. */)
811 (register Lisp_Object arg) 819 (register Lisp_Object arg)
812{ 820{
813 if (SYMBOL_WITH_POS_P (arg)) 821 if (SYMBOL_WITH_POS_P (arg))
@@ -816,10 +824,11 @@ Otherwise, return ARG unchanged. Compare with `bare-symbol'. */)
816} 824}
817 825
818DEFUN ("position-symbol", Fposition_symbol, Sposition_symbol, 2, 2, 0, 826DEFUN ("position-symbol", Fposition_symbol, Sposition_symbol, 2, 2, 0,
819 doc: /* Create a new symbol with position. 827 doc: /* Make a new symbol with position.
820SYM is a symbol, with or without position, the symbol to position. 828SYM is a symbol, with or without position, the symbol to position.
821POS, the position, is either a fixnum or a symbol with position from which 829POS, the position, is either a nonnegative fixnum,
822the position will be taken. */) 830or a symbol with position from which the position will be taken.
831Ignore `symbols-with-pos-enabled'. */)
823 (register Lisp_Object sym, register Lisp_Object pos) 832 (register Lisp_Object sym, register Lisp_Object pos)
824{ 833{
825 Lisp_Object bare = Fbare_symbol (sym); 834 Lisp_Object bare = Fbare_symbol (sym);
@@ -4374,7 +4383,7 @@ This variable cannot be set; trying to do so will signal an error. */);
4374 4383
4375 DEFSYM (Qsymbols_with_pos_enabled, "symbols-with-pos-enabled"); 4384 DEFSYM (Qsymbols_with_pos_enabled, "symbols-with-pos-enabled");
4376 DEFVAR_BOOL ("symbols-with-pos-enabled", symbols_with_pos_enabled, 4385 DEFVAR_BOOL ("symbols-with-pos-enabled", symbols_with_pos_enabled,
4377 doc: /* Non-nil when "symbols with position" can be used as symbols. 4386 doc: /* If non-nil, a symbol with position ordinarily behaves as its bare symbol.
4378Bind this to non-nil in applications such as the byte compiler. */); 4387Bind this to non-nil in applications such as the byte compiler. */);
4379 symbols_with_pos_enabled = false; 4388 symbols_with_pos_enabled = false;
4380 4389