summaryrefslogtreecommitdiff
path: root/src/lread.c
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2021-09-22 23:53:15 +0100
committerJoão Távora <joaotavora@gmail.com>2021-09-27 01:07:11 +0100
commit66f30875304e373c40e9b81aa37041d49bf7abfe (patch)
tree83429917e6bf2b949d6126858ce4d31ba14b7d92 /src/lread.c
parent90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd (diff)
downloademacs-66f30875304e373c40e9b81aa37041d49bf7abfe.tar.gz
emacs-66f30875304e373c40e9b81aa37041d49bf7abfe.tar.bz2
emacs-66f30875304e373c40e9b81aa37041d49bf7abfe.zip
Add #_ reader macro to escape shorthand renaming
* src/lread.c (read1): Add skip_shorthand variable. Add a '#_' case. If skip_shorthand call oblookup instead of oblookup_considering_shorthand. * test/lisp/progmodes/elisp-mode-tests.el (elisp-shorthand-escape): New test. * test/lisp/progmodes/elisp-resources/simple-shorthand-test.el (#_f-test4---): New fixture function.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lread.c b/src/lread.c
index 51a7084821e..db8c847a875 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2972,6 +2972,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
{
int c;
bool uninterned_symbol = false;
+ bool skip_shorthand = false;
bool multibyte;
char stackbuf[stackbufsize];
current_thread->stack_top = stackbuf;
@@ -3367,6 +3368,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (c == ':')
{
uninterned_symbol = true;
+ read_hash_prefixed_symbol:
c = READCHAR;
if (!(c > 040
&& c != NO_BREAK_SPACE
@@ -3380,6 +3382,12 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
}
goto read_symbol;
}
+ /* #_foo is really the symbol foo, regardless of shorthands */
+ if (c == '_')
+ {
+ skip_shorthand = true;
+ goto read_hash_prefixed_symbol;
+ }
/* ## is the empty symbol. */
if (c == '#')
return Fintern (empty_unibyte_string, Qnil);
@@ -3760,7 +3768,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
ptrdiff_t nbytes = p - read_buffer;
UNREAD (c);
- if (!quoted && !uninterned_symbol)
+ if (!quoted && !uninterned_symbol && !skip_shorthand)
{
ptrdiff_t len;
Lisp_Object result = string_to_number (read_buffer, 10, &len);
@@ -3795,10 +3803,14 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
ptrdiff_t longhand_chars = 0;
ptrdiff_t longhand_bytes = 0;
- Lisp_Object tem
- = oblookup_considering_shorthand
+ Lisp_Object tem;
+ if (skip_shorthand)
+ tem = oblookup (obarray, read_buffer, nchars, nbytes);
+ else {
+ tem = oblookup_considering_shorthand
(obarray, read_buffer, nchars, nbytes,
&longhand, &longhand_chars, &longhand_bytes);
+ }
if (SYMBOLP (tem))
result = tem;