From 90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd Mon Sep 17 00:00:00 2001 From: João Távora Date: Tue, 21 Sep 2021 22:20:17 +0100 Subject: Consider shorthands in Elisp's elisp-completion-at-point Instead of referencing obarray directly, that function has to consider a collection of completions which includes the shorthand versions of some of the symbols. That collection changes from buffer to buffer, depending on the choice of elisp-shorthands. To make this process efficient, and avoid needless recalculation of the above collection, a new obarray-specific cache was invented. The Elisp variable obarray-cache is immediately nullified if something touches the obarray. * lisp/progmodes/elisp-mode.el : New helper. (elisp-completion-at-point): Use new helpers. (elisp--completion-local-symbols) (elisp--fboundp-considering-shorthands) (elisp--bboundp-considering-shorthands): New helpers * src/lread.c (intern_driver): Nullify Qobarray_cache. (syms_of_lread): Add Qobarray_cache. * test/lisp/progmodes/elisp-mode-tests.el (elisp-shorthand-completion-at-point): New test. * test/lisp/progmodes/elisp-resources/simple-shorthand-test.el (f-test-complete-me): New fixture. --- src/lread.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/lread.c b/src/lread.c index 4b7fcc2875b..51a7084821e 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4356,6 +4356,7 @@ intern_sym (Lisp_Object sym, Lisp_Object obarray, Lisp_Object index) Lisp_Object intern_driver (Lisp_Object string, Lisp_Object obarray, Lisp_Object index) { + SET_SYMBOL_VAL (XSYMBOL (Qobarray_cache), Qnil); return intern_sym (Fmake_symbol (string), obarray, index); } @@ -5427,4 +5428,5 @@ that are loaded before your customizations are read! */); DEFVAR_LISP ("elisp-shorthands", Velisp_shorthands, doc: /* Alist of known symbol name shorthands*/); Velisp_shorthands = Qnil; + DEFSYM (Qobarray_cache, "obarray-cache"); } -- cgit v1.2.1