smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Clarify HTML tag pairing

Open Wilfred opened this issue 9 years ago • 6 comments
trafficstars

I'd like to be able to type <p> and have smartparens automatically add </p>.

smartparens-html.el seems to contain code that does this:

(sp-with-modes sp--html-modes
  (sp-local-pair "<" ">")
  (sp-local-tag  "<" "<_>" "</_>" :transform 'sp-match-sgml-tags :post-handlers '(sp-html-post-handler)))

However, sp-match-sgml-tags is marked as deprecated as of f4c0f0da485f9bbbff39e51b4673b035ed1320a6. That commit says "remove tags", but sp-local-tag doesn't seem to be deprecated.

So, what are tags in smartparens? Are they still supported? Should smartparens be able to add a closing HTML </foo>?

Wilfred avatar Dec 21 '15 18:12 Wilfred

They are in a somewhat weird state, it doesn't work but the code is there to keep working config working.

The long-term plan is to unify tags with normal pairs because they are really nothing special (we already support keyword pairs and other complicated things). The plan was to have the rewrite done by the end of february this year... apparently it didn't work out :/

Fuco1 avatar Dec 21 '15 18:12 Fuco1

Hi, what's the situation with this? Have html tags been abandoned for now?

AlexChalk avatar Mar 09 '17 16:03 AlexChalk

I have a rather low priority plan to bring this back, I feel like html-mode or web-mode and similar do better job with the insertion, then can handle special cases like no-closing-tag tags and similar. The tag parsing in smartparens still works though, and you can use slupr/barf etc. just as ever.

Fuco1 avatar Mar 10 '17 09:03 Fuco1

FWIW https://github.com/magnars/tagedit can do this, if you need a solution today.

I haven't seen any functionality in html-mode for this: sgml-tag only creates the opening tag, then sgml-close-tag closes it (handy, but requires an extra command). @Fuco1 have I missed some awesome workflow?

Wilfred avatar Mar 10 '17 11:03 Wilfred

@Wilfred no idea, I don't do html :)

Fuco1 avatar Mar 10 '17 12:03 Fuco1

Thanks both—I think you're right, tagedit and web-mode already provide great solutions. Maybe it's worth linking to those packages in the readme to help html people find what they're looking for?

AlexChalk avatar Mar 10 '17 14:03 AlexChalk