summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/elisp-mode-tests.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2021-09-21 22:20:17 +0100
committerJoão Távora <joaotavora@gmail.com>2021-09-27 01:07:11 +0100
commit90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd (patch)
treee76f8770ee587a6cfc0f77bd20ec2ce2c199eca1 /test/lisp/progmodes/elisp-mode-tests.el
parent68d73eb154c745cbba7b3fd6a0a0a087d7c157da (diff)
downloademacs-90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd.tar.gz
emacs-90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd.tar.bz2
emacs-90cbf0cb8d9959b94ba09f1faa0dcb50c8dbddbd.zip
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.
Diffstat (limited to 'test/lisp/progmodes/elisp-mode-tests.el')
-rw-r--r--test/lisp/progmodes/elisp-mode-tests.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el
index d5d3f336fac..9fe583d8cc3 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -1080,5 +1080,21 @@ evaluation of BODY."
(should (intern-soft "elisp--foo-test"))
(should-not (intern-soft "f-test"))))
+(ert-deftest elisp-shorthand-completion-at-point ()
+ (let ((test-file (expand-file-name "simple-shorthand-test.el"
+ elisp--test-resources-dir)))
+ (load test-file)
+ (with-current-buffer (find-file-noselect test-file)
+ (revert-buffer t t)
+ (goto-char (point-min))
+ (insert "f-test-compl")
+ (completion-at-point)
+ (goto-char (point-min))
+ (should (search-forward "f-test-complete-me" (line-end-position) t))
+ (goto-char (point-min))
+ (should (string= (symbol-name (read (current-buffer)))
+ "elisp--foo-test-complete-me"))
+ (revert-buffer t t))))
+
(provide 'elisp-mode-tests)
;;; elisp-mode-tests.el ends here