LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-24-2006, 05:09 AM   #1
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Rep: Reputation: 15
Editing php code easily and with proper indentation


Hi,

My editor of choice is emacs (the version I got with Red Hat 9.0 which has a number of features that make it more like xemacs that I had when I ran SuSE 7.2 - maybe it is xemacs). The auto-indentation works great with C code, but is simply wrong when I edit php script. After the 1st 'if' statement, the indentation remains. For the subsequent few 'if's and 'foreach's the code that should be further indented isn't.

I have downloaded and installed php-mode 1.2.0 from SourceForge to no avail. Same problem.

I set the "TAB" key to self-insert-command to try to do my own indentation. But emacs would still auto-indent (wrongly) on typing characters like '('.

The only way I could stop emacs from auto-indenting was to remove php-mode altogether. This is not what I want as I want the syntax highlighting. In fact, I want auto-indenting because manually indenting can be so time-consuming, especially if you change the structure of your code. I just want it to work properly.

I resorted to vi. However, as well as having to manually indent, moving between buffers in vi is not nearly as quick and convenient as with emacs.

Does anyone know of an emacs lisp file for php mode that works properly, or another good editor.

TIA,

Lost Johnny
 
Old 07-25-2006, 03:04 PM   #2
hobbestec
LQ Newbie
 
Registered: Nov 2003
Location: Boston, MA
Distribution: Debian, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 15
I've started using Kate recently and it has worked well for me.
 
Old 07-26-2006, 05:40 AM   #3
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by hobbestec
I've started using Kate recently and it has worked well for me.
Thanks,

My windows manager is Gnome, so I don't think I'll be able to use Kate, not easily at least, unless anyone knows better.

Lost Johnny
 
Old 07-26-2006, 05:43 AM   #4
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
Further to my original message, I've found that the auto-indent works fine for function definitions. It's the code that's outside of any function that's not indenting properly.
 
Old 07-26-2006, 07:00 AM   #5
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
I've found that PHP code that is outside of any function can be enclosed by a pair of braces. The script runs the same, but the emacs editor will indent properly between a pair of braces, while it will not properly indent code that is not between braces.

Graham
 
Old 07-26-2006, 08:06 AM   #6
hobbestec
LQ Newbie
 
Registered: Nov 2003
Location: Boston, MA
Distribution: Debian, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 15
Bluefish will probably work well in GNOME.
 
Old 07-27-2006, 03:14 AM   #7
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks for the info on alternative editors available.

Now that I've found the work-around of enclosing the code in braces I'll get on with what I know for now and maybe re-visit the idea of switching software if another issue comes up.

Cheers,

Graham
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to send email from PHP - How can I do this easily? wadesmart Ubuntu 6 07-06-2006 03:15 AM
Proper way of removing Apache, PHP and MySQL Basel Slackware 1 01-29-2006 04:34 AM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 08:40 AM
Editing buttons (quote, code etc.) add the code to the end vharishankar LQ Suggestions & Feedback 2 09-13-2004 09:32 AM
where to find the source code for a small easily loadable filesystem ramya272 Linux - Newbie 0 02-26-2004 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration