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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
(let ((elisp-shorthands '(("foo-" . "bar-"))))
|
||||
(intern "foo-bar")))
|
||||
|
||||
(defvar f-test-complete-me 42)
|
||||
|
||||
(when nil
|
||||
(f-test3)
|
||||
(f-test2)
|
||||
|
||||
Reference in New Issue
Block a user