diff options
| author | Dmitry Gutov | 2015-05-03 23:57:38 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2015-05-03 23:57:38 +0300 |
| commit | ac5586a1037bae49738607d19fd008cd93f49ae2 (patch) | |
| tree | fc8ef96d6faafdbf79749f46bd7f2fc06455ffd5 /test | |
| parent | 2703629711f29f6a46e2766c10df5df5863d2ab9 (diff) | |
| download | emacs-ac5586a1037bae49738607d19fd008cd93f49ae2.tar.gz emacs-ac5586a1037bae49738607d19fd008cd93f49ae2.zip | |
elisp-completion-at-point: Prioritize being quoted over funpos
* lisp/progmodes/elisp-mode.el (elisp-completion-at-point):
Only consider function position when not inside quoted form
(bug#20425).
* test/automated/elisp-mode-tests.el: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/elisp-mode-tests.el | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/test/automated/elisp-mode-tests.el b/test/automated/elisp-mode-tests.el new file mode 100644 index 00000000000..a4148e9e5ff --- /dev/null +++ b/test/automated/elisp-mode-tests.el | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | ;;; elisp-mode-tests.el --- Tests for emacs-lisp-mode -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Dmitry Gutov <dgutov@yandex.ru> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | |||
| 26 | (defun elisp--test-completions () | ||
| 27 | (let ((data (elisp-completion-at-point))) | ||
| 28 | (all-completions (buffer-substring (nth 0 data) (nth 1 data)) | ||
| 29 | (nth 2 data) | ||
| 30 | (plist-get (nthcdr 3 data) :predicate)))) | ||
| 31 | |||
| 32 | (ert-deftest elisp-completes-functions () | ||
| 33 | (with-temp-buffer | ||
| 34 | (emacs-lisp-mode) | ||
| 35 | (insert "(ba") | ||
| 36 | (let ((comps (elisp--test-completions))) | ||
| 37 | (should (member "backup-buffer" comps)) | ||
| 38 | (should-not (member "backup-inhibited" comps))))) | ||
| 39 | |||
| 40 | (ert-deftest elisp-completes-variables () | ||
| 41 | (with-temp-buffer | ||
| 42 | (emacs-lisp-mode) | ||
| 43 | (insert "(foo ba") | ||
| 44 | (let ((comps (elisp--test-completions))) | ||
| 45 | (should (member "backup-inhibited" comps)) | ||
| 46 | (should-not (member "backup-buffer" comps))))) | ||
| 47 | |||
| 48 | (ert-deftest elisp-completes-anything-quoted () | ||
| 49 | (dolist (text '("`(foo ba" "(foo 'ba" | ||
| 50 | "`(,foo ba" "`,(foo `ba" | ||
| 51 | "'(foo (ba")) | ||
| 52 | (with-temp-buffer | ||
| 53 | (emacs-lisp-mode) | ||
| 54 | (insert text) | ||
| 55 | (let ((comps (elisp--test-completions))) | ||
| 56 | (should (member "backup-inhibited" comps)) | ||
| 57 | (should (member "backup-buffer" comps)) | ||
| 58 | (should (member "backup" comps)))))) | ||
| 59 | |||
| 60 | (ert-deftest elisp-completes-variables-unquoted () | ||
| 61 | (dolist (text '("`(foo ,ba" "`(,(foo ba" "`(,ba")) | ||
| 62 | (with-temp-buffer | ||
| 63 | (emacs-lisp-mode) | ||
| 64 | (insert text) | ||
| 65 | (let ((comps (elisp--test-completions))) | ||
| 66 | (should (member "backup-inhibited" comps)) | ||
| 67 | (should-not (member "backup-buffer" comps)))))) | ||
| 68 | |||
| 69 | (ert-deftest elisp-completes-functions-in-special-macros () | ||
| 70 | (dolist (text '("(declare-function ba" "(cl-callf2 ba")) | ||
| 71 | (with-temp-buffer | ||
| 72 | (emacs-lisp-mode) | ||
| 73 | (insert text) | ||
| 74 | (let ((comps (elisp--test-completions))) | ||
| 75 | (should (member "backup-buffer" comps)) | ||
| 76 | (should-not (member "backup-inhibited" comps)))))) | ||
| 77 | |||
| 78 | (ert-deftest elisp-completes-local-variables () | ||
| 79 | (with-temp-buffer | ||
| 80 | (emacs-lisp-mode) | ||
| 81 | (insert "(let ((bar 1) baz) (foo ba") | ||
| 82 | (let ((comps (elisp--test-completions))) | ||
| 83 | (should (member "backup-inhibited" comps)) | ||
| 84 | (should (member "bar" comps)) | ||
| 85 | (should (member "baz" comps))))) | ||
| 86 | |||
| 87 | (provide 'elisp-mode-tests) | ||
| 88 | ;;; elisp-mode-tests.el ends here | ||