跳转到emacs中的java方法
|
我想通过方法跳转我的 java文件,例如当我有我的任何地方,做一个键盘快捷方式跳转到方法的下一端或方法的开头. Emacs使用C-M-a和C-M-e“通过默认移动”对C来说非常有用,并且完全符合我的要求.但显然在Java中,defun是一个完整的类. 通过defuns移动: 我发现我可以强迫C-M-f和C-M-b做我想做的事.他们在任何括号平衡的表达式上前后移动.问题是,当从方法定义的开头或右边括号外调用时,它们只具有我正在寻找的功能,这是非常有限的. 平衡括号的表达式: 任何想法都会受到欢迎! 解决方法imenu和 speedbar接近你想要的.否则你可以自己定义它. (defvar java-function-regexp
(concat
"^[ t]*" ; leading white space
"(public|private|protected|" ; some of these 8 keywords
"abstract|final|static|"
"synchronized|native"
"|[ tnr])*" ; or whitespace
"[a-zA-Z0-9_$]+" ; return type
"[ tnr]*[[]?[]]?" ; (could be array)
"[ tnr]+" ; whitespace
"([a-zA-Z0-9_$]+)" ; the name we want!
"[ tnr]*" ; optional whitespace
"(" ; open the param list
"([ tnr]*" ; optional whitespace
"<[a-zA-Z0-9_$]+>" ; typename
"[ tnr]*[[]?[]]?" ; (could be array)
"[ tnr]+" ; whitespace
"<[a-zA-Z0-9_$]+>" ; variable name
"[ tnr]*[[]?[]]?" ; (could be array)
"[ tnr]*,?)*" ; opt whitespace and comma
"[ tnr]*" ; optional whitespace
")" ; end the param list
))
(defun my:next-java-method()
(interactive)
(re-search-forward java-function-regexp nil t)
)
(defun my:prev-java-method()
(interactive)
(re-search-backward java-function-regexp nil t)
)
然后将my:next-java-method和my:prev-java-method绑定到你要去的任何键 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
