New completion bug

Bug #1034656 reported by Richard Stanton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

Using r1056 under Windows, if I try to complete the string "ex" in a script window, an *IPython Completion* buffer opens with the correct completions listed, but I also get the following error:

Debugger entered--Lisp error: (void-function word-at-point)
  (word-at-point)
  (progn (forward-word -1) (delete-other-windows) (word-at-point))
  (if (search-forward (car (all-completions pattern completions))) (progn (forward-word -1) (delete-other-windows) (word-at-point)))
  (when (search-forward (car (all-completions pattern completions))) (forward-word -1) (delete-other-windows) (word-at-point))
  (cond ((eq completion t) (if (eq this-command last-command) (when python-completion-original-window-configuration (set-window-configuration python-completion-original-window-configuration))) (setq python-completion-original-window-configuration nil) (message "Can't find completion for \"%s\"" pattern) (ding) nil) ((not (string= pattern completion)) (progn (delete-char (- (length pattern))) (insert completion) nil)) ((< 1 (length completions)) (unless python-completion-original-window-configuration (setq python-completion-original-window-configuration (current-window-configuration))) (with-output-to-temp-buffer "*IPython Completions*" (display-completion-list (all-completions pattern completions))) (set-buffer "*IPython Completions*") (switch-to-buffer "*IPython Completions*") (goto-char (point-min)) (when (search-forward (car (all-completions pattern completions))) (forward-word -1) (delete-other-windows) (word-at-point))) ((null completion) (message "Can't find completion for \"%s\"" pattern) (ding)))
  (let* ((beg (or beg (progn (save-excursion (skip-chars-backward "a-z0-9A-Z_." (point-at-bol)) (point))))) (end (or end (point))) (pattern (or word (buffer-substring-no-properties beg end))) (sep ";") (shell (py-choose-shell)) (pyshellname (if (string-match "ipython" shell) shell "ipython")) (processlist (process-list)) done (process (if ipython-complete-use-separate-shell-p (unless (and (buffer-live-p "*IPython-Complete*") (comint-check-proc (process-name ...))) (get-buffer-process (py-shell nil nil pyshellname (quote noswitch) nil "*IPython-Complete*"))) (progn (while (and processlist (not done)) (when (and ... ... ...)) (setq processlist (cdr processlist))) done))) (python-process (or process (get-buffer-process (py-shell nil nil (if (string-match "[iI][pP]ython[^[:alpha:]]*$" pyshellname) pyshellname "ipython") (quote noswitch) nil)))) (comint-output-filter-functions (delq (quote py-comint-output-filter-function) comint-output-filter-functions)) (comint-output-filter-functions (append comint-output-filter-functions (quote (ansi-color-filter-apply (lambda (string) (setq ugly-return ...) (delete-region comint-last-output-start ...)))))) (ccs (or completion-command-string (py-set-ipython-completion-command-string (process-name python-process)))) completion completions completion-table ugly-return) (if (string= pattern "") (tab-to-tab-stop) (process-send-string python-process (format ccs pattern)) (accept-process-output python-process 0.1) (setq completions (split-string (substring ugly-return 0 (position 10 ugly-return)) sep)) (setq completion (when completions (try-completion pattern completions)))) (cond ((eq completion t) (if (eq this-command last-command) (when python-completion-original-window-configuration (set-window-configuration python-completion-original-window-configuration))) (setq python-completion-original-window-configuration nil) (message "Can't find completion for \"%s\"" pattern) (ding) nil) ((not (string= pattern completion)) (progn (delete-char (- (length pattern))) (insert completion) nil)) ((< 1 (length completions)) (unless python-completion-original-window-configuration (setq python-completion-original-window-configuration (current-window-configuration))) (with-output-to-temp-buffer "*IPython Completions*" (display-completion-list (all-completions pattern completions))) (set-buffer "*IPython Completions*") (switch-to-buffer "*IPython Completions*") (goto-char (point-min)) (when (search-forward (car (all-completions pattern completions))) (forward-word -1) (delete-other-windows) (word-at-point))) ((null completion) (message "Can't find completion for \"%s\"" pattern) (ding))))
  ipython-complete(nil nil 21 23 "ex")
  (cond ((string= word "") (tab-to-tab-stop)) ((string-match "[iI][pP]ython" shell) (ipython-complete nil nil beg end word)) ((string-match "[pP]ython3[^[:alpha:]]*$" shell) (python-shell-completion--do-completion-at-point proc (buffer-substring-no-properties beg end) word)) (imports (py-python-script-complete shell imports beg end word)) (t (py-shell-complete-intern word beg end shell imports proc)))
  (let* ((shell (or shell (py-choose-shell))) py-split-windows-on-execute-p py-switch-buffers-on-execute-p (proc (or (get-process shell) (get-buffer-process (py-shell nil nil shell (quote noswitch) nil)))) (beg (save-excursion (skip-chars-backward "a-zA-Z0-9_.") (point))) (end (point)) (word (buffer-substring-no-properties beg end)) (imports (py-find-imports))) (cond ((string= word "") (tab-to-tab-stop)) ((string-match "[iI][pP]ython" shell) (ipython-complete nil nil beg end word)) ((string-match "[pP]ython3[^[:alpha:]]*$" shell) (python-shell-completion--do-completion-at-point proc (buffer-substring-no-properties beg end) word)) (imports (py-python-script-complete shell imports beg end word)) (t (py-shell-complete-intern word beg end shell imports proc))))
  (if (or (eq major-mode (quote comint-mode)) (eq major-mode (quote inferior-python-mode))) (let (py-fontify-shell-buffer-p (shell (or shell (py-report-executable (buffer-name (current-buffer))))) (imports (py-find-imports))) (if (string-match "[iI][pP]ython" shell) (ipython-complete) (let* ((orig (point)) (beg (save-excursion (skip-chars-backward "a-zA-Z0-9_.") (point))) (end (point)) (word (buffer-substring-no-properties beg end)) (proc (get-buffer-process (current-buffer)))) (cond ((string= word "") (tab-to-tab-stop)) ((string-match "[pP]ython3[^[:alpha:]]*$" shell) (python-shell-completion--do-completion-at-point proc imports word)) (t (py-shell-complete-intern word beg end shell imports proc)))))) (let* ((shell (or shell (py-choose-shell))) py-split-windows-on-execute-p py-switch-buffers-on-execute-p (proc (or (get-process shell) (get-buffer-process (py-shell nil nil shell (quote noswitch) nil)))) (beg (save-excursion (skip-chars-backward "a-zA-Z0-9_.") (point))) (end (point)) (word (buffer-substring-no-properties beg end)) (imports (py-find-imports))) (cond ((string= word "") (tab-to-tab-stop)) ((string-match "[iI][pP]ython" shell) (ipython-complete nil nil beg end word)) ((string-match "[pP]ython3[^[:alpha:]]*$" shell) (python-shell-completion--do-completion-at-point proc (buffer-substring-no-properties beg end) word)) (imports (py-python-script-complete shell imports beg end word)) (t (py-shell-complete-intern word beg end shell imports proc)))))
  py-shell-complete()
  completion--capf-wrapper(py-shell-complete all)
  run-hook-wrapped(completion--capf-wrapper py-shell-complete all)
  completion-at-point()
  complete-symbol(nil)
  call-interactively(complete-symbol nil nil)

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Richard,

thanks for the report.

Inserting a (require 'thingatpt) should do it.
Will check in a resp. fix

Andreas

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.0
importance: Undecided → Medium
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
Revision history for this message
Richard Stanton (a-stanton) wrote :
Download full text (6.7 KiB)

With r1057, I get no completion buffer and a different error message:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  insert(nil)
  (progn (delete-char (- (length pattern))) (insert completion) nil)
  (cond ((eq completion t) (if (eq this-command last-command) (when python-completion-original-window-configuration (set-window-configuration python-completion-original-window-configuration))) (setq python-completion-original-window-configuration nil) (message "Can't find completion for \"%s\"" pattern) (ding) nil) ((not (string= pattern completion)) (progn (delete-char (- (length pattern))) (insert completion) nil)) ((< 1 (length completions)) (unless python-completion-original-window-configuration (setq python-completion-original-window-configuration (current-window-configuration))) (with-output-to-temp-buffer "*IPython Completions*" (display-completion-list (all-completions pattern completions))) (set-buffer "*IPython Completions*") (switch-to-buffer "*IPython Completions*") (goto-char (point-min)) (when (search-forward (car (all-completions pattern completions))) (forward-word -1) (delete-other-windows) (word-at-point))) ((null completion) (message "Can't find completion for \"%s\"" pattern) (ding)))
  (let* ((beg (or beg (progn (save-excursion (skip-chars-backward "a-z0-9A-Z_." (point-at-bol)) (point))))) (end (or end (point))) (pattern (or word (buffer-substring-no-properties beg end))) (sep ";") (shell (py-choose-shell)) (pyshellname (if (string-match "ipython" shell) shell "ipython")) (processlist (process-list)) done (process (if ipython-complete-use-separate-shell-p (unless (and (buffer-live-p "*IPython-Complete*") (comint-check-proc (process-name ...))) (get-buffer-process (py-shell nil nil pyshellname (quote noswitch) nil "*IPython-Complete*"))) (progn (while (and processlist (not done)) (when (and ... ... ...)) (setq processlist (cdr processlist))) done))) (python-process (or process (get-buffer-process (py-shell nil nil (if (string-match "[iI][pP]ython[^[:alpha:]]*$" pyshellname) pyshellname "ipython") (quote noswitch) nil)))) (comint-output-filter-functions (delq (quote py-comint-output-filter-function) comint-output-filter-functions)) (comint-output-filter-functions (append comint-output-filter-functions (quote (ansi-color-filter-apply (lambda (string) (setq ugly-return ...) (delete-region comint-last-output-start ...)))))) (ccs (or completion-command-string (py-set-ipython-completion-command-string (process-name python-process)))) completion completions completion-table ugly-return) (if (string= pattern "") (tab-to-tab-stop) (process-send-string python-process (format ccs pattern)) (accept-process-output python-process 0.1) (setq completions (split-string (substring ugly-return 0 (position 10 ugly-return)) sep)) (setq completion (when completions (try-completion pattern completions)))) (cond ((eq completion t) (if (eq this-command last-command) (when python-completion-original-window-configuration (set-window-configuration python-completion-original-window-configuration))) (setq python-completion-original-window-configuration nil) (message "Can't find completion for \"%s\"" pattern) (ding) nil) ((not (s...

Read more...

Changed in python-mode:
status: Fix Committed → New
Revision history for this message
Richard Stanton (a-stanton) wrote :

Further checking - it works OK if I run the script file first using C-c C-c.

Changed in python-mode:
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.