diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:32 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:32 -0300 |
| commit | 338a21d0d138a008c985a82d650f8b4a1b5b35d3 (patch) | |
| tree | ab06c60bf27cee1bff0bb0135fc5d42821bc6f92 /lisp/progmodes/python.el | |
| parent | aa4099353c10e0af0bbc11ca56a8be6243b3c882 (diff) | |
| download | emacs-338a21d0d138a008c985a82d650f8b4a1b5b35d3.tar.gz emacs-338a21d0d138a008c985a82d650f8b4a1b5b35d3.zip | |
Improvements on completion code.
Do no complete when defining a code block (we can't do this until
finding some way of getting raw tabs to the interpreter correctly)
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b4d388eb41d..5842dc021c6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1635,20 +1635,27 @@ completions on the current context." | |||
| 1635 | (buffer-substring (point-at-bol) (point)) nil nil)) | 1635 | (buffer-substring (point-at-bol) (point)) nil nil)) |
| 1636 | (input (substring-no-properties | 1636 | (input (substring-no-properties |
| 1637 | (or (comint-word (current-word)) "") nil nil)) | 1637 | (or (comint-word (current-word)) "") nil nil)) |
| 1638 | (prompt (buffer-substring-no-properties | ||
| 1639 | (overlay-start comint-last-prompt-overlay) | ||
| 1640 | (overlay-end comint-last-prompt-overlay))) | ||
| 1638 | (completion-code | 1641 | (completion-code |
| 1639 | (cond ((and (> (length python-shell-completion-pdb-string-code) 0) | 1642 | (cond ((and (> (length python-shell-completion-pdb-string-code) 0) |
| 1640 | (string-match python-shell-prompt-pdb-regexp | 1643 | (string-match |
| 1641 | (buffer-substring-no-properties | 1644 | (concat "^" python-shell-prompt-pdb-regexp) prompt)) |
| 1642 | (overlay-start comint-last-prompt-overlay) | ||
| 1643 | (overlay-end comint-last-prompt-overlay)))) | ||
| 1644 | python-shell-completion-pdb-string-code) | 1645 | python-shell-completion-pdb-string-code) |
| 1645 | ((and (> (length python-shell-completion-module-string-code) 0) | 1646 | ((and (> (length python-shell-completion-module-string-code) 0) |
| 1646 | (string-match "^\\(from\\|import\\)[ \t]" line)) | 1647 | (string-match |
| 1648 | (concat "^" python-shell-prompt-regexp) prompt) | ||
| 1649 | (string-match "^\\(from\\|import\\)[ \t]" line)) | ||
| 1647 | python-shell-completion-module-string-code) | 1650 | python-shell-completion-module-string-code) |
| 1648 | (t python-shell-completion-string-code))) | 1651 | ((string-match |
| 1652 | (concat "^" python-shell-prompt-regexp) prompt) | ||
| 1653 | python-shell-completion-string-code) | ||
| 1654 | (t nil))) | ||
| 1649 | (completions | 1655 | (completions |
| 1650 | (and (> (length input) 0) | 1656 | (and completion-code (> (length input) 0) |
| 1651 | (python-shell-completion--get-completions line process completion-code))) | 1657 | (python-shell-completion--get-completions |
| 1658 | line process completion-code))) | ||
| 1652 | (completion (when completions | 1659 | (completion (when completions |
| 1653 | (try-completion input completions)))) | 1660 | (try-completion input completions)))) |
| 1654 | (cond ((eq completion t) | 1661 | (cond ((eq completion t) |
| @@ -1661,19 +1668,19 @@ completions on the current context." | |||
| 1661 | ((null completion) | 1668 | ((null completion) |
| 1662 | (message "Can't find completion for \"%s\"" input) | 1669 | (message "Can't find completion for \"%s\"" input) |
| 1663 | (ding) | 1670 | (ding) |
| 1664 | nil) | 1671 | nil) |
| 1665 | ((not (string= input completion)) | 1672 | ((not (string= input completion)) |
| 1666 | (progn (delete-char (- (length input))) | 1673 | (progn (delete-char (- (length input))) |
| 1667 | (insert completion) | 1674 | (insert completion) |
| 1668 | t)) | 1675 | t)) |
| 1669 | (t | 1676 | (t |
| 1670 | (unless python-shell-completion-original-window-configuration | 1677 | (unless python-shell-completion-original-window-configuration |
| 1671 | (setq python-shell-completion-original-window-configuration | 1678 | (setq python-shell-completion-original-window-configuration |
| 1672 | (current-window-configuration))) | 1679 | (current-window-configuration))) |
| 1673 | (with-output-to-temp-buffer "*Python Completions*" | 1680 | (with-output-to-temp-buffer "*Python Completions*" |
| 1674 | (display-completion-list | 1681 | (display-completion-list |
| 1675 | (all-completions input completions))) | 1682 | (all-completions input completions))) |
| 1676 | t))))) | 1683 | t))))) |
| 1677 | 1684 | ||
| 1678 | (defun python-shell-completion-complete-at-point () | 1685 | (defun python-shell-completion-complete-at-point () |
| 1679 | "Perform completion at point in inferior Python process." | 1686 | "Perform completion at point in inferior Python process." |