elisp def
1.0.0
转到点处的符号的定义。支持全球定义,本地定义甚至宏观代码!

elisp-def静态分析您的代码,并归结为无法实现的启发式方法。它应该有99%的时间工作,因此,如果找不到代码的定义,请提交错误。
从MELPA安装,然后将以下内容添加到您的Emacs配置中:
( dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
( add-hook hook # 'elisp-def-mode ))elisp-def将在点找到全局函数和全局变量的定义。
( defun demo/foo ()
1 )
( defun demo/bar ()
; ; M-x eval-buffer, then elisp-def on this:
(demo/foo))它还将使用Edebug信息来查找功能定义,因此比XREF更频繁地找到定义。
elisp-def了解符号和函数之间的区别,并跳到正确的定义。
( require 'cc-mode )
; ; `c-version' is both a variable and a function.
( defun demo/foo ()
; ; `elisp-def` will find the function here.
( c-version ))
( defun demo/foo ()
; ; `elisp-def` will find the variable here.
( setq c-version t ))elisp-def了解宏,因此它可以准确检测功能参考。
( require 'dash )
( defvar demo/foo nil )
( defun demo/foo ( x )
x)
( defun demo/bar ()
(-> > 123
; ; `elisp-def' knows that this is a function, even though there are
; ; no parens.
demo/foo))它还可以理解定义函数或变量的宏。
( define-derived-mode demo/foo-mode fundamental-mode " demo " )
; ; `elisp-def' will expand macros to discover where major mode hooks
; ; are defined.
demo/foo-mode-hook
( cl-defstruct demo/point x y)
; ; `elisp-def' can find this function even though the defstruct
; ; call doesn't contain this symbol name.
(make-demo/point 1 2 )elisp-def将找到库,并在可能的情况下显示provide声明。
; ; `elisp-def' will open python.el here.
( require 'python )
; ; Unlike `xref-find-definition' , `elisp-def' will not confuse this
; ; library name with the macro named `use-package' .
( require 'use-package )
; ; `elisp-def' will even find python.el here, because the macro
; ; expands to a call to `require' .
( use-package python
:config
( setq python-indent-guess-indent-offset-verbose nil ))elisp-def了解局部绑定和参数。
( defun demo/foo ( bar )
( let ((foo 1 ))
; ; `elisp-def' on the FOO below will move point to the let
; ; binding.
( setq foo 2 )
; ; `elisp-def' on the BAR below will move point to the function
; ; parameters line.
( setq bar 3 )))
( defun demo/bar ()
( let* ((foo 1 )
(bar 2 )
(foo 3 )
; ; `elisp-def' on the second FOO on the following line will
; ; move point to the relevant binding, which is the line
; ; immediately above.
(foo ( + foo 1 ))
(foo 5 ))
nil ))这甚至与引入绑定的宏相关。
( require 'dash )
( eval-when-compile
( require 'cl-lib ))
( defun demo/foo ( items )
( cl-destructuring-bind ( first second) items
; ; `elisp-def' knowns that FIRST is bound on line above.
( message " first is %s " first))
(-let [( first . rest) items]
; ; `elisp-def' knowns that FIRST is bound on line above.
( message " first is %s " first)))elisp-def允许您对引用的符号,DocString符号或反向引用的符号提出点。
( defun demo/foo ( x )
; ; `elisp-def' on X in the docstring will find the parameter.
" Adds one to X and returns it. "
( 1+ x))
( defun demo/bar ()
; ; `elisp-def' can find demo/foo even when point is on the #.
( funcall # 'demo/foo 1 )
; ; `elisp-def' on demo/foo below will find the function.
; ;
; ; See `demo/foo' for more information.
nil )
( defun demo/baz ( foo )
; ; `elisp-def' understands that @ is not part of foo here.
`(blah ,@foo ))当它找到符号时,ELISP-DEF还将暂时突出显示其可见度。
elisp-def分析能力有限。
; ; `elisp-def' is able to find these quoted symbols because they're
; ; only globally bound in one namespace.
( mapcar 'symbol-name '(foo bar baz))
( add-to-list 'auto-mode-alist '( " \ .java \ ' " . java-mode))
( require 'cc-mode )
( defun demo/calls-fn ( sym )
( funcall sym))
; ; Since `c-version' is both a function and a variable, and we're not
; ; using a sharp-quote #'c-version, we have to prompt the user.
(demo/calls-fn 'c-version )
( defun demo/foo ( c-version )
; ; Here we have no idea whether we're using `c-version' as a
; ; function (e.g. funcall), as a variable (e.g. set) or as a
; ; parameter (e.g. eval).
(bar 'c-version nil )) elisp-def找不到let*语义和重复变量的宏中的定义。
( require 'dash )
( defun demo/foo ()
(-let ((x 1 )
(x 2 ))
; ; `elisp-def' on X below will move to the first X binding, rather
; ; than the second.
x)) elisp-def也无法处理重写形式的宏,以使符号完全消失。
( eval-when-compile ( require 'cl-lib ))
( cl-labels ((foo (x y) ( + x y)))
; ; `cl-labels' completely rewrites this body to (--cl-foo-- 1 2), so
; ; `elisp-def' can't find the definition of FOO.
(foo 1 2 ))elisp-slime-nav-find-elisp-thing-at-point thaimp-slime-navemacs-lisp-mode (Emacs Core的一部分)中的xref-find-definitionssemantic/ia.el的semantic-ia-fast-jump (包括在emacs中) #emacs上的优秀人士回答了我对Elisp Esoterica的问题,尤其是Wasamasa。
Clojure完成的称赞库具有上下文的概念,这与ELISP-DEF提取和分析形式非常相似。
Hacklang也有类似的占位符的概念,用于分析代码中的某个点的完成。
GPLV3+。
我将根据开源许可为您提供存储库中的代码。因为这是我的个人存储库,所以您获得的代码许可是我的,而不是我的雇主。