When I was watching Emacs Rocks, there was a feature showed, called sgml-close-tag. You can see an example here. When called that command, he will close the tag for you if there is a tag missing. I bounded it to C-l and was hooked with it.

Then I was wondering if I could apply this with another languages.

For example, like in PHP, you have the following

 public function Foobar(){

 echo "Foobar

I will get a syntax error, there is a double quote (") missing in order to close the string "Foobar", then a semicolon (;) to end the line, and then a bracket (}) to close the function Foobar.

I was wondering if I could develop the same functionality as in the screencast above, that you need to press only one key and he will close the syntax accordingly. Would be totally awesome and an immense productivity boost.

So I'm wondering if I could be able to develop a package with this feature. I couldn't figure out to which functions I need to look. Could anyone gives me a push in the right direction, or do another suggestion?

UPDATE: this issue got solved by Andreas: https://github.com/emacs-berlin/general-close

  • Well, the source code for sgml-close-tag is probably the place to start.
    – Dan
    Jun 16, 2015 at 11:24
  • 1
    Did you check smartparens? Jun 16, 2015 at 13:00
  • In addition to smartparens and general-close already suggested, you may want to try dummy-parens, electric-pair, cleverparens, etc., as each has its use cases.
    – Emacs User
    Jun 17, 2015 at 18:08

1 Answer 1


Such is developed here:


Feel free to send bug-reports and feature requests.

See also


  • Thanks for your suggestion. It seems it will check for opening tags only, without the ability of adding a semicolon (the lines never start with a semicolon). So there must be a way to implement it.
    – ReneFroger
    Jun 17, 2015 at 20:50
  • @ReneFrogertjuh Please open a ticket for this too, will look for it - thanks. Jun 18, 2015 at 6:14
  • @ReneFrogertjuh There are several modes out there dealing with php. Which one to hack again? Jun 18, 2015 at 6:30
  • I opened a ticket on your Github page about the issue with the semicolon. Thanks for the suggestion. And what do you mean with the modes for PHP, since general-close is not bounded to a major mode?
    – ReneFroger
    Jun 18, 2015 at 19:29
  • @ReneFrogertjuh Seeing a ticket requesting Melpa, not that matter. Jun 19, 2015 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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