From 749813e9d4a844384e0450f6f7f88484b15e348a Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Mon, 22 Dec 2014 02:24:42 -0300 Subject: python.el: Fix electric colon behavior * lisp/progmodes/python.el (python-indent-post-self-insert-function): Make colon to re-indent only for dedenters, handling multiline-statements gracefully. * test/automated/python-tests.el (python-indent-electric-colon-2) (python-indent-electric-colon-3): New tests. --- test/automated/python-tests.el | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index f84ded8cad2..d1713ac1851 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -740,6 +740,39 @@ def b() (python-tests-self-insert ":") (should (= (current-indentation) 0)))) +(ert-deftest python-indent-electric-colon-2 () + "Test indentation case for dedenter." + (python-tests-with-temp-buffer + " +if do: + something() + else +" + (python-tests-look-at "else") + (goto-char (line-end-position)) + (python-tests-self-insert ":") + (should (= (current-indentation) 0)))) + +(ert-deftest python-indent-electric-colon-3 () + "Test indentation case for multi-line dedenter." + (python-tests-with-temp-buffer + " +if do: + something() + elif (this + and + that) +" + (python-tests-look-at "that)") + (goto-char (line-end-position)) + (python-tests-self-insert ":") + (python-tests-look-at "elif" -1) + (should (= (current-indentation) 0)) + (python-tests-look-at "and") + (should (= (current-indentation) 6)) + (python-tests-look-at "that)") + (should (= (current-indentation) 6)))) + (ert-deftest python-indent-region-1 () "Test indentation case from Bug#18843." (let ((contents " -- cgit v1.2.1 From 7284a174abc03c9ccf45aa43c939585beea351b7 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Fri, 26 Dec 2014 17:59:33 -0300 Subject: python.el: Generate clearer shell buffer names. * lisp/progmodes/python.el (python-shell-get-process-name) (python-shell-internal-get-process-name): Use `buffer-name`. (python-shell-internal-get-or-create-process): Simplify. * test/automated/python-tests.el (python-shell-get-process-name-1) (python-shell-internal-get-process-name-1): Cleanup. (python-shell-get-process-name-2) (python-shell-internal-get-process-name-2): New tests. (python-shell-calculate-command-1) (python-shell-calculate-process-environment-3) (python-shell-calculate-exec-path-2, python-shell-make-comint-1) (python-shell-make-comint-2, python-shell-make-comint-4) (python-shell-get-process-1, python-util-clone-local-variables-1): Replace obsolete function and variable references with current. --- test/automated/python-tests.el | 99 +++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 55 deletions(-) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index de20a80ea52..fd427941bf1 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -1775,52 +1775,41 @@ def f(): (defvar python-tests-shell-interpreter "python") (ert-deftest python-shell-get-process-name-1 () - "Check process name calculation on different scenarios." + "Check process name calculation sans `buffer-file-name'." (python-tests-with-temp-buffer - "" - (should (string= (python-shell-get-process-name nil) - python-shell-buffer-name)) - ;; When the `current-buffer' doesn't have `buffer-file-name', even - ;; if dedicated flag is non-nil should not include its name. - (should (string= (python-shell-get-process-name t) - python-shell-buffer-name))) + "" + (should (string= (python-shell-get-process-name nil) + python-shell-buffer-name)) + (should (string= (python-shell-get-process-name t) + (format "%s[%s]" python-shell-buffer-name (buffer-name)))))) + +(ert-deftest python-shell-get-process-name-2 () + "Check process name calculation with `buffer-file-name'." (python-tests-with-temp-file - "" - ;; `buffer-file-name' is non-nil but the dedicated flag is nil and - ;; should be respected. - (should (string= (python-shell-get-process-name nil) - python-shell-buffer-name)) - (should (string= - (python-shell-get-process-name t) - (format "%s[%s]" python-shell-buffer-name buffer-file-name))))) + "" + ;; `buffer-file-name' is non-nil but the dedicated flag is nil and + ;; should be respected. + (should (string= (python-shell-get-process-name nil) + python-shell-buffer-name)) + (should (string= + (python-shell-get-process-name t) + (format "%s[%s]" python-shell-buffer-name (buffer-name)))))) (ert-deftest python-shell-internal-get-process-name-1 () - "Check the internal process name is config-unique." - (let* ((python-shell-interpreter python-tests-shell-interpreter) - (python-shell-interpreter-args "") - (python-shell-prompt-regexp ">>> ") - (python-shell-prompt-block-regexp "[.][.][.] ") - (python-shell-setup-codes "") - (python-shell-process-environment "") - (python-shell-extra-pythonpaths "") - (python-shell-exec-path "") - (python-shell-virtualenv-path "") - (expected (python-tests-with-temp-buffer - "" (python-shell-internal-get-process-name)))) - ;; Same configurations should match. - (should - (string= expected - (python-tests-with-temp-buffer - "" (python-shell-internal-get-process-name)))) - (let ((python-shell-interpreter-args "-B")) - ;; A minimal change should generate different names. - (should - (not (string= - expected - (python-tests-with-temp-buffer - "" (python-shell-internal-get-process-name)))))))) - -(ert-deftest python-shell-parse-command-1 () + "Check the internal process name is buffer-unique sans `buffer-file-name'." + (python-tests-with-temp-buffer + "" + (should (string= (python-shell-internal-get-process-name) + (format "%s[%s]" python-shell-internal-buffer-name (buffer-name)))))) + +(ert-deftest python-shell-internal-get-process-name-2 () + "Check the internal process name is buffer-unique with `buffer-file-name'." + (python-tests-with-temp-file + "" + (should (string= (python-shell-internal-get-process-name) + (format "%s[%s]" python-shell-internal-buffer-name (buffer-name)))))) + +(ert-deftest python-shell-calculate-command-1 () "Check the command to execute is calculated correctly. Using `python-shell-interpreter' and `python-shell-interpreter-args'." @@ -1832,7 +1821,7 @@ Using `python-shell-interpreter' and (format "%s %s" python-shell-interpreter python-shell-interpreter-args) - (python-shell-parse-command))))) + (python-shell-calculate-command))))) (ert-deftest python-shell-calculate-process-environment-1 () "Test `python-shell-process-environment' modification." @@ -1857,17 +1846,17 @@ Using `python-shell-interpreter' and path-separator original-pythonpath))))) (ert-deftest python-shell-calculate-process-environment-3 () - "Test `python-shell-virtualenv-path' modification." + "Test `python-shell-virtualenv-root' modification." (let* ((original-path (or (getenv "PATH") "")) - (python-shell-virtualenv-path + (python-shell-virtualenv-root (directory-file-name user-emacs-directory)) (process-environment (python-shell-calculate-process-environment))) (should (not (getenv "PYTHONHOME"))) - (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-path)) + (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root)) (should (equal (getenv "PATH") (format "%s/bin%s%s" - python-shell-virtualenv-path + python-shell-virtualenv-root path-separator original-path))))) (ert-deftest python-shell-calculate-process-environment-4 () @@ -1900,13 +1889,13 @@ Using `python-shell-interpreter' and (ert-deftest python-shell-calculate-exec-path-2 () "Test `python-shell-exec-path' modification." (let* ((original-exec-path exec-path) - (python-shell-virtualenv-path + (python-shell-virtualenv-root (directory-file-name (expand-file-name user-emacs-directory))) (exec-path (python-shell-calculate-exec-path))) (should (equal exec-path (append (cons - (format "%s/bin" python-shell-virtualenv-path) + (format "%s/bin" python-shell-virtualenv-root) original-exec-path)))))) (ert-deftest python-shell-make-comint-1 () @@ -1922,7 +1911,7 @@ Using `python-shell-interpreter' and (shell-buffer (python-tests-with-temp-buffer "" (python-shell-make-comint - (python-shell-parse-command) proc-name))) + (python-shell-calculate-command) proc-name))) (process (get-buffer-process shell-buffer))) (unwind-protect (progn @@ -1943,7 +1932,7 @@ Using `python-shell-interpreter' and (shell-buffer (python-tests-with-temp-buffer "" (python-shell-make-comint - (python-shell-parse-command) proc-name nil t))) + (python-shell-calculate-command) proc-name nil t))) (process (get-buffer-process shell-buffer))) (unwind-protect (progn @@ -2010,7 +1999,7 @@ and `python-shell-interpreter-args' in the new shell buffer." (setenv "PYTHONSTARTUP" startup-file) (python-tests-with-temp-buffer "" (python-shell-make-comint - (python-shell-parse-command) proc-name nil)))) + (python-shell-calculate-command) proc-name nil)))) (process (get-buffer-process shell-buffer))) (unwind-protect (progn @@ -2040,10 +2029,10 @@ and `python-shell-interpreter-args' in the new shell buffer." (dedicated-proc-name (python-shell-get-process-name t)) (global-shell-buffer (python-shell-make-comint - (python-shell-parse-command) global-proc-name)) + (python-shell-calculate-command) global-proc-name)) (dedicated-shell-buffer (python-shell-make-comint - (python-shell-parse-command) dedicated-proc-name)) + (python-shell-calculate-command) dedicated-proc-name)) (global-process (get-buffer-process global-shell-buffer)) (dedicated-process (get-buffer-process dedicated-shell-buffer))) (unwind-protect @@ -3767,7 +3756,7 @@ def foo(a, b, c): . "from IPython.core.completerlib import module_completion") (python-shell-completion-string-code . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") - (python-shell-virtualenv-path + (python-shell-virtualenv-root . "/home/user/.virtualenvs/project")))) (with-current-buffer buffer (kill-all-local-variables) -- cgit v1.2.1 From 2dd5163d764f395eb31a2306dba385d123af4aba Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 27 Dec 2014 01:30:21 -0300 Subject: python.el: Handle file encoding for shell. * lisp/progmodes/python.el (python-rx-constituents): Add coding-cookie. (python-shell--save-temp-file): Write file with proper encoding. (python-shell-buffer-substring): Add coding cookie for detected encoding to generated content. Fix blank lines when removing if-name-main block. (python-shell-send-file): Handle file encoding. (python-info-encoding-from-cookie) (python-info-encoding): New functions. * test/automated/python-tests.el (python-shell-buffer-substring-1) (python-shell-buffer-substring-2, python-shell-buffer-substring-3) (python-shell-buffer-substring-4, python-shell-buffer-substring-5) (python-shell-buffer-substring-6, python-shell-buffer-substring-7) (python-shell-buffer-substring-8) (python-info-encoding-from-cookie-1) (python-info-encoding-from-cookie-2) (python-info-encoding-from-cookie-3) (python-info-encoding-from-cookie-4) (python-info-encoding-from-cookie-5) (python-info-encoding-from-cookie-6) (python-info-encoding-from-cookie-7, python-info-encoding-1) (python-info-encoding-2): New tests. --- test/automated/python-tests.el | 271 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index d1713ac1851..8fcda58e1e0 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2459,6 +2459,198 @@ and `python-shell-interpreter-args' in the new shell buffer." "^\\(o\\.t \\|\\)"))) (ignore-errors (delete-file startup-file))))) +(ert-deftest python-shell-buffer-substring-1 () + "Selecting a substring of the whole buffer must match its contents." + (python-tests-with-temp-buffer + " +class Foo(models.Model): + pass + + +class Bar(models.Model): + pass +" + (should (string= (buffer-string) + (python-shell-buffer-substring (point-min) (point-max)))))) + +(ert-deftest python-shell-buffer-substring-2 () + "Main block should be removed if NOMAIN is non-nil." + (python-tests-with-temp-buffer + " +class Foo(models.Model): + pass + +class Bar(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) +" + (should (string= (python-shell-buffer-substring (point-min) (point-max) t) + " +class Foo(models.Model): + pass + +class Bar(models.Model): + pass + + + + +")))) + +(ert-deftest python-shell-buffer-substring-3 () + "Main block should be removed if NOMAIN is non-nil." + (python-tests-with-temp-buffer + " +class Foo(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring (point-min) (point-max) t) + " +class Foo(models.Model): + pass + + + + + +class Bar(models.Model): + pass +")))) + +(ert-deftest python-shell-buffer-substring-4 () + "Coding cookie should be added for substrings." + (python-tests-with-temp-buffer + "# coding: latin-1 + +class Foo(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring + (python-tests-look-at "class Foo(models.Model):") + (progn (python-nav-forward-sexp) (point))) + "# -*- coding: latin-1 -*- + +class Foo(models.Model): + pass")))) + +(ert-deftest python-shell-buffer-substring-5 () + "The proper amount of blank lines is added for a substring." + (python-tests-with-temp-buffer + "# coding: latin-1 + +class Foo(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring + (python-tests-look-at "class Bar(models.Model):") + (progn (python-nav-forward-sexp) (point))) + "# -*- coding: latin-1 -*- + + + + + + + + +class Bar(models.Model): + pass")))) + +(ert-deftest python-shell-buffer-substring-6 () + "Handle substring with coding cookie in the second line." + (python-tests-with-temp-buffer + " +# coding: latin-1 + +class Foo(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring + (python-tests-look-at "# coding: latin-1") + (python-tests-look-at "if __name__ == \"__main__\":")) + "# -*- coding: latin-1 -*- + + +class Foo(models.Model): + pass + +")))) + +(ert-deftest python-shell-buffer-substring-7 () + "Ensure first coding cookie gets precedence." + (python-tests-with-temp-buffer + "# coding: utf-8 +# coding: latin-1 + +class Foo(models.Model): + pass + +if __name__ == \"__main__\": + foo = Foo() + print (foo) + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring + (python-tests-look-at "# coding: latin-1") + (python-tests-look-at "if __name__ == \"__main__\":")) + "# -*- coding: utf-8 -*- + + +class Foo(models.Model): + pass + +")))) + +(ert-deftest python-shell-buffer-substring-8 () + "Ensure first coding cookie gets precedence when sending whole buffer." + (python-tests-with-temp-buffer + "# coding: utf-8 +# coding: latin-1 + +class Foo(models.Model): + pass +" + (should (string= (python-shell-buffer-substring (point-min) (point-max)) + "# coding: utf-8 + + +class Foo(models.Model): + pass +")))) + ;;; Shell completion @@ -3773,6 +3965,85 @@ foo = True # another comment (forward-line 1) (should (python-info-current-line-empty-p)))) +(ert-deftest python-info-encoding-from-cookie-1 () + "Should detect it on first line." + (python-tests-with-temp-buffer + "# coding=latin-1 + +foo = True # another comment +" + (should (eq (python-info-encoding-from-cookie) 'latin-1)))) + +(ert-deftest python-info-encoding-from-cookie-2 () + "Should detect it on second line." + (python-tests-with-temp-buffer + " +# coding=latin-1 + +foo = True # another comment +" + (should (eq (python-info-encoding-from-cookie) 'latin-1)))) + +(ert-deftest python-info-encoding-from-cookie-3 () + "Should not be detected on third line (and following ones)." + (python-tests-with-temp-buffer + " + +# coding=latin-1 +foo = True # another comment +" + (should (not (python-info-encoding-from-cookie))))) + +(ert-deftest python-info-encoding-from-cookie-4 () + "Should detect Emacs style." + (python-tests-with-temp-buffer + "# -*- coding: latin-1 -*- + +foo = True # another comment" + (should (eq (python-info-encoding-from-cookie) 'latin-1)))) + +(ert-deftest python-info-encoding-from-cookie-5 () + "Should detect Vim style." + (python-tests-with-temp-buffer + "# vim: set fileencoding=latin-1 : + +foo = True # another comment" + (should (eq (python-info-encoding-from-cookie) 'latin-1)))) + +(ert-deftest python-info-encoding-from-cookie-6 () + "First cookie wins." + (python-tests-with-temp-buffer + "# -*- coding: iso-8859-1 -*- +# vim: set fileencoding=latin-1 : + +foo = True # another comment" + (should (eq (python-info-encoding-from-cookie) 'iso-8859-1)))) + +(ert-deftest python-info-encoding-from-cookie-7 () + "First cookie wins." + (python-tests-with-temp-buffer + "# vim: set fileencoding=latin-1 : +# -*- coding: iso-8859-1 -*- + +foo = True # another comment" + (should (eq (python-info-encoding-from-cookie) 'latin-1)))) + +(ert-deftest python-info-encoding-1 () + "Should return the detected encoding from cookie." + (python-tests-with-temp-buffer + "# vim: set fileencoding=latin-1 : + +foo = True # another comment" + (should (eq (python-info-encoding) 'latin-1)))) + +(ert-deftest python-info-encoding-2 () + "Should default to utf-8." + (python-tests-with-temp-buffer + "# No encoding for you + +foo = True # another comment" + (should (eq (python-info-encoding) 'utf-8)))) + ;;; Utility functions -- cgit v1.2.1 From 433af0a06089885f5a57ef0f3e7d6283e8d51bd5 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 27 Dec 2014 17:22:29 -0300 Subject: * lisp/progmodes/python.el (python-shell-buffer-substring): Handle cornercase when region sent starts at point-min. --- test/automated/python-tests.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 8fcda58e1e0..a4948571242 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2651,6 +2651,27 @@ class Foo(models.Model): pass ")))) +(ert-deftest python-shell-buffer-substring-9 () + "Check substring starting from `point-min'." + (python-tests-with-temp-buffer + "# coding: utf-8 + +class Foo(models.Model): + pass + +class Bar(models.Model): + pass +" + (should (string= (python-shell-buffer-substring + (point-min) + (python-tests-look-at "class Bar(models.Model):")) + "# coding: utf-8 + +class Foo(models.Model): + pass + +")))) + ;;; Shell completion -- cgit v1.2.1 From 7d1e62d51b51be27b11a67d7828b77f2df9e1eb1 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 27 Dec 2014 20:12:00 -0300 Subject: python.el: Enhance shell user interaction and deprecate python-shell-get-or-create-process. * lisp/progmodes/python.el (python-shell-get-process-or-error): New function. (python-shell-with-shell-buffer): Use it. (python-shell-send-string, python-shell-send-region) (python-shell-send-buffer, python-shell-send-defun) (python-shell-send-file, python-shell-switch-to-shell): Use it. Add argument MSG to display user-friendly message when no process is running. (python-shell-switch-to-shell): Call pop-to-buffer with NORECORD. (python-shell-make-comint): Rename argument SHOW from POP. Use display-buffer instead of pop-to-buffer. (run-python): Doc fix. Return process. (python-shell-get-or-create-process): Make obsolete. * test/automated/python-tests.el (python-shell-get-or-create-process-1) (python-shell-get-or-create-process-2) (python-shell-get-or-create-process-3): Remove tests. --- test/automated/python-tests.el | 78 ------------------------------------------ 1 file changed, 78 deletions(-) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index a6ed6808182..90fa79ee966 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2083,84 +2083,6 @@ and `python-shell-interpreter-args' in the new shell buffer." (ignore-errors (kill-buffer global-shell-buffer)) (ignore-errors (kill-buffer dedicated-shell-buffer)))))) -(ert-deftest python-shell-get-or-create-process-1 () - "Check shell dedicated process creation." - (skip-unless (executable-find python-tests-shell-interpreter)) - (python-tests-with-temp-file - "" - (let* ((cmd - (concat (executable-find python-tests-shell-interpreter) " -i")) - (use-dialog-box) - (dedicated-process-name (python-shell-get-process-name t)) - (dedicated-process (python-shell-get-or-create-process cmd t)) - (dedicated-shell-buffer (process-buffer dedicated-process))) - (unwind-protect - (progn - (set-process-query-on-exit-flag dedicated-process nil) - ;; should be dedicated. - (should (equal (process-name dedicated-process) - dedicated-process-name)) - (kill-buffer dedicated-shell-buffer) - ;; Check there are no processes for current buffer. - (should (not (python-shell-get-process)))) - (ignore-errors (kill-buffer dedicated-shell-buffer)))))) - -(ert-deftest python-shell-get-or-create-process-2 () - "Check shell global process creation." - (skip-unless (executable-find python-tests-shell-interpreter)) - (python-tests-with-temp-file - "" - (let* ((cmd - (concat (executable-find python-tests-shell-interpreter) " -i")) - (use-dialog-box) - (process-name (python-shell-get-process-name nil)) - (process (python-shell-get-or-create-process cmd)) - (shell-buffer (process-buffer process))) - (unwind-protect - (progn - (set-process-query-on-exit-flag process nil) - ;; should be global. - (should (equal (process-name process) process-name)) - (kill-buffer shell-buffer) - ;; Check there are no processes for current buffer. - (should (not (python-shell-get-process)))) - (ignore-errors (kill-buffer shell-buffer)))))) - -(ert-deftest python-shell-get-or-create-process-3 () - "Check shell dedicated/global process preference." - (skip-unless (executable-find python-tests-shell-interpreter)) - (python-tests-with-temp-file - "" - (let* ((cmd - (concat (executable-find python-tests-shell-interpreter) " -i")) - (python-shell-interpreter python-tests-shell-interpreter) - (use-dialog-box) - (dedicated-process-name (python-shell-get-process-name t)) - (global-process) - (dedicated-process)) - (progn - ;; Create global process - (run-python cmd nil) - (setq global-process (get-buffer-process "*Python*")) - (should global-process) - (set-process-query-on-exit-flag global-process nil) - ;; Create dedicated process - (run-python cmd t) - (setq dedicated-process (get-process dedicated-process-name)) - (should dedicated-process) - (set-process-query-on-exit-flag dedicated-process nil) - ;; Prefer dedicated. - (should (equal (python-shell-get-or-create-process) - dedicated-process)) - ;; Kill the dedicated so the global takes over. - (kill-buffer (process-buffer dedicated-process)) - ;; Detect global. - (should (equal (python-shell-get-or-create-process) global-process)) - ;; Kill the global. - (kill-buffer (process-buffer global-process)) - ;; Check there are no processes for current buffer. - (should (not (python-shell-get-process))))))) - (ert-deftest python-shell-internal-get-or-create-process-1 () "Check internal shell process creation fallback." (skip-unless (executable-find python-tests-shell-interpreter)) -- cgit v1.2.1 From 2cb7592275bce47e44916134223b994a75e4b861 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 27 Dec 2014 20:58:45 -0300 Subject: python.el: Native readline completion. This commit adds native readline completion that fallbacks to the old mechanism when it cannot be used for the current interpreter. * lisp/progmodes/python.el (python-shell-completion-native-disabled-interpreters) (python-shell-completion-native-enable) (python-shell-completion-native-output-timeout): New defcustoms. (python-shell-completion-native-interpreter-disabled-p) (python-shell-completion-native-try) (python-shell-completion-native-setup) (python-shell-completion-native-turn-off) (python-shell-completion-native-turn-on) (python-shell-completion-native-turn-on-maybe) (python-shell-completion-native-turn-on-maybe-with-msg) (python-shell-completion-native-toggle): New functions. (python-shell-completion-native-get-completions): New function. (python-shell-completion-at-point): Use it. * test/automated/python-tests.el (python-shell-completion-native-interpreter-disabled-p-1): New test. --- test/automated/python-tests.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/automated/python-tests.el') diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 90fa79ee966..ca43c45ac5e 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2584,6 +2584,13 @@ class Foo(models.Model): ;;; Shell completion +(ert-deftest python-shell-completion-native-interpreter-disabled-p-1 () + (let* ((python-shell-completion-native-disabled-interpreters (list "pypy")) + (python-shell-interpreter "/some/path/to/bin/pypy")) + (should (python-shell-completion-native-interpreter-disabled-p)))) + + + ;;; PDB Track integration -- cgit v1.2.1