hlissner/emacs-pug-mode

Sub-elements of a div that does not have a div tag do not get indented

ajpauwels opened this issue · 2 comments

Example code, this works properly:

div#myExampleDiv
    p An example paragraph

When I write the div, then hit enter, and then hit tab, pug-mode correctly indents the p tag.

This does not work:

#myExampleDiv
    p An example paragraph

When the tag name is not provided, Pug assumes a div is desired. Pug-mode does not, however, detect that this is a valid div and does not properly indent the p tag inside the div.

This is not a big deal on new projects, as I think it's cleaner to specify the div tag explicitly, however when working in codebases where the tag-less style is used, it makes indenting a pain.

Sorry for taking so long to get to this. I'm trying to reproduce this and don't quite understand what the problem is. I've tried this myself and they both appear to indent correctly.

pug

Mind you, I've remapped newline to newline-and-indent, like so:

(global-set-key [remap newline] #'newline-and-indent)

I've tried it with newline + TAB, but I get the same results. What am I looking for?

You're right, the problem only happens one level of nesting deep. For example, try this:

#firstExampleDiv
	#secondExampleDiv

Now try indenting below #secondExampleDiv and it'll put the cursor at the same level as #secondExampleDiv, whereas I would like to have the option to indent into #secondExampleDiv