diff options
author | Johan Claesson <[email protected]> | 2016-06-13 19:08:25 +0200 |
---|---|---|
committer | Johan Claesson <[email protected]> | 2016-06-14 17:47:00 +0200 |
commit | f129398908a8b33e150323e54ba540d077c1f4b3 (patch) | |
tree | e6102cd5d476fbc2641d84a75821cc81528a8585 /lib/tools/emacs/erlang-test.el | |
parent | 481ac2a246c53c29033648ae5adda2c215fcc924 (diff) | |
download | otp-f129398908a8b33e150323e54ba540d077c1f4b3.tar.gz otp-f129398908a8b33e150323e54ba540d077c1f4b3.tar.bz2 otp-f129398908a8b33e150323e54ba540d077c1f4b3.zip |
Tag completion in Emacs 25
Adapt tag completion for changes in Emacs 25.
Stop storing module:tag entries in the completion table for definitions
in hrl-files. These entries make no sense since hrl-files are not
modules.
Add test-case for tag completion in erlang-test.el.
Ensure prog-mode is defined for the sake of Emacs 23 and XEmacs.
Diffstat (limited to 'lib/tools/emacs/erlang-test.el')
-rw-r--r-- | lib/tools/emacs/erlang-test.el | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/lib/tools/emacs/erlang-test.el b/lib/tools/emacs/erlang-test.el index a5aab04953..9a146632c5 100644 --- a/lib/tools/emacs/erlang-test.el +++ b/lib/tools/emacs/erlang-test.el @@ -33,6 +33,7 @@ (require 'ert) (require 'cl-lib) +(require 'erlang) (defvar erlang-test-code '((nil . "-module(erlang_test).") @@ -51,27 +52,28 @@ concatenated to form an erlang file to test on.") (ert-deftest erlang-test-tags () (let* ((dir (make-temp-file "erlang-test" t)) - (erlang-file (expand-file-name "erlang_test.erl" dir)) - (tags-file (expand-file-name "TAGS" dir)) - tags-file-name tags-table-list erlang-buffer) - (unwind-protect - (progn - (erlang-test-create-erlang-file erlang-file) - (erlang-test-compile-tags erlang-file tags-file) - (setq erlang-buffer (find-file-noselect erlang-file)) - (with-current-buffer erlang-buffer - (setq-local tags-file-name tags-file)) - ;; PENDING - setting global tags-file-name is a workaround - ;; for GNU Emacs bug23164. - (setq tags-file-name tags-file) - (erlang-test-xref-find-definitions erlang-file erlang-buffer)) - (when (buffer-live-p erlang-buffer) - (kill-buffer erlang-buffer)) - (let ((tags-buffer (find-buffer-visiting tags-file))) - (when (buffer-live-p tags-buffer) - (kill-buffer tags-buffer))) - (when (file-exists-p dir) - (delete-directory dir t))))) + (erlang-file (expand-file-name "erlang_test.erl" dir)) + (tags-file (expand-file-name "TAGS" dir)) + tags-file-name tags-table-list erlang-buffer) + (unwind-protect + (progn + (erlang-test-create-erlang-file erlang-file) + (erlang-test-compile-tags erlang-file tags-file) + (setq erlang-buffer (find-file-noselect erlang-file)) + (with-current-buffer erlang-buffer + (setq-local tags-file-name tags-file)) + ;; Setting global tags-file-name is a workaround for + ;; GNU Emacs bug#23164. + (setq tags-file-name tags-file) + (erlang-test-completion-table) + (erlang-test-xref-find-definitions erlang-file erlang-buffer)) + (when (buffer-live-p erlang-buffer) + (kill-buffer erlang-buffer)) + (let ((tags-buffer (find-buffer-visiting tags-file))) + (when (buffer-live-p tags-buffer) + (kill-buffer tags-buffer))) + (when (file-exists-p dir) + (delete-directory dir t))))) (defun erlang-test-create-erlang-file (erlang-file) (with-temp-file erlang-file @@ -83,6 +85,19 @@ concatenated to form an erlang file to test on.") "-o" tags-file erlang-file)))) +(defun erlang-test-completion-table () + (let ((erlang-replace-etags-tags-completion-table t)) + (setq tags-completion-table nil) + (tags-completion-table)) + (should (equal (sort tags-completion-table #'string-lessp) + (sort (erlang-expected-completion-table) #'string-lessp)))) + +(defun erlang-expected-completion-table () + (append (cl-loop for (symbol . _) in erlang-test-code + when (stringp symbol) + append (list symbol (concat "erlang_test:" symbol))) + (list "erlang_test:" "erlang_test:module_info"))) + (defun erlang-test-xref-find-definitions (erlang-file erlang-buffer) (cl-loop for (tagname . code) in erlang-test-code for line = 1 then (1+ line) |