* Configuring Anaconda-Mode and Company-Mode with IPython
@ 2015-04-15 13:42 daniel.galtieri
2015-04-17 1:36 ` Dmitry Gutov
[not found] ` <mailman.851.1429234616.904.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: daniel.galtieri @ 2015-04-15 13:42 UTC (permalink / raw)
To: help-gnu-emacs
I am new to using Emacs, and am currently trying to configure it to be a more robust environment for coding in Python.
To do this I'm using Company-Mode with Anaconda-Mode for autocompletion, along with the defaul Python.el mode
I would like to use IPython as my repl, but I'm experiencing some odd behavior with autocompletion in the IPython buffer (autocompletion works fine in the normal python buffer(s)).
Basically what happens is as follows:
If I start typing something, such as "import sys" the appropriate hints for import and sys pop up (so that's working fine).
When I go to use sys, though, if I symply type "sy" and then hit tab/enter to complete sys and then go to use one of the methods in sys (e.g. sys.path), again the appropriate hints are shown (so again, working fine)
However, if instead I type out sys and try to then continue by typing sys.p, no hints are shown. I can force company to complete manually with M-x company-complete, but obviously this is not the desired behavior.
I think this may have something to do with Anaconda-mode and IPython. Looking at my Python buffers, Anaconda-mode is listed as one of the minor modes, but it is not listed in my IPython buffer. Disabling Anaconda-mode in my Python buffers also produces the behavior described above. If I manually start Anaconda-mode in the IPython buffer (Inferior Python), the tooltips now activate properly but the contents are incorrect (i.e. the class methods shown to be available are not correct).
Also, I'm using company-quickhelp for docstring tooltips. In none of the above scenarios do the docstring tooltips popup.
I'm assuming there is an issue with how I have IPython / Anacanda-mode (and associated company-anaconda backed) / company-mode, but I'm not sure how to resolve it.
Also, I'm not sure if it's related to this or not, but looking at the *Messages* buffer, whenever I go to type in the IPython buffer I see the following message popping up:
Invalid face reference: nil [nnn times]
where the value for nnn increases every time I type in the IPython buffer
I have my configuration split up into different files:
init.el:
;;; add path to settings files
(add-to-list 'load-path "~/.emacs.d/settings")
;;; setup package management
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
;;; configure general settings
(require 'general-settings)
;;; configure general settings for all coding buffers
(require 'general-code-settings)
;;;
(require 'python-settings)
;;; init.el ends here
python-settings.el:
;;enable anaconda-mode and eldoc-mode in all python buffers
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'eldoc-mode)
;;use IPython
(setq python-shell-interpreter "ipython")
(provide 'python-settings)
;;; python-settings.el ends here
general-code-settings.el:
;;enable company mode globally and add company-anaconda backend
(add-hook 'after-init-hook 'global-company-mode)
;;(add-hook 'prog-mode-hook 'company-mode)
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-anaconda))
;;makes completion start automatically rather than waiting for 3 chars / 0.5sec
(setq company-minimum-prefix-length 1)
(setq company-idle-delay 0)
;;company quickhelp gives docstring info
(company-quickhelp-mode 1)
;;enable flycheck
(add-hook 'after-init-hook #'global-flycheck-mode)
;;enable fill-column-indicator for 80char line indication
(require 'fill-column-indicator)
(add-hook 'prog-mode-hook 'fci-mode)
(setq fci-rule-column 80)
;;workaround for bug between company mode and fill-column-indicator
(defvar-local company-fci-mode-on-p nil)
(defun company-turn-off-fci (&rest ignore)
(when (boundp 'fci-mode)
(setq company-fci-mode-on-p fci-mode)
(when fci-mode (fci-mode -1))))
(defun company-maybe-turn-on-fci (&rest ignore)
(when company-fci-mode-on-p (fci-mode 1)))
(add-hook 'company-completion-started-hook 'company-turn-off-fci)
(add-hook 'company-completion-finished-hook 'company-maybe-turn-on-fci)
(add-hook 'company-completion-cancelled-hook 'company-maybe-turn-on-fci)
(provide 'general-code-settings)
;;; general-code-settings.el ends here
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Configuring Anaconda-Mode and Company-Mode with IPython
2015-04-15 13:42 Configuring Anaconda-Mode and Company-Mode with IPython daniel.galtieri
@ 2015-04-17 1:36 ` Dmitry Gutov
[not found] ` <mailman.851.1429234616.904.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2015-04-17 1:36 UTC (permalink / raw)
To: daniel.galtieri, help-gnu-emacs
Hi!
On 04/15/2015 04:42 PM, daniel.galtieri@gmail.com wrote:
> I am new to using Emacs, and am currently trying to configure it to be a more robust environment for coding in Python.
>
> To do this I'm using Company-Mode with Anaconda-Mode for autocompletion, along with the defaul Python.el mode
>
> I would like to use IPython as my repl, but I'm experiencing some odd behavior with autocompletion in the IPython buffer (autocompletion works fine in the normal python buffer(s)).
Sorry, I don't do Python, and I'm a bit too busy to try you config.
Here's what you should try:
First, disable anaconda-mode and see how much of the described behavior
you can reproduce. If there are problems you can now attribute to
anaconda-mode, file issues on its bug tracker.
The rest of those should be problems or limitations of the built-in
Emacs completion (which uses the REPL buffer), which you can file bugs
for, with `M-x report-emacs-bug'.
But to double-check, disable `company-mode', and try pressing C-M-i: you
should see the same results in the *Completions* buffer.
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.851.1429234616.904.help-gnu-emacs@gnu.org>]
* Re: Configuring Anaconda-Mode and Company-Mode with IPython
[not found] ` <mailman.851.1429234616.904.help-gnu-emacs@gnu.org>
@ 2015-04-17 2:48 ` Daniel Galtieri
2015-04-17 20:41 ` Dmitry Gutov
[not found] ` <mailman.961.1429303304.904.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Daniel Galtieri @ 2015-04-17 2:48 UTC (permalink / raw)
To: help-gnu-emacs
On Friday, April 17, 2015 at 1:36:58 AM UTC, Dmitry Gutov wrote:
> Hi!
>
> On 04/15/2015 04:42 PM, daniel.galtieri@gmail.com wrote:
> > I am new to using Emacs, and am currently trying to configure it to be a more robust environment for coding in Python.
> >
> > To do this I'm using Company-Mode with Anaconda-Mode for autocompletion, along with the defaul Python.el mode
> >
> > I would like to use IPython as my repl, but I'm experiencing some odd behavior with autocompletion in the IPython buffer (autocompletion works fine in the normal python buffer(s)).
>
> Sorry, I don't do Python, and I'm a bit too busy to try you config.
> Here's what you should try:
>
> First, disable anaconda-mode and see how much of the described behavior
> you can reproduce. If there are problems you can now attribute to
> anaconda-mode, file issues on its bug tracker.
>
> The rest of those should be problems or limitations of the built-in
> Emacs completion (which uses the REPL buffer), which you can file bugs
> for, with `M-x report-emacs-bug'.
>
> But to double-check, disable `company-mode', and try pressing C-M-i: you
> should see the same results in the *Completions* buffer.
So I spoke with the dev for Anaconda-mode and it seems that it doesn't work in the inferior python mode buffer, which is why it's not even listed as a minor mode in my inferior buffer. Disabling Anaconda-mode as you suggested doesn't change any of the described behavior, which isn't too surprising.
C-M-i provides all the correct completion options. The issue seems to be with whatever mechanism is behind generating the autocomplete tooltips. I'm not entirely sure what I changed, or if this never worked to begin with and I was mistaken in the first place, but if I do the following, for example:
sys.p M-x company-complete to manually start completion I get "No completion found". But if I type C-M-i I get a completions buffer with the appropriate methods.
Oddly, if I type sys.p and then change my focus to another application (e.g. I click inside of firefox) and then switch my focus back to Emacs, typing "a" (for example) results in the autocompletion tooltip to pop up.
There seems to be something funky going on, but I'm not entirely sure where to direct my questions.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Configuring Anaconda-Mode and Company-Mode with IPython
2015-04-17 2:48 ` Daniel Galtieri
@ 2015-04-17 20:41 ` Dmitry Gutov
[not found] ` <mailman.961.1429303304.904.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2015-04-17 20:41 UTC (permalink / raw)
To: Daniel Galtieri, help-gnu-emacs
On 04/17/2015 05:48 AM, Daniel Galtieri wrote:
> C-M-i provides all the correct completion options. The issue seems to be with whatever mechanism is behind generating the autocomplete tooltips. I'm not entirely sure what I changed, or if this never worked to begin with and I was mistaken in the first place, but if I do the following, for example:
Thanks for checking. Looking into this, seems like it never worked in
the Python REPL buffers (or at least hasn't for a long while).
The `company-capf' backend wasn't used, you were simply getting
completions from `company-dabbrev'.
> sys.p M-x company-complete to manually start completion I get "No completion found". But if I type C-M-i I get a completions buffer with the appropriate methods.
I've pushed a fix below to the master repo. It should work now.
> Oddly, if I type sys.p and then change my focus to another application (e.g. I click inside of firefox) and then switch my focus back to Emacs, typing "a" (for example) results in the autocompletion tooltip to pop up.
Sounds odd, but you probably weren't getting the right completions in
this scenario, too.
> There seems to be something funky going on, but I'm not entirely sure where to direct my questions.
The company-mode issue tracker is an okay venue for this kind of
questions, too.
diff --git a/company-capf.el b/company-capf.el
index 4962a26..17b739b 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -1,6 +1,6 @@
;;; company-capf.el --- company-mode completion-at-point-functions
back-end -*- lexical-binding: t -*-
-;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
@@ -51,7 +51,7 @@
(data (run-hook-wrapped 'completion-at-point-functions
;; Ignore misbehaving functions.
#'completion--capf-wrapper
'optimist)))
- (when (and (consp (cdr data)) (numberp (nth 1 data))) data)))
+ (when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data)))
data)))
(defun company-capf (command &optional arg &rest _args)
"`company-mode' back-end using `completion-at-point-functions'."
^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <mailman.961.1429303304.904.help-gnu-emacs@gnu.org>]
* Re: Configuring Anaconda-Mode and Company-Mode with IPython
[not found] ` <mailman.961.1429303304.904.help-gnu-emacs@gnu.org>
@ 2015-06-16 15:53 ` Daniel Galtieri
2015-06-17 10:35 ` Dmitry Gutov
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Galtieri @ 2015-06-16 15:53 UTC (permalink / raw)
To: help-gnu-emacs
Sorry to ressurrect this, have been meaning to come back and respond. With the updates you've made I'm still not seeing the behavior I'd quite expect.
Rather than trying to explain it, I just took a screencast of what I'm seeing:
https://www.youtube.com/watch?v=E5TuC68ByK8&feature=youtu.be
Maybe this is how it should be behaving and I'm just expecting something that it can't do. The behavior that I'm just to describe though is what you see when I type out "datetime" and can't get a completion for the methods associated with it. Hitting tab after the "." gives me a list of completions-at-point (this is shown in the video), but company does not (either automatically or manually with company-complete).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Configuring Anaconda-Mode and Company-Mode with IPython
2015-06-16 15:53 ` Daniel Galtieri
@ 2015-06-17 10:35 ` Dmitry Gutov
[not found] ` <CAJgjJzRHOuFt9kAhucRL75STfohapqid+u72S2DrztjqxhO4ig@mail.gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2015-06-17 10:35 UTC (permalink / raw)
To: Daniel Galtieri, help-gnu-emacs
Hi again!
On 06/16/2015 06:53 PM, Daniel Galtieri wrote:
> Sorry to ressurrect this, have been meaning to come back and respond. With the updates you've made I'm still not seeing the behavior I'd quite expect.
You haven't mentioned your Emacs version. But in any case, it wouldn't
hurt to try the current master.
> Rather than trying to explain it, I just took a screencast of what I'm seeing:
>
> https://www.youtube.com/watch?v=E5TuC68ByK8&feature=youtu.be
Unfortunately, I'm not seeing the exact problem. There have been quite a
few times in this video when the completion popup was displayed after
"datetime.".
> The behavior that I'm just to describe though is what you see when I type out "datetime" and can't get a completion for the methods associated with it.
It works for me, and I've seen it work in this video.
Is this complaint about the misbehavior around 0:17? I can't reproduce it.
> Hitting tab after the "." gives me a list of completions-at-point (this is shown in the video), but company does not (either automatically or manually with company-complete).
Please don't say you're using M-x completion-at-point when you're
actually using Helm. Why don't you disable it first, before trying to
reproduce this problem.
Instead of M-x company-complete, maybe try M-x company-complete-common.
The former command is a bit weird when called from M-x.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-06-23 3:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 13:42 Configuring Anaconda-Mode and Company-Mode with IPython daniel.galtieri
2015-04-17 1:36 ` Dmitry Gutov
[not found] ` <mailman.851.1429234616.904.help-gnu-emacs@gnu.org>
2015-04-17 2:48 ` Daniel Galtieri
2015-04-17 20:41 ` Dmitry Gutov
[not found] ` <mailman.961.1429303304.904.help-gnu-emacs@gnu.org>
2015-06-16 15:53 ` Daniel Galtieri
2015-06-17 10:35 ` Dmitry Gutov
[not found] ` <CAJgjJzRHOuFt9kAhucRL75STfohapqid+u72S2DrztjqxhO4ig@mail.gmail.com>
2015-06-17 20:08 ` Dmitry Gutov
2015-06-23 3:05 ` Daniel Galtieri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).