1

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 '15 at 11:24
  • 1
    Did you check smartparens? – fredtantini Jun 16 '15 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 '15 at 18:08
2

Such is developed here:

https://github.com/emacs-berlin/general-close

Feel free to send bug-reports and feature requests.

See also

http://lists.gnu.org/archive/html/emacs-devel/2013-09/msg00512.html

  • 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 '15 at 20:50
  • @ReneFrogertjuh Please open a ticket for this too, will look for it - thanks. – Andreas Röhler Jun 18 '15 at 6:14
  • @ReneFrogertjuh There are several modes out there dealing with php. Which one to hack again? – Andreas Röhler Jun 18 '15 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 '15 at 19:29
  • @ReneFrogertjuh Seeing a ticket requesting Melpa, not that matter. – Andreas Röhler Jun 19 '15 at 7:40

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.