diff options
| author | Gerd Möllmann | 2022-10-12 13:53:07 +0200 |
|---|---|---|
| committer | Gerd Möllmann | 2022-10-12 14:09:33 +0200 |
| commit | b3cdb8a3d3aba0ea537ecabd2900a3682e7c0660 (patch) | |
| tree | 8f20aa6cb1b0a1b1e6e24f8518697f8e12cd61c6 /src | |
| parent | 3e29407122da36e942c9a1c44e701f8aacae7c72 (diff) | |
| download | emacs-b3cdb8a3d3aba0ea537ecabd2900a3682e7c0660.tar.gz emacs-b3cdb8a3d3aba0ea537ecabd2900a3682e7c0660.zip | |
Intern keywords differently
Instead of something like (intern (format ":%s" ...)) do
(intern (format "%s" :keyword). Likewise in C.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/lread.c | 35 | ||||
| -rw-r--r-- | src/pkg.c | 13 |
4 files changed, 42 insertions, 10 deletions
diff --git a/src/image.c b/src/image.c index 1e323ba66a0..f6209149313 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -10072,7 +10072,7 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent]) | |||
| 10072 | if (! CONSP (val)) | 10072 | if (! CONSP (val)) |
| 10073 | return NULL; | 10073 | return NULL; |
| 10074 | 10074 | ||
| 10075 | format = image_spec_value (spec, intern (":format"), NULL); | 10075 | format = image_spec_value (spec, QCformat, NULL); |
| 10076 | val = Fcar_safe (Fcdr_safe (Fassq (format, val))); | 10076 | val = Fcar_safe (Fcdr_safe (Fassq (format, val))); |
| 10077 | if (! STRINGP (val)) | 10077 | if (! STRINGP (val)) |
| 10078 | return NULL; | 10078 | return NULL; |
diff --git a/src/lisp.h b/src/lisp.h index 68a7233abd0..c5ce309306f 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2268,6 +2268,8 @@ extern Lisp_Object pkg_emacs_intern_soft (Lisp_Object name, Lisp_Object package) | |||
| 2268 | extern Lisp_Object pkg_emacs_unintern (Lisp_Object name, Lisp_Object package); | 2268 | extern Lisp_Object pkg_emacs_unintern (Lisp_Object name, Lisp_Object package); |
| 2269 | extern bool pkg_intern_name_c_string (const char *p, ptrdiff_t len, Lisp_Object *symbol); | 2269 | extern bool pkg_intern_name_c_string (const char *p, ptrdiff_t len, Lisp_Object *symbol); |
| 2270 | extern void pkg_early_intern_symbol (Lisp_Object symbol); | 2270 | extern void pkg_early_intern_symbol (Lisp_Object symbol); |
| 2271 | extern Lisp_Object pkg_lookup_c_string (const char *ptr, ptrdiff_t nchars, ptrdiff_t nbytes); | ||
| 2272 | extern void pkg_break (void); | ||
| 2271 | 2273 | ||
| 2272 | extern bool package_system_ready; | 2274 | extern bool package_system_ready; |
| 2273 | 2275 | ||
diff --git a/src/lread.c b/src/lread.c index 4260850399f..edd50efd16b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4138,7 +4138,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) | |||
| 4138 | /* If of the form ||, everything except '|' is considered quoted. | 4138 | /* If of the form ||, everything except '|' is considered quoted. |
| 4139 | the bars doesn't belong to the symbol name. */ | 4139 | the bars doesn't belong to the symbol name. */ |
| 4140 | bool in_vertical_bar = false; | 4140 | bool in_vertical_bar = false; |
| 4141 | if (c == '|') | 4141 | if (!read_emacs_syntax && c == '|') |
| 4142 | { | 4142 | { |
| 4143 | in_vertical_bar = true; | 4143 | in_vertical_bar = true; |
| 4144 | c = READCHAR; | 4144 | c = READCHAR; |
| @@ -4160,19 +4160,22 @@ read0 (Lisp_Object readcharfun, bool locate_syms) | |||
| 4160 | { | 4160 | { |
| 4161 | if (c == ':' && !last_was_backslash && !in_vertical_bar) | 4161 | if (c == ':' && !last_was_backslash && !in_vertical_bar) |
| 4162 | { | 4162 | { |
| 4163 | /* #:xyz should not contain a colon. */ | ||
| 4164 | if (uninterned_symbol) | ||
| 4165 | invalid_syntax ("colon in uninterned symbol", readcharfun); | ||
| 4166 | |||
| 4167 | /* Remember where the first : is. */ | 4163 | /* Remember where the first : is. */ |
| 4168 | if (colon == NULL) | 4164 | if (colon == NULL) |
| 4169 | colon = p; | 4165 | colon = p; |
| 4170 | ++ncolons; | 4166 | ++ncolons; |
| 4171 | 4167 | ||
| 4172 | /* Up to two colons are allowed if they are | 4168 | if (!read_emacs_syntax) |
| 4173 | consecutive. PKG-FIXME check consecutive :. */ | 4169 | { |
| 4174 | if (ncolons > 2) | 4170 | /* #:xyz should not contain a colon. */ |
| 4175 | invalid_syntax ("too many colons", readcharfun); | 4171 | if (uninterned_symbol) |
| 4172 | invalid_syntax ("colon in uninterned symbol", readcharfun); | ||
| 4173 | |||
| 4174 | /* Up to two colons are allowed if they are | ||
| 4175 | consecutive. PKG-FIXME check consecutive :. */ | ||
| 4176 | if (ncolons > 2) | ||
| 4177 | invalid_syntax ("too many colons", readcharfun); | ||
| 4178 | } | ||
| 4176 | } | 4179 | } |
| 4177 | 4180 | ||
| 4178 | /* Handle backslash. The first backslash is not part of | 4181 | /* Handle backslash. The first backslash is not part of |
| @@ -4219,6 +4222,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) | |||
| 4219 | symbol. */ | 4222 | symbol. */ |
| 4220 | if (in_vertical_bar) | 4223 | if (in_vertical_bar) |
| 4221 | { | 4224 | { |
| 4225 | eassert (!read_emacs_syntax); | ||
| 4222 | if (c < 0) | 4226 | if (c < 0) |
| 4223 | end_of_file_error (); | 4227 | end_of_file_error (); |
| 4224 | if (c == '|') | 4228 | if (c == '|') |
| @@ -4826,6 +4830,8 @@ A second optional argument specifies the obarray to use; | |||
| 4826 | it defaults to the value of `obarray'. */) | 4830 | it defaults to the value of `obarray'. */) |
| 4827 | (Lisp_Object string, Lisp_Object package) | 4831 | (Lisp_Object string, Lisp_Object package) |
| 4828 | { | 4832 | { |
| 4833 | /* PKG-FIXME: Remove this eassert. */ | ||
| 4834 | eassert (SREF (string, 0) != ':' || !package_system_ready); | ||
| 4829 | return pkg_emacs_intern (string, package); | 4835 | return pkg_emacs_intern (string, package); |
| 4830 | } | 4836 | } |
| 4831 | 4837 | ||
| @@ -4862,6 +4868,10 @@ usage: (unintern NAME OBARRAY) */) | |||
| 4862 | Lisp_Object | 4868 | Lisp_Object |
| 4863 | oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff_t size_byte) | 4869 | oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff_t size_byte) |
| 4864 | { | 4870 | { |
| 4871 | const Lisp_Object found = pkg_lookup_c_string (ptr, size, size_byte); | ||
| 4872 | if (!EQ (found, Qunbound)) | ||
| 4873 | return found; | ||
| 4874 | |||
| 4865 | size_t hash; | 4875 | size_t hash; |
| 4866 | size_t obsize; | 4876 | size_t obsize; |
| 4867 | register Lisp_Object tail; | 4877 | register Lisp_Object tail; |
| @@ -4897,6 +4907,7 @@ oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff | |||
| 4897 | void | 4907 | void |
| 4898 | map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Object arg) | 4908 | map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Object arg) |
| 4899 | { | 4909 | { |
| 4910 | eassert (package_system_ready); | ||
| 4900 | ptrdiff_t i; | 4911 | ptrdiff_t i; |
| 4901 | register Lisp_Object tail; | 4912 | register Lisp_Object tail; |
| 4902 | CHECK_VECTOR (obarray); | 4913 | CHECK_VECTOR (obarray); |
| @@ -4917,6 +4928,7 @@ map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Ob | |||
| 4917 | static void | 4928 | static void |
| 4918 | mapatoms_1 (Lisp_Object sym, Lisp_Object function) | 4929 | mapatoms_1 (Lisp_Object sym, Lisp_Object function) |
| 4919 | { | 4930 | { |
| 4931 | eassert (package_system_ready); | ||
| 4920 | call1 (function, sym); | 4932 | call1 (function, sym); |
| 4921 | } | 4933 | } |
| 4922 | 4934 | ||
| @@ -4925,6 +4937,7 @@ DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, | |||
| 4925 | OBARRAY defaults to the value of `obarray'. */) | 4937 | OBARRAY defaults to the value of `obarray'. */) |
| 4926 | (Lisp_Object function, Lisp_Object obarray) | 4938 | (Lisp_Object function, Lisp_Object obarray) |
| 4927 | { | 4939 | { |
| 4940 | eassert (package_system_ready); | ||
| 4928 | if (NILP (obarray)) obarray = Vobarray; | 4941 | if (NILP (obarray)) obarray = Vobarray; |
| 4929 | obarray = check_obarray (obarray); | 4942 | obarray = check_obarray (obarray); |
| 4930 | 4943 | ||
| @@ -5575,6 +5588,10 @@ that are loaded before your customizations are read! */); | |||
| 5575 | doc: /* Non-nil means not to load a .eln file when a .elc was requested. */); | 5588 | doc: /* Non-nil means not to load a .eln file when a .elc was requested. */); |
| 5576 | load_no_native = false; | 5589 | load_no_native = false; |
| 5577 | 5590 | ||
| 5591 | DEFVAR_BOOL ("read-emacs-syntax", read_emacs_syntax, | ||
| 5592 | doc: /* Non-nil means don't treat ':' or '|' specially in symbols. */); | ||
| 5593 | read_emacs_syntax = true; | ||
| 5594 | |||
| 5578 | /* Vsource_directory was initialized in init_lread. */ | 5595 | /* Vsource_directory was initialized in init_lread. */ |
| 5579 | 5596 | ||
| 5580 | DEFSYM (Qcurrent_load_list, "current-load-list"); | 5597 | DEFSYM (Qcurrent_load_list, "current-load-list"); |
| @@ -555,6 +555,15 @@ pkg_intern_name_c_string (const char *p, ptrdiff_t len, Lisp_Object *symbol) | |||
| 555 | return true; | 555 | return true; |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | Lisp_Object | ||
| 559 | pkg_lookup_c_string (const char *ptr, ptrdiff_t nchars, ptrdiff_t nbytes) | ||
| 560 | { | ||
| 561 | if (!package_system_ready) | ||
| 562 | return Qunbound; | ||
| 563 | const Lisp_Object name = make_string_from_bytes (ptr, nchars, nbytes); | ||
| 564 | return lookup_symbol (name, Vearmuffs_package); | ||
| 565 | } | ||
| 566 | |||
| 558 | void | 567 | void |
| 559 | pkg_early_intern_symbol (Lisp_Object symbol) | 568 | pkg_early_intern_symbol (Lisp_Object symbol) |
| 560 | { | 569 | { |
| @@ -582,6 +591,10 @@ pkg_unintern_symbol (Lisp_Object symbol, Lisp_Object package) | |||
| 582 | return Qnil; | 591 | return Qnil; |
| 583 | } | 592 | } |
| 584 | 593 | ||
| 594 | void pkg_break (void) | ||
| 595 | { | ||
| 596 | } | ||
| 597 | |||
| 585 | 598 | ||
| 586 | /*********************************************************************** | 599 | /*********************************************************************** |
| 587 | Old Emacs intern stuff | 600 | Old Emacs intern stuff |