diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:02:57 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:02:57 -0300 |
| commit | 3d6913c7d1737ffbe4163cf0f8a19c4d09f2dbc7 (patch) | |
| tree | 41379d5d1d2b0414cb2d1032b0de149c536bcc04 | |
| parent | 13d914ed50eeef89288f143dc2b7a084dbfd9079 (diff) | |
| download | emacs-3d6913c7d1737ffbe4163cf0f8a19c4d09f2dbc7.tar.gz emacs-3d6913c7d1737ffbe4163cf0f8a19c4d09f2dbc7.zip | |
Fixes to shell completion at point
| -rw-r--r-- | lisp/progmodes/python.el | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 737730d7823..b9cbfdd3b4d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1141,46 +1141,47 @@ It is specially designed to be added to the | |||
| 1141 | (defun python-shell-completion-complete-at-point () | 1141 | (defun python-shell-completion-complete-at-point () |
| 1142 | "Perform completion at point in inferior Python process." | 1142 | "Perform completion at point in inferior Python process." |
| 1143 | (interactive) | 1143 | (interactive) |
| 1144 | (when (and comint-last-prompt-overlay | 1144 | (with-syntax-table python-dotty-syntax-table |
| 1145 | (> (point-marker) (overlay-end comint-last-prompt-overlay))) | 1145 | (when (and comint-last-prompt-overlay |
| 1146 | (let* ((process (get-buffer-process (current-buffer))) | 1146 | (> (point-marker) (overlay-end comint-last-prompt-overlay))) |
| 1147 | (input (comint-word (current-word))) | 1147 | (let* ((process (get-buffer-process (current-buffer))) |
| 1148 | (completions (when input | 1148 | (input (comint-word (current-word))) |
| 1149 | (delete-region (point-marker) | 1149 | (completions (when input |
| 1150 | (progn | 1150 | (delete-region (point-marker) |
| 1151 | (forward-char (- (length input))) | 1151 | (progn |
| 1152 | (point-marker))) | 1152 | (forward-char (- (length input))) |
| 1153 | (process-send-string | 1153 | (point-marker))) |
| 1154 | process | 1154 | (message (format python-shell-completion-strings-code input)) |
| 1155 | (format | 1155 | (python-shell-send-string |
| 1156 | python-shell-completion-strings-code input)) | 1156 | (format python-shell-completion-strings-code input) |
| 1157 | (accept-process-output process) | 1157 | process) |
| 1158 | (save-excursion | ||
| 1159 | (re-search-backward comint-prompt-regexp | ||
| 1160 | comint-last-input-end t) | ||
| 1161 | (split-string | 1158 | (split-string |
| 1162 | (buffer-substring-no-properties | 1159 | (save-excursion |
| 1163 | (point-marker) comint-last-input-end) | 1160 | (if (not comint-last-output-start) |
| 1164 | ";\\|\"\\|'\\|(" t)))) | 1161 | "" |
| 1165 | (completion (when completions (try-completion input completions)))) | 1162 | (goto-char comint-last-output-start) |
| 1166 | (when completions | 1163 | (buffer-substring-no-properties |
| 1167 | (save-excursion | 1164 | (point-marker) (line-end-position)))) |
| 1168 | (forward-line -1) | 1165 | ";\\|\"\\|'\\|(" t))) |
| 1169 | (kill-line 1))) | 1166 | (completion (when completions (try-completion input completions)))) |
| 1170 | (cond ((eq completion t) | 1167 | (when completions |
| 1171 | (when input (insert input))) | 1168 | (save-excursion |
| 1172 | ((null completion) | 1169 | (forward-line -1) |
| 1173 | (when input (insert input)) | 1170 | (kill-line 1))) |
| 1174 | (message "Can't find completion for \"%s\"" input) | 1171 | (cond ((eq completion t) |
| 1175 | (ding)) | 1172 | (when input (insert input))) |
| 1176 | ((not (string= input completion)) | 1173 | ((null completion) |
| 1177 | (insert completion)) | 1174 | (when input (insert input)) |
| 1178 | (t | 1175 | (message "Can't find completion for \"%s\"" input) |
| 1179 | (message "Making completion list...") | 1176 | (ding)) |
| 1180 | (when input (insert input)) | 1177 | ((not (string= input completion)) |
| 1181 | (with-output-to-temp-buffer "*Python Completions*" | 1178 | (insert completion)) |
| 1182 | (display-completion-list | 1179 | (t |
| 1183 | (all-completions input completions)))))))) | 1180 | (message "Making completion list...") |
| 1181 | (when input (insert input)) | ||
| 1182 | (with-output-to-temp-buffer "*Python Completions*" | ||
| 1183 | (display-completion-list | ||
| 1184 | (all-completions input completions))))))))) | ||
| 1184 | 1185 | ||
| 1185 | (defun python-shell-completion-complete-or-indent () | 1186 | (defun python-shell-completion-complete-or-indent () |
| 1186 | "Complete or indent depending on the context. | 1187 | "Complete or indent depending on the context. |