0

I have been using Emacs for some time but I am quite new for PHP and Web development. I want to use Emacs as a PHP editor.

I have searched a lot of pages and I have found that many people recommend web-mode for editing mixed PHP and HTML code.

I installed it from MELPA and started using it but I have a problem with curly brackets indentation. As you can see on the attached screenshot I have two blocks of PHP code separated by a small piece of HTML.

It seems that web-mode cannot recognize that the second block is a continuation of the first one so the curly braces and the else clause are automatically aligned to the left side. This looks very ugly.

I tried to find a solution by reading documentation and searching in Google but I could not find anything helpful.

How can I get this working correctly? Is it something that should be added to the configuration file?

--- WEB-MODE DEBUG BEG ---
versions: emacs(26.3) web-mode("17.0.0")
vars: engine("php") minor("php") content-type("html") file("x:/www/delete.php")
system: window(w32) config("x86_64-w64-mingw32")
colors: fg(nil) bg(nil) 
minor modes: (global-eldoc-mode)
vars:
web-mode-enable-current-column-highlight=t 
web-mode-enable-current-element-highlight=nil 
indent-tabs-mode=t 
--- WEB-MODE DEBUG END ---
You can run the command ‘web-mode-debug’ with M-x w-deb RET
--- WEB-MODE DEBUG END ---

enter image description here

1
  • 1
    I don't think that you can do much, web-mode isn't made for that although it can handle it. Also your file is mostly php and it'll be better handled by a php mode. In your case - regardless what is in the code and how it'll work - I'd place everything in the same block, with the html either in a variable or a external file included in when your else clause is executed. – Muihlinn Jun 15 '20 at 6:58

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.