Find the answer to your Linux question:
Results 1 to 7 of 7
I've just started learning Python and intending to use Emacs for it. I need to switch on syntax highlighting for Python code in Emacs as it doen't already have it. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2005
    Location
    The Slammer
    Posts
    137

    Need help with Emacs


    I've just started learning Python and intending to use Emacs for it. I need to switch on syntax highlighting for Python code in Emacs as it doen't already have it. Another thing I want is this:
    For example, I write an indented line of code. I want that on hitting <RETURN>, the cursor should be placed below the first letter of the previous line, not on the margin (Kind of like the indentation option in GEdit). I hope you understand and can provide a solution.

    As usual, thanx.
    Registered Linux User #394578

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I don't know about the indentation Emacs Python mode, but in C mode, the default is indeed to place the cursor by the margin after you press enter. You'll then have to press Tab to get automatic indentation. I don't know if this works in Python mode, but in C mode, you can get it to indent automagically by doing this:
    Code:
    M-x local-set-key RET RET newline-and-indent RET
    (I assume that you're familiar with Emacs typing markup)

    As for Python mode not working, I'm not sure exactly what you mean. Do you just have to enable python-mode manually by typing M-x python-mode RET, or isn't it installed at all?

  4. #4
    Linux Newbie
    Join Date
    Apr 2005
    Location
    The Slammer
    Posts
    137
    Thanx for the link. But is that text supposed to replce the original or go after it?

    And no, the indentation doesn't work.

    Uh..a bit off topic, but should I download Dr. Python, an editor for Python? Is it as powerful as Emacs (coz i've got used to emacs now)?
    Registered Linux User #394578

  5. #5
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    I think that downloading a completely new editor just for syntax hilighting is a bit extreme. And if you have any python-based stuff already in there, I'd comment it out, and see how you like this new one.

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Quote Originally Posted by {MaX}
    Thanx for the link. But is that text supposed to replce the original or go after it?
    It's supposed to go after the existing text in your ~/.emacs.

    Quote Originally Posted by {MaX}
    And no, the indentation doesn't work.
    Well, I don't use Python, and therefore by extension I don't use python-mode, so I can't really say why it doesn't work. It would have worked in c-mode, though.

    Quote Originally Posted by {MaX}
    Uh..a bit off topic, but should I download Dr. Python, an editor for Python? Is it as powerful as Emacs (coz i've got used to emacs now)?
    Personally, I think Emacs is one of the best things the world has ever seen, so my opinion is clearly that you should go with Emacs, no matter what. I don't think that there really can be anything as powerful as Emacs (at least not as long as you know LISP).

  7. #7
    Linux Newbie
    Join Date
    Apr 2005
    Location
    The Slammer
    Posts
    137
    Whoops! All I needed was to install the python-mode from apt.
    Everything works now. Sorry for wastin' your time...
    Registered Linux User #394578

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •