Under my home directory I have a .emacs file which has the following lines -

(add-to-list 'load-path "~/.emacs.d/")
(require 'cython-mode)

and under the .emacs.d directory I have this file - cython-mode.el which I downloaded from here - Cython-mode.el and I have been using emacs with Cython for over a week now but I cannot seem to do a tab. When I hit tab it does not indent at all. Where am I going wrong ?

Sample example -

cdef extern from "Skip_list.cpp":

The pass word should come under extern but it does not. I am not able to figure out why.

OS - Ubuntu 18.04 LTS, Cython 0.24 , Emacs version - 25.2


When I type M-x cython-mode the word "pass" does get indented properly but I get this message at the bottom of emacs. Why is this not done automatically and does this mean I have to do it manually every single time ?

Can't guess python-indent-offset ,using defaults : 4

I also did a

 find . -name "python.el" 


 find . -name "python-mode.el"

as user root on my Ubuntu and both these finds gave me null results.

  • 1
    You can use M-xlocate-library to tell you exactly where Emacs is getting a particular library from. In your case it's possible that you only have the compiled versions, which would all be filenames ending in .elc
    – rpluim
    Sep 25, 2018 at 8:47
  • @rpluim - Excellent point. There is indeed a python.elc. How do you suggest I fix my problem ?
    – gansub
    Sep 25, 2018 at 8:52
  • I don't think there's a problem to fix, unless you're unhappy with python-mode's default of 4 space indenting. If you're referring to having to type M-xcython-mode, then you should investigate the documentation of the variable auto-mode-alist
    – rpluim
    Sep 25, 2018 at 9:25
  • @rpluim I read about it but I am not sure how it will help ensure that my Cython code is indented properly
    – gansub
    Sep 25, 2018 at 9:38
  • You said that indentation happens as intended after you do M-xcython-mode, which indicates your buffer is not being put in cython-mode automatically. auto-mode-alist is a way of indicating which modes gets used based on the name of the file you're editing.
    – rpluim
    Sep 25, 2018 at 13:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.