unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* 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

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).