I'm trying to devise a function which returns the class name. I would like to call that function inside a Yasnippet snippet for PHP-mode, so the class name will be inserted inside the template snippet.
After reading Emacs documentation, I found which-function-mode
, which it returns a function name. But nothing about class names, unfortunately. Do anyone know a alternative way to get the class name of the position/current buffer?
Edit: I found an regex in the imenu source code that matches the name of the classes in PHP. But now I'm wondering how he could returns the result for yasnippet: ("^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?class\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)" 1)