diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2024-03-11 00:03:39 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2024-03-11 00:34:27 -0700 |
commit | 2d61ebb505977af4f9fd90f92a776599a73f8501 (patch) | |
tree | 3ac892ed33305f86f65444caed2dd56e3a41c298 /src/data.c | |
parent | bbc53e0bcf3fe18e7c1cd51fb8719cf62b9f6c71 (diff) | |
download | emacs-2d61ebb505977af4f9fd90f92a776599a73f8501.tar.gz |
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.c | 35 |
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, } DEFUN ("symbol-with-pos-p", Fsymbol_with_pos_p, Ssymbol_with_pos_p, 1, 1, 0, - doc: /* Return t if OBJECT is a symbol together with position. */ + doc: /* Return t if OBJECT is a symbol together with position. +Ignore `symbols-with-pos-enabled'. */ attributes: const) (Lisp_Object object) { @@ -789,25 +790,32 @@ Doing that might make Emacs dysfunctional, and might even crash Emacs. */) } DEFUN ("bare-symbol", Fbare_symbol, Sbare_symbol, 1, 1, 0, - doc: /* Extract, if need be, the bare symbol from SYM, a symbol. */) + doc: /* Extract, if need be, the bare symbol from SYM. +SYM is either a symbol or a symbol with position. +Ignore `symbols-with-pos-enabled'. */) (register Lisp_Object sym) { - CHECK_SYMBOL (sym); - return BARE_SYMBOL_P (sym) ? sym : XSYMBOL_WITH_POS_SYM (sym); + if (BARE_SYMBOL_P (sym)) + return sym; + if (SYMBOL_WITH_POS_P (sym)) + return XSYMBOL_WITH_POS_SYM (sym); + xsignal2 (Qwrong_type_argument, list2 (Qsymbolp, Qsymbol_with_pos_p), sym); } DEFUN ("symbol-with-pos-pos", Fsymbol_with_pos_pos, Ssymbol_with_pos_pos, 1, 1, 0, - doc: /* Extract the position from a symbol with position. */) - (register Lisp_Object ls) + doc: /* Extract the position from the symbol with position SYMPOS. +Ignore `symbols-with-pos-enabled'. */) + (register Lisp_Object sympos) { - CHECK_TYPE (SYMBOL_WITH_POS_P (ls), Qsymbol_with_pos_p, ls); - return XSYMBOL_WITH_POS_POS (ls); + CHECK_TYPE (SYMBOL_WITH_POS_P (sympos), Qsymbol_with_pos_p, sympos); + return XSYMBOL_WITH_POS_POS (sympos); } DEFUN ("remove-pos-from-symbol", Fremove_pos_from_symbol, Sremove_pos_from_symbol, 1, 1, 0, doc: /* If ARG is a symbol with position, return it without the position. -Otherwise, return ARG unchanged. Compare with `bare-symbol'. */) +Otherwise, return ARG unchanged. Ignore `symbols-with-pos-enabled'. +Compare with `bare-symbol'. */) (register Lisp_Object arg) { if (SYMBOL_WITH_POS_P (arg)) @@ -816,10 +824,11 @@ Otherwise, return ARG unchanged. Compare with `bare-symbol'. */) } DEFUN ("position-symbol", Fposition_symbol, Sposition_symbol, 2, 2, 0, - doc: /* Create a new symbol with position. + doc: /* Make a new symbol with position. SYM is a symbol, with or without position, the symbol to position. -POS, the position, is either a fixnum or a symbol with position from which -the position will be taken. */) +POS, the position, is either a nonnegative fixnum, +or a symbol with position from which the position will be taken. +Ignore `symbols-with-pos-enabled'. */) (register Lisp_Object sym, register Lisp_Object pos) { Lisp_Object bare = Fbare_symbol (sym); @@ -4374,7 +4383,7 @@ This variable cannot be set; trying to do so will signal an error. */); DEFSYM (Qsymbols_with_pos_enabled, "symbols-with-pos-enabled"); DEFVAR_BOOL ("symbols-with-pos-enabled", symbols_with_pos_enabled, - doc: /* Non-nil when "symbols with position" can be used as symbols. + doc: /* If non-nil, a symbol with position ordinarily behaves as its bare symbol. Bind this to non-nil in applications such as the byte compiler. */); symbols_with_pos_enabled = false; |