Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 2nd May 2008, 03:09 AM
GammaPoint Offline
Registered User
 
Join Date: May 2007
Posts: 102
Turning on syntax highlighting in emacs

Hi, I'm trying to turn on syntax highlighting in emacs for python. I saw some directions online that referred to editing my .emacs file, but I don't actually have this file, I have a .emacs.d directory (and in that directory there is no file .emacs). Could someone walk me through the steps to turn on syntax highlighting to aid my python programming?
Reply With Quote
  #2  
Old 2nd May 2008, 03:29 AM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,300
You *can* create a ~/.emacs customization file, but you don't need to enable syntax hightlighting.

If you edit a python file with the ".py" suffix it will automagically be in "pthyon-mode".
To force a buffer to python-mode type "M-x python-mode" "M-x" means meta-x in emacs lingo, (typically <esc>x). When you type M-x you'll see the minibuffer at the bottom line and just type oin i "python-mode<enter>".

If you use the command:
emacs /usr/share/glipper/plugins/grow.py
it's automaticall in python mode.

If you using emacs and you edit a python file, like:
^X^F/usr/share/glipper/plugins/grow.py
it will automatically load in python mode.

So it's already enabled. No need for the .emacs file in this case.
Reply With Quote
  #3  
Old 2nd May 2008, 03:40 AM
juanfgs's Avatar
juanfgs Offline
Registered User
 
Join Date: Mar 2008
Location: Entre Rios, Argentina
Posts: 159
well, I'm currently using emacs 23 (just compiled from CVS), and Python syntax highlighting is activated by default. I'm pretty sure that in emacs 22 it's the same.
Try the following:
open a python file, and see if the global mode changes to (Python) and then do "M-x font-lock-mode"
If it doesn't, you might want to search for a python-mode.

Also you have to actually create the .emacs files and insert elisp code there , probably you want to enable font-lock mode for Python files automatically so you should put something like this in your .emacs file:

(add-hook 'python-mode-common-hook
(font-lock-mode))
__________________
I'm back... again...
Reply With Quote
  #4  
Old 2nd May 2008, 03:46 AM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,300
btw - here is a .emacs I sometimes use

$ cat ~/.emacs
;; Linus' kernel formatting
(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux kernel."
(interactive)
(c-mode)
(c-set-style "K&R")
(setq tab-width 8)
(setq indent-tabs-mode t)
(setq c-basic-offset 8))

;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)

;; turn on font-lock mode
(when (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))

;; enable visual feedback on selections
(setq transient-mark-mode t)

;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" system-name))

;; default to unified diffs
(setq diff-switches "-u")

;; always end a file with a newline
(setq require-final-newline 'query)

(setq c-default-style "k&r")
(setq c-basic-offset 4)
Reply With Quote
  #5  
Old 2nd May 2008, 03:48 AM
juanfgs's Avatar
juanfgs Offline
Registered User
 
Join Date: Mar 2008
Location: Entre Rios, Argentina
Posts: 159
wow! there are some things that look pretty neat, I think I'll try them , thanks for sharing!
__________________
I'm back... again...
Reply With Quote
Reply

Tags
emacs, highlighting, syntax, turning

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
emacs: syntax highlighting daniel_I_l Using Fedora 1 3rd October 2008 08:46 AM
turn on syntax highlighting in vi as root susmit_koirala Using Fedora 2 11th September 2007 04:39 PM
VI syntax highlighting as root bbeverage Using Fedora 5 19th August 2006 10:33 PM
No syntax and color highlighting kishore25 Using Fedora 4 13th July 2006 08:57 AM
Emacs syntax highlighting wrong for c++ Anomaly Using Fedora 3 19th April 2005 08:51 AM


Current GMT-time: 22:26 (Wednesday, 22-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat