1

I've started taking an html course and I'm trying to figure out how to add functionality to emacs that exists in programs like atom or brackets. I've seen a few modes web-mode.el and nxhtml mentioned but they don't seem to have the same degree of completion.

Specifically for instance in either atom or brackets you can type for example <img and a context-popup will give you options for it such as "src= " "alt= " and the complete list of attributes etc. Is there similar autocomplete functionality somewhere?

1

In stock Emacs, you can perform completion with M-TAB. If you want a popup to appear magically, then you probably want to install and enable the company package, available from GNU ELPA.

The quality/quantity of the completion candidates depends on the major mode you use. I personally use nxml-mode when I edit HTML files (which requires that I properly close my tags, but I find it a good idea anyway) which uses the XML schema to know the completions, so it's pretty good in my experience (but do install the html5-schema package from GNU ELPA, so you get an up-to-date schema, since the schema that comes with Emacs is for HTML4).

5
  • We don't have any "smart" completion for html-mode in stock Emacs though, do we? – Dmitry Nov 19 '17 at 8:41
  • If you use nxml-mode there is. – Stefan Nov 19 '17 at 14:04
  • Even then, it seems to offer no completions in "normal" HTML files. Probably different for XHTML files, but there are not many of those left these days. – Dmitry Nov 19 '17 at 23:47
  • Not sure what you mean. I always edit my HTML files with nxml-mode (using the html5-schema GNU ELPA package). – Stefan Nov 20 '17 at 14:18
  • That's great (and should probably be mentioned in the answer). Too bad this doesn't help the cases where we have to use html-mode anyway (mhtml-mode, templating fragments, and so on). – Dmitry Nov 21 '17 at 11:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.