##// END OF EJS Templates
Switches to use a better completion API and send the whole line....
Pete Aykroyd -
Show More
@@ -314,7 +314,7 b' gets converted to:'
314 (replace-match "" t nil)))))
314 (replace-match "" t nil)))))
315
315
316 (defvar ipython-completion-command-string
316 (defvar ipython-completion-command-string
317 "print(';'.join(get_ipython().Completer.all_completions('%s'))) #PYTHON-MODE SILENT\n"
317 "print(';'.join(get_ipython().complete('%s', '%s')[1])) #PYTHON-MODE SILENT\n"
318 "The string send to ipython to query for all possible completions")
318 "The string send to ipython to query for all possible completions")
319
319
320
320
@@ -390,6 +390,7 b' in the current *Python* session."'
390 (beg (save-excursion (skip-chars-backward "a-z0-9A-Z_./" (point-at-bol))
390 (beg (save-excursion (skip-chars-backward "a-z0-9A-Z_./" (point-at-bol))
391 (point)))
391 (point)))
392 (end (point))
392 (end (point))
393 (line (buffer-substring-no-properties (point-at-bol) end))
393 (pattern (buffer-substring-no-properties beg end))
394 (pattern (buffer-substring-no-properties beg end))
394 (completions nil)
395 (completions nil)
395 (completion-table nil)
396 (completion-table nil)
@@ -401,7 +402,7 b' in the current *Python* session."'
401 (setq ugly-return (concat ugly-return string))
402 (setq ugly-return (concat ugly-return string))
402 "")))))
403 "")))))
403 (process-send-string python-process
404 (process-send-string python-process
404 (format ipython-completion-command-string pattern))
405 (format ipython-completion-command-string pattern line))
405 (accept-process-output python-process)
406 (accept-process-output python-process)
406 (setq completions
407 (setq completions
407 (split-string (substring ugly-return 0 (position ?\n ugly-return)) sep))
408 (split-string (substring ugly-return 0 (position ?\n ugly-return)) sep))
@@ -411,10 +412,10 b' in the current *Python* session."'
411 (setq completion (try-completion pattern completion-table))
412 (setq completion (try-completion pattern completion-table))
412 (cond ((eq completion t))
413 (cond ((eq completion t))
413 ((null completion)
414 ((null completion)
414 (message "Can't find completion for \"%s\"" pattern)
415 (message "Can't find completion for \"%s\" based on line %s" pattern line)
415 (ding))
416 (ding))
416 ((not (string= pattern completion))
417 ((not (string= pattern completion))
417 (delete-region beg end)
418 (delete-region (- end (length pattern)) end)
418 (insert completion))
419 (insert completion))
419 (t
420 (t
420 (message "Making completion list...")
421 (message "Making completion list...")
General Comments 0
You need to be logged in to leave comments. Login now