fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.63k stars 262 forks source link

don't close element on `>` when element is already closed #1276

Closed bzy-debug closed 1 year ago

bzy-debug commented 1 year ago

Thanks for creating this wonderful package, it really helps a lot!

I'm currently using web-mode with this config:

(setq web-mode-auto-close-style 2)

The behaviour of auto closing on > makes it a bit of annoying when working with emmet. In emmet, > can be used to create nested tags, and the auto closing behaviour of > makes this feature unusable. For example, under this circumstance (| is the position of cursor):

<body>
  |
</body>

To create two nesting div and p elements using emmet, I need to type div>p. However, when I type >, it triggers the auto close of the body element, resulting something like this:

<body>
  div></body>p|
</body>

Is it possible not to let > trigger auto close body when the body is already closed?

Thanks again for your greate package!

yugaego commented 1 year ago

You should be able to change web-mode-auto-close-style, setting it to 1 or 3, or disable web-mode-enable-auto-closing for the files that need it. There's a number of approaches to do that, so it's up to your exact setup and taste. For instance, set these custom options with M-: (setq-local web-mode-auto-close-style 1), or custom keybinding, or some hook, etc.

bzy-debug commented 1 year ago

Thanks for your reply. I’m currently switch to vscode for web development. This is not a issue for me.